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

Diff of /monit/p.y

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

revision 1.189 by hauk, Sun Dec 19 01:42:39 2004 UTC revision 1.190 by hauk, Mon Dec 20 05:39:34 2004 UTC
# Line 110  Line 110 
110  #include "ssl.h"  #include "ssl.h"
111  #include "device.h"  #include "device.h"
112    
113    
114    /* ------------------------------------------------------------- Definitions */
115    
116    struct IHavePrecedence {    struct IHavePrecedence {
117      int daemon;      int daemon;
118      int logfile;      int logfile;
119      int pidfile;      int pidfile;
120    };    };
121    
122    #define STRDUP (s) (s ? xstrdup(s) : NULL)
123    #define STRNDUP(s, l) (s&&l ? xstrndup(s, l) : NULL)
124    
125    /* yacc interface */    /* yacc interface */
126    void  yyerror(const char *,...);    void  yyerror(const char *,...);
127    void  yyerror2(const char *,...);    void  yyerror2(const char *,...);
# Line 138  Line 144 
144    static Service_T tail= NULL;    static Service_T tail= NULL;
145    static Service_T current= NULL;    static Service_T current= NULL;
146    static unsigned int eventset;    static unsigned int eventset;
147      static Request_T urlrequest= NULL;
148    static Command_T command= NULL;    static Command_T command= NULL;
149    static Command_T command1= NULL;    static Command_T command1= NULL;
150    static Command_T command2= NULL;    static Command_T command2= NULL;
# Line 156  Line 163 
163    static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE};    static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE};
164    static char * htpasswd_file= NULL;    static char * htpasswd_file= NULL;
165    static int    digesttype= DIGEST_CLEARTEXT;    static int    digesttype= DIGEST_CLEARTEXT;
166    
167        
168    /* Private prototypes */  /* -------------------------------------------------------------- Prototypes */
169    
170    static void  preparse();    static void  preparse();
171    static void  postparse();    static void  postparse();
172    static void  addservice(Service_T);    static void  addservice(Service_T);
# Line 174  Line 183 
183    static void  addgeneric(Port_T, char*, char*);    static void  addgeneric(Port_T, char*, char*);
184    static void  addcommand(int);    static void  addcommand(int);
185    static void  addargument(char *);    static void  addargument(char *);
186    static void  addcollector(char *, int, int, char *);    static void  addcollector(URL_T, int, int, char *);
187    static void  addmailserver(char *, int);    static void  addmailserver(char *, int);
188    static int   addcredentials(char *, char *, int, int);    static int   addcredentials(char *, char *, int, int);
189    static void  addhtpasswdentry(char *, char *, int);    static void  addhtpasswdentry(char *, char *, int);
# Line 187  Line 196 
196    static void  addeuid(uid_t);    static void  addeuid(uid_t);
197    static void  addegid(gid_t);    static void  addegid(gid_t);
198    static void  addeventaction(EventAction_T *, int, int);    static void  addeventaction(EventAction_T *, int, int);
199      static void  prepare_urlrequest(URL_T U);
200      static void  seturlrequest(int, char *);
201    static void  setlogfile(char *);    static void  setlogfile(char *);
202    static void  setpidfile(char *);    static void  setpidfile(char *);
203    static void  reset_mailset();    static void  reset_mailset();
# Line 212  Line 223 
223    static void  order_depend(Service_T);    static void  order_depend(Service_T);
224    static void  validate_depend(Service_T, int *);    static void  validate_depend(Service_T, int *);
225    static void  setsyslog(char *);    static void  setsyslog(char *);
226    
227  %}  %}
228    
229  %union {  %union {
230      URL_T url;
231    float real;    float real;
232    int   number;    int   number;
233    char *string;    char *string;
# Line 248  Line 261 
261  %token BYTE KILOBYTE MEGABYTE GIGABYTE  %token BYTE KILOBYTE MEGABYTE GIGABYTE
262  %token INODE SPACE PERMISSION SIZE  %token INODE SPACE PERMISSION SIZE
263  %token EXEC UNMONITOR ICMP ICMPECHO NONEXIST INVALID DATA RECOVERED  %token EXEC UNMONITOR ICMP ICMPECHO NONEXIST INVALID DATA RECOVERED
264    %token URL CONTENT
265    %token <url> URLOBJECT
266    
267  %left GREATER LESS EQUAL NOTEQUAL  %left GREATER LESS EQUAL NOTEQUAL
268    
# Line 424  collectorlist   : collector Line 439  collectorlist   : collector
439                  | collectorlist collector                  | collectorlist collector
440                  ;                  ;
441    
442  collector       : STRING nettimeout sslversion certmd5 {  collector       : URLOBJECT nettimeout sslversion certmd5 {
443                      addcollector($1, $<number>2, $<number>3, $<string>4);                      check_hostname(($<url>1)->hostname);
444                        addcollector($<url>1, $<number>2, $<number>3, $<string>4);
445                    }                    }
446                  ;                  ;
447    
# Line 658  connection      : IF FAILED host port ty Line 674  connection      : IF FAILED host port ty
674                     addeventaction(&(portset).action, $<number>9, $<number>10);                     addeventaction(&(portset).action, $<number>9, $<number>10);
675                     addport(&portset);                     addport(&portset);
676                    }                    }
677                    | IF FAILED URL URLOBJECT urloption nettimeout THEN action1
678                      recovery {
679                       prepare_urlrequest($<url>4);
680                       portset.timeout= $<number>6;
681                       addeventaction(&(portset).action, $<number>8, $<number>9);
682                       addport(&portset);
683                      }
684                  ;                  ;
685    
686  connectionunix  : IF FAILED unixsocket type protocol nettimeout THEN action1  connectionunix  : IF FAILED unixsocket type protocol nettimeout THEN action1
# Line 751  sendexpect      : SEND STRING { addgener Line 774  sendexpect      : SEND STRING { addgener
774                  ;                  ;
775    
776  request         : /* EMPTY */  request         : /* EMPTY */
777                  | REQUEST PATH  {                  | REQUEST PATH {
778                          portset.request= Util_urlEncode($2);                          portset.request= Util_urlEncode($2);
779                          FREE($2);                          FREE($2);
780                    }                    }
# Line 833  timeout         : TIMEOUT NUMBER NUMBER Line 856  timeout         : TIMEOUT NUMBER NUMBER
856                   }                   }
857                  ;                  ;
858    
859    urloption       : /* EMPTY */
860                    | CONTENT urloperator STRING {
861                       seturlrequest($<number>2, $<string>3);
862                       FREE($3);
863                     }
864                    ;
865    
866    urloperator     : EQUAL    { $<number>$= OPERATOR_EQUAL; }
867                    | NOTEQUAL { $<number>$= OPERATOR_NOTEQUAL; }
868                    ;
869    
870  alert           : alertmail '{' eventoptionlist '}' formatlist {  alert           : alertmail '{' eventoptionlist '}' formatlist {
871                     addmail($<string>1, &mailset, &current->maillist, eventset);                     addmail($<string>1, &mailset, &current->maillist, eventset);
# Line 1566  static void addport(Port_T port) { Line 1599  static void addport(Port_T port) {
1599    p->protocol= port->protocol;    p->protocol= port->protocol;
1600    p->pathname= port->pathname;    p->pathname= port->pathname;
1601    p->hostname= port->hostname;    p->hostname= port->hostname;
1602      p->url_request= port->url_request;
1603    p->request_checksum= port->request_checksum;    p->request_checksum= port->request_checksum;
1604    p->ApacheStatus.loglimit= port->ApacheStatus.loglimit;    p->ApacheStatus.loglimit= port->ApacheStatus.loglimit;
1605    p->ApacheStatus.closelimit= port->ApacheStatus.closelimit;    p->ApacheStatus.closelimit= port->ApacheStatus.closelimit;
# Line 2029  static void addargument(char *argument) Line 2063  static void addargument(char *argument)
2063    
2064    
2065  /*  /*
2066   * Add a new data recipient server to the collector server list   * Setup a url request for the current port object
2067   */   */
2068  static void addcollector(char *url, int timeout, int sslversion, char *certmd5) {  static void prepare_urlrequest(URL_T U) {
2069    
2070    Url_T       u;    ASSERT(U);
   Collector_T c;  
2071        
2072    ASSERT(url);    if(!Util_startsWith(U->protocol, "http")) {
2073        yyerror2("Invalid URL protocol [%s]."
2074                 " Only http(s) is supported", U->protocol);
2075      } else {
2076        /* FIXME, change if we should allow other than the
2077           http protocol in an URL */
2078        portset.protocol= addprotocol(P_HTTP);
2079      }
2080      if(urlrequest==NULL)
2081        NEW(urlrequest);
2082      urlrequest->url= U;
2083      urlrequest->url->url= Util_getString("%s://%s:%d%s%s",
2084                                           U->protocol, U->hostname, U->port,
2085                                           U->path, U->query);
2086      portset.hostname= U->hostname;
2087      check_hostname(portset.hostname);
2088      portset.port= U->port;
2089      portset.url_request= urlrequest;
2090      
2091    }
2092    
2093    u = Util_parseURL(url);  
2094    if(u == NULL) {  /*
2095      yyerror2("invalid collector url");   * Set the url request for a port
2096      return;   */
2097    static void  seturlrequest(int operator, char *regex) {
2098      
2099      ASSERT(regex);
2100    
2101      if(! urlrequest)
2102        NEW(urlrequest);
2103      urlrequest->operator= operator;
2104    #ifdef HAVE_REGEX_H
2105      {    
2106        int reg_return;
2107        NEW(urlrequest->regex);
2108        reg_return= regcomp(urlrequest->regex, regex, REG_NOSUB|REG_EXTENDED);
2109        if (reg_return!=0) {
2110          char errbuf[STRLEN];
2111          regerror(reg_return, urlrequest->regex, errbuf, STRLEN);
2112          yyerror2("regex parsing error: %s", errbuf);
2113        }
2114    }    }
2115    #else
2116      urlrequest->regex= xstrdup(regex);
2117    #endif
2118    
2119    check_hostname(u->hostname);  }
2120    
2121    
2122    /*
2123     * Add a new data recipient server to the collector server list
2124     */
2125    static void addcollector(URL_T url, int timeout, int sslversion,
2126                             char *certmd5) {
2127    
2128      Collector_T c;
2129      
2130      ASSERT(url);
2131    
2132    NEW(c);    NEW(c);
2133    c->url = u;    c->url = url;
2134    if(!strcmp(c->url->protocol, "https")) {    if(!strcmp(c->url->protocol, "https")) {
2135      if(!have_ssl()) {      if(!have_ssl()) {
2136        yyerror("ssl check cannot be activated. SSL is not supported");        yyerror("ssl check cannot be activated. SSL is not supported");
# Line 2066  static void addcollector(char *url, int Line 2149  static void addcollector(char *url, int
2149    if(Run.collectors) {    if(Run.collectors) {
2150      Collector_T C;      Collector_T C;
2151      for(C = Run.collectors; C->next; C = C->next)      for(C = Run.collectors; C->next; C = C->next)
2152        ; /* Empty */        /* Empty */ ;
2153      C->next = c;      C->next = c;
2154    }    }
2155    else {    else {
# Line 2482  static void reset_portset() { Line 2565  static void reset_portset() {
2565    portset.family= AF_INET;    portset.family= AF_INET;
2566    portset.SSL.version= SSL_VERSION_AUTO;    portset.SSL.version= SSL_VERSION_AUTO;
2567    portset.timeout= NET_TIMEOUT;    portset.timeout= NET_TIMEOUT;
2568      /* Clear implicit embedded http_request */
2569      urlrequest= NULL;
2570  }  }
2571    
2572    

Legend:
Removed from v.1.189  
changed lines
  Added in v.1.190

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