/[monit]/monit/alert.c
ViewVC logotype

Diff of /monit/alert.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by martinp, Mon Dec 16 10:15:39 2002 UTC revision 1.11 by hauk, Sat Dec 21 13:56:04 2002 UTC
# Line 84  static char desclog[][STRLEN]= {"Timeout Line 84  static char desclog[][STRLEN]= {"Timeout
84  void smtp_alert_timeout(Process_T p, char *m, ...) {  void smtp_alert_timeout(Process_T p, char *m, ...) {
85    
86    va_list ap;    va_list ap;
87    
88      ASSERT(p);
89      ASSERT(m);
90        
91    va_start(ap, m);    va_start(ap, m);
92    smtp_alert(p, DO_TIMEOUT, m, ap);    smtp_alert(p, DO_TIMEOUT, m, ap);
# Line 103  void smtp_alert_checksum(Process_T p, ch Line 106  void smtp_alert_checksum(Process_T p, ch
106    
107    va_list ap;    va_list ap;
108        
109      ASSERT(p);
110      ASSERT(m);
111    
112    va_start(ap, m);    va_start(ap, m);
113    smtp_alert(p, DO_CHECKSUM, m, ap);    smtp_alert(p, DO_CHECKSUM, m, ap);
114    va_end(ap);    va_end(ap);
# Line 119  void smtp_alert_restart(Process_T p, cha Line 125  void smtp_alert_restart(Process_T p, cha
125    
126    va_list ap;    va_list ap;
127        
128      ASSERT(p);
129      ASSERT(m);
130    
131    va_start(ap, m);    va_start(ap, m);
132    smtp_alert(p, DO_RESTART, m, ap);    smtp_alert(p, DO_RESTART, m, ap);
133    va_end(ap);    va_end(ap);
# Line 135  void smtp_alert_resource(Process_T p, ch Line 144  void smtp_alert_resource(Process_T p, ch
144    
145    va_list ap;    va_list ap;
146        
147      ASSERT(p);
148      ASSERT(m);
149    
150    va_start(ap, m);    va_start(ap, m);
151    smtp_alert(p, DO_RESOURCE, m, ap);    smtp_alert(p, DO_RESOURCE, m, ap);
152    va_end(ap);    va_end(ap);
# Line 151  void smtp_alert_stop(Process_T p, char * Line 163  void smtp_alert_stop(Process_T p, char *
163    
164    va_list ap;    va_list ap;
165        
166      ASSERT(p);
167      ASSERT(m);
168    
169    va_start(ap, m);    va_start(ap, m);
170    smtp_alert(p, DO_STOP, m, ap);    smtp_alert(p, DO_STOP, m, ap);
171    va_end(ap);    va_end(ap);
# Line 167  void smtp_alert_failed(Process_T p, char Line 182  void smtp_alert_failed(Process_T p, char
182    
183    va_list ap;    va_list ap;
184    
185      ASSERT(p);
186      ASSERT(m);
187    
188    va_start(ap, m);    va_start(ap, m);
189    smtp_alert(p, DO_FAILED, m, ap);    smtp_alert(p, DO_FAILED, m, ap);
190    va_end(ap);    va_end(ap);
# Line 183  void smtp_alert_timestamp(Process_T p, c Line 201  void smtp_alert_timestamp(Process_T p, c
201    
202    va_list ap;    va_list ap;
203    
204      ASSERT(p);
205      ASSERT(m);
206    
207    va_start(ap, m);    va_start(ap, m);
208    smtp_alert(p, DO_TIMESTAMP, m, ap);    smtp_alert(p, DO_TIMESTAMP, m, ap);
209    va_end(ap);    va_end(ap);
# Line 198  void smtp_alert_timestamp(Process_T p, c Line 219  void smtp_alert_timestamp(Process_T p, c
219   */   */
220  static void smtp_alert(Process_T p, int event, char *optmsg, va_list ap) {  static void smtp_alert(Process_T p, int event, char *optmsg, va_list ap) {
221    
222      ASSERT(p);
223    
224    if(p->maillist) {    if(p->maillist) {
225    
226      Mail_T m;      Mail_T m;
# Line 263  static void substitute(Mail_T *m, char * Line 286  static void substitute(Mail_T *m, char *
286    char *now= get_ctime();    char *now= get_ctime();
287    char *host= get_localhostname();    char *host= get_localhostname();
288    
289      ASSERT(m && name && event);
290    
291    replace(&(*m)->from, "$HOST", host);    replace(&(*m)->from, "$HOST", host);
292    replace(&(*m)->subject, "$DATE", now);    replace(&(*m)->subject, "$DATE", now);
293    replace(&(*m)->message, "$DATE", now);    replace(&(*m)->message, "$DATE", now);
# Line 284  static void replace(char **src, char *ol Line 309  static void replace(char **src, char *ol
309    int i= count(*src, old);    int i= count(*src, old);
310    int d= strlen(new)-strlen(old);    int d= strlen(new)-strlen(old);
311    
312      ASSERT(src && old && new);
313    
314    if(i==0)    if(i==0)
315        return;        return;
316    if(d>0)    if(d>0)
# Line 323  static int count(char *src, char *needle Line 350  static int count(char *src, char *needle
350    int i= 0;    int i= 0;
351    char *p= src;    char *p= src;
352    
353      ASSERT(p && needle);
354      
355    while((p= strstr(p, needle))) { i++;  p++; }    while((p= strstr(p, needle))) { i++;  p++; }
356    
357    return i;    return i;
# Line 332  static int count(char *src, char *needle Line 361  static int count(char *src, char *needle
361    
362  static void copy_mail(Mail_T n, Mail_T o) {  static void copy_mail(Mail_T n, Mail_T o) {
363    
364      ASSERT(n && o);
365      
366    n->to= xstrdup(o->to);    n->to= xstrdup(o->to);
367    n->from=    n->from=
368        o->from?        o->from?

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26