/[monit]/monit/p.y
ViewVC logotype

Diff of /monit/p.y

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

revision 1.79 by martinp, Sun Jun 22 18:02:31 2003 UTC revision 1.80 by hauk, Tue Jun 24 02:49:09 2003 UTC
# Line 83  Line 83 
83      int pidfile;      int pidfile;
84    };    };
85    
   struct MailFilter {  
     char *from;  
     char *subject;  
     char *message;  
     int  timeout;  
     int  restart;  
     int  checksum;  
     int  resource;  
     int  stop;  
     int  timestamp;  
   };  
86    
87    struct PortSet {    struct PortSet {
88      int  socket;      int  socket;
# Line 140  Line 129 
129    extern FILE *yyin;    extern FILE *yyin;
130    extern int lineno;    extern int lineno;
131    extern char *yytext;    extern char *yytext;
132    
133        
134    /* Local variables */    /* Local variables */
   static Service_T tail= NULL;  
135    static int cfg_errflag= FALSE;    static int cfg_errflag= FALSE;
136      static Service_T tail= NULL;
137    static Service_T current= NULL;    static Service_T current= NULL;
138      static struct mymail mailset;
139      static struct myalert alertset;
140    static Command_T command= NULL;    static Command_T command= NULL;
141    static Service_T depend_list= NULL;    static Service_T depend_list= NULL;
142    static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE};    static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE};
   static struct MailFilter mtf= {NULL, NULL, NULL, FALSE, FALSE, FALSE,  
     FALSE, FALSE, FALSE};  
143    static struct PortSet portset= {-1, NULL, 0, SOCK_STREAM, AF_INET, FALSE,    static struct PortSet portset= {-1, NULL, 0, SOCK_STREAM, AF_INET, FALSE,
144      SSL_VERSION_AUTO, NULL, NULL, NULL, NULL};      SSL_VERSION_AUTO, NULL, NULL, NULL, NULL};
145    static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1,    static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1,
# Line 161  Line 151 
151    /* Private prototypes */    /* Private prototypes */
152    static void initialize();    static void initialize();
153    static void addservice(Service_T);    static void addservice(Service_T);
154    static void addmail(char *, struct MailFilter *);    static void addmail(char *, Mail_T, Alert_T);
155    static void createservice(int, char *, char *);    static void createservice(int, char *, char *);
156    static void adddependant(char *);    static void adddependant(char *);
157    static void addchecksum(char *, char *);    static void addchecksum(char *, char *);
# Line 179  Line 169 
169    static void setmailserver(char *);    static void setmailserver(char *);
170    static void setuname(char *);    static void setuname(char *);
171    static void setpasswd(char *);    static void setpasswd(char *);
172    static void reset_mailfilter();    static void reset_mailset();
173    static void reset_runmail();    static void reset_runmail();
174    static void reset_portset();    static void reset_portset();
175    static void reset_resourceset();    static void reset_resourceset();
# Line 393  setmta          : SET MAILSERVER STRING Line 383  setmta          : SET MAILSERVER STRING
383    
384  setmailformat   : SET MAILFORMAT '{' formatoptionlist '}' {  setmailformat   : SET MAILFORMAT '{' formatoptionlist '}' {
385                     Run.MailFormat.from=                     Run.MailFormat.from=
386                          mtf.from?                          mailset.from?
387                          mtf.from:                          mailset.from:
388                          xstrdup(ALERT_FROM);                          xstrdup(ALERT_FROM);
389                     Run.MailFormat.subject=                     Run.MailFormat.subject=
390                          mtf.subject?                          mailset.subject?
391                          mtf.subject:                          mailset.subject:
392                          xstrdup(ALERT_SUBJECT);                          xstrdup(ALERT_SUBJECT);
393                     Run.MailFormat.message=                     Run.MailFormat.message=
394                          mtf.message?                          mailset.message?
395                          mtf.message:                          mailset.message:
396                          xstrdup(ALERT_MESSAGE);                          xstrdup(ALERT_MESSAGE);
397                     reset_mailfilter();                     reset_mailset();
398                   }                   }
399                  ;                  ;
400    
# Line 603  timeout         : TIMEOUT NUMBER NUMBER Line 593  timeout         : TIMEOUT NUMBER NUMBER
593                  ;                  ;
594    
595  alert           : alertmail '{' alertoptionlist '}' formatlist {  alert           : alertmail '{' alertoptionlist '}' formatlist {
596                     addmail($<string>1, &mtf);                     addmail($<string>1, &mailset, alertset);
597                   }                   }
598                  | alertmail formatlist {                  | alertmail formatlist {
599                     addmail($<string>1, &mtf);                     addmail($<string>1, &mailset, alertset);
600                   }                   }
601                  ;                  ;
602    
# Line 618  alertoptionlist : alertoption Line 608  alertoptionlist : alertoption
608                  | alertoptionlist alertoption                  | alertoptionlist alertoption
609                  ;                  ;
610    
611  alertoption     : TIMEOUT   { mtf.timeout= TRUE; }  alertoption     : TIMEOUT   { alertset.alert_on_timeout= TRUE; }
612                  | RESTART   { mtf.restart= TRUE; }                  | RESTART   { alertset.alert_on_restart= TRUE; }
613                  | CHECKSUM  { mtf.checksum= TRUE; }                  | CHECKSUM  { alertset.alert_on_checksum= TRUE; }
614                  | RESOURCE  { mtf.resource= TRUE; }                  | RESOURCE  { alertset.alert_on_resource= TRUE; }
615                  | STOP      { mtf.stop= TRUE; }                  | STOP      { alertset.alert_on_stop= TRUE; }
616                  | TIMESTAMP { mtf.timestamp= TRUE; }                  | TIMESTAMP { alertset.alert_on_timestamp= TRUE; }
617                  ;                  ;
618    
619  formatlist      : /* EMPTY */  formatlist      : /* EMPTY */
# Line 634  formatoptionlist: formatoption Line 624  formatoptionlist: formatoption
624                  | formatoptionlist formatoption                  | formatoptionlist formatoption
625                  ;                  ;
626    
627  formatoption    : MAILFROM { mtf.from= $1; }  formatoption    : MAILFROM { mailset.from= $1; }
628                  | MAILSUBJECT { mtf.subject= $1; }                  | MAILSUBJECT { mailset.subject= $1; }
629                  | MAILBODY { mtf.message= $1; }                  | MAILBODY { mailset.message= $1; }
630                  ;                  ;
631    
632  every           : EVERY NUMBER {  every           : EVERY NUMBER {
# Line 1046  static void addchecksum(char *filename, Line 1036  static void addchecksum(char *filename,
1036    
1037  /*  /*
1038   * Add the given mailaddress with the apropriate alert notification   * Add the given mailaddress with the apropriate alert notification
1039   * mask { TIMEOUT RESTART CHECKSUM RESOURCE STOP TIMESTAMP } and mail   * mask and mail attributes to the current service's mailinglist.
  * attributes to the current service's mailinglist.  
1040   */   */
1041  static void addmail(char *mailto, struct MailFilter *f) {  static void addmail(char *mailto, Mail_T f, Alert_T a) {
1042    
1043    Mail_T m= NEW(m);    Mail_T m= NEW(m);
1044    
1045    ASSERT(mailto);    ASSERT(mailto);
1046    
1047    if(f->timeout  ||    if(a.alert_on_timeout  || a.alert_on_restart  ||
1048         f->restart  ||       a.alert_on_checksum || a.alert_on_resource ||
1049         f->checksum ||       a.alert_on_stop     || a.alert_on_timestamp) {
1050         f->resource ||      
1051         f->stop     ||      memcpy(&m->alerts, &a, sizeof(Alert_T));
        f->timestamp) {  
       
     m->alert_on_timeout= f->timeout;  
     m->alert_on_restart= f->restart;  
     m->alert_on_checksum= f->checksum;  
     m->alert_on_resource= f->resource;  
     m->alert_on_stop= f->stop;  
     m->alert_on_timestamp= f->timestamp;  
1052            
1053    } else {    } else {
1054    
1055      m->alert_on_timeout= TRUE;      /* The following turns on all alerts (i.e. to TRUE). NB! remember
1056      m->alert_on_restart= TRUE;       * to update the initializer below if new members are added to the
1057      m->alert_on_checksum= TRUE;       * Alert_T object */
1058      m->alert_on_resource= TRUE;      Alert_T tmp= {1, 1, 1, 1, 1, 1};
1059      m->alert_on_stop= TRUE;      memcpy(&m->alerts, &tmp, sizeof(Alert_T));
     m->alert_on_timestamp= TRUE;  
1060            
1061    }    }
1062        
1063    m->to= mailto;    m->to= mailto;
     
1064    m->from= f->from;    m->from= f->from;
1065    m->subject= f->subject;    m->subject= f->subject;
1066    m->message= f->message;    m->message= f->message;
# Line 1089  static void addmail(char *mailto, struct Line 1068  static void addmail(char *mailto, struct
1068    m->next= current->maillist;    m->next= current->maillist;
1069    current->maillist= m;    current->maillist= m;
1070    
1071    reset_mailfilter();    reset_mailset();
1072    
1073  }  }
1074    
# Line 1620  static void setsyslog(char *facility) { Line 1599  static void setsyslog(char *facility) {
1599    
1600    
1601  /*  /*
1602   * Reset the Mail filter to default values   * Reset the current mailset and alertset for reuse
1603   */   */
1604  static void reset_mailfilter() {  static void reset_mailset() {
   
   mtf.from= NULL;  
   mtf.subject= NULL;  
   mtf.message= NULL;  
   mtf.timeout= FALSE;  
   mtf.restart= FALSE;  
   mtf.checksum= FALSE;  
   mtf.resource= FALSE;  
   mtf.stop= FALSE;  
   mtf.timestamp= FALSE;  
1605    
1606      memset(&mailset, 0, sizeof(struct mymail));
1607      memset(&alertset, 0, sizeof(struct myalert));
1608    
1609  }  }
1610    

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.80

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