74 |
#define OPERATOR_EQUAL 2 |
#define OPERATOR_EQUAL 2 |
75 |
#define OPERATOR_NOTEQUAL 3 |
#define OPERATOR_NOTEQUAL 3 |
76 |
|
|
77 |
#define TIME_SECOND 1 |
#define TIME_SECOND 1 |
78 |
#define TIME_MINUTE 60 |
#define TIME_MINUTE 60 |
79 |
#define TIME_HOUR 3600 |
#define TIME_HOUR 3600 |
80 |
#define TIME_DAY 86400 |
#define TIME_DAY 86400 |
81 |
|
|
82 |
#define ACTION_ALERT 1 |
#define ACTION_ALERT 1 |
83 |
#define ACTION_RESTART 2 |
#define ACTION_RESTART 2 |
130 |
#undef MAX |
#undef MAX |
131 |
#endif |
#endif |
132 |
#define MAX(x,y) ((x) > (y) ? (x) : (y)) |
#define MAX(x,y) ((x) > (y) ? (x) : (y)) |
133 |
#define IS(a,b) ((a&&b)?!strcasecmp(a, b):0) |
#define IS(a,b) ((a&&b)?!strcasecmp(a, b):0) |
134 |
#define DEBUG if(Run.debug) log |
#define DEBUG if(Run.debug) log |
135 |
|
|
136 |
|
|
161 |
/** Defines data for application runtime */ |
/** Defines data for application runtime */ |
162 |
struct myrun { |
struct myrun { |
163 |
int stopped; /**< TRUE if the main program was stopped. Flag |
int stopped; /**< TRUE if the main program was stopped. Flag |
164 |
used by threads */ |
used by threads */ |
165 |
char *controlfile; /**< The file to read configuration from */ |
char *controlfile; /**< The file to read configuration from */ |
166 |
char *logfile; /**< The file to write logdata into */ |
char *logfile; /**< The file to write logdata into */ |
167 |
char *localhostname; /**< The host name for localhost */ |
char *localhostname; /**< The host name for localhost */ |
183 |
int servicessl; /**< TRUE if monit has ssl service checks */ |
int servicessl; /**< TRUE if monit has ssl service checks */ |
184 |
int allowselfcert; /**< TRUE if self certified client certs are allowed */ |
int allowselfcert; /**< TRUE if self certified client certs are allowed */ |
185 |
int httpdport; /**< The monit http server's portnumber */ |
int httpdport; /**< The monit http server's portnumber */ |
186 |
int validate; /**< TRUE - use validate behaviour on startup */ |
int validate; /**< TRUE - use validate behaviour on startup */ |
187 |
int init; /**< TRUE - don't background to run from init */ |
int init; /**< TRUE - don't background to run from init */ |
188 |
int facility; /** The facility to use when running openlog() */ |
int facility; /** The facility to use when running openlog() */ |
189 |
int doprocess; /**< TRUE if process status engine is used */ |
int doprocess; /**< TRUE if process status engine is used */ |
190 |
char *bind_addr; /**< The address monit http will bind to */ |
char *bind_addr; /**< The address monit http will bind to */ |
218 |
}; |
}; |
219 |
|
|
220 |
|
|
221 |
|
/** |
222 |
|
* Defines a Command with ARGMAX optional arguments. The arguments |
223 |
|
* array must be NULL terminated and the first entry is the program |
224 |
|
* itself. In addition, a user and group may be set for the Command |
225 |
|
* which means that the Command should run as a certain user and with |
226 |
|
* certain group. |
227 |
|
*/ |
228 |
|
typedef struct mycommand { |
229 |
|
char *arg[ARGMAX]; /**< Program with arguments */ |
230 |
|
int length; /**< The length of the arguments array */ |
231 |
|
int has_uid; /**< TRUE if a new uid is defined for this Command */ |
232 |
|
uid_t uid; /**< The user id to switch to when running this Command */ |
233 |
|
int has_gid; /**< TRUE if a new gid is defined for this Command */ |
234 |
|
gid_t gid; /**< The group id to switch to when running this Command */ |
235 |
|
} *Command_T; |
236 |
|
|
237 |
|
|
238 |
/** Defines a port object */ |
/** Defines a port object */ |
239 |
typedef struct myport { |
typedef struct myport { |
240 |
volatile int socket; /**< Socket used for connection */ |
volatile int socket; /**< Socket used for connection */ |
302 |
int cycle; /**< Cycle overrun counter */ |
int cycle; /**< Cycle overrun counter */ |
303 |
int max_cycle; /**< Cycle overrun limit */ |
int max_cycle; /**< Cycle overrun limit */ |
304 |
int action; /**< Action in case of failure */ |
int action; /**< Action in case of failure */ |
305 |
|
int event_flag; /**< TRUE if an event occured on this object */ |
306 |
|
Command_T exec; /**< Optional command to be executed upon a resurce event*/ |
307 |
|
|
308 |
/** For internal use */ |
/** For internal use */ |
309 |
struct myresource *next; /**< next resource in chain */ |
struct myresource *next; /**< next resource in chain */ |
312 |
|
|
313 |
/** Defines timestamp object */ |
/** Defines timestamp object */ |
314 |
typedef struct mytimestamp { |
typedef struct mytimestamp { |
315 |
char *pathname; /**< Path to the object */ |
char *pathname; /**< Path to the object */ |
316 |
int operator; /**< Comparison operator */ |
int operator; /**< Comparison operator */ |
317 |
int time; /**< Timestamp watermark */ |
int time; /**< Timestamp watermark */ |
318 |
int action; /**< Action in case of failure */ |
int action; /**< Action in case of failure */ |
319 |
|
int test_changes; /**< TRUE if we only should test for changes */ |
320 |
|
time_t timestamp; /**< The original last modified timestamp for this object*/ |
321 |
|
int event_flag; /**< TRUE if an event occured on this object */ |
322 |
|
Command_T exec; /**< Optional command to be executed upon a timestamp event*/ |
323 |
|
|
324 |
/** For internal use */ |
/** For internal use */ |
325 |
struct mytimestamp *next; /**< next timestamp in chain */ |
struct mytimestamp *next; /**< next timestamp in chain */ |
326 |
} *Timestamp_T; |
} *Timestamp_T; |
345 |
} *ProcInfo_T; |
} *ProcInfo_T; |
346 |
|
|
347 |
|
|
|
/** |
|
|
* Defines a Command with ARGMAX optional arguments. The arguments |
|
|
* array must be NULL terminated and the first entry is the program |
|
|
* itself. In addition, a user and group may be set for the Command |
|
|
* which means that the Command should run as a certain user and with |
|
|
* certain group. Finally, a Command_T object may contain a set of |
|
|
* environment variables to be set before the Command is started. |
|
|
*/ |
|
|
typedef struct mycommand { |
|
|
char *arg[ARGMAX]; /**< Program with arguments */ |
|
|
int length; /**< The length of the arguments array */ |
|
|
int has_uid; /**< TRUE if a new uid is defined for this Command */ |
|
|
uid_t uid; /**< The user id to switch to when running this Command */ |
|
|
int has_gid; /**< TRUE if a new gid is defined for this Command */ |
|
|
gid_t gid; /**< The group id to switch to when running this Command */ |
|
|
unsigned int events; /**< Events triggering this program to be executed */ |
|
|
|
|
|
/** For internal use */ |
|
|
struct mycommand *next; /**< next external program in chain */ |
|
|
} *Command_T; |
|
|
|
|
|
|
|
348 |
/** Defines filesystem device data */ |
/** Defines filesystem device data */ |
349 |
typedef struct mydeviceinfo { |
typedef struct mydeviceinfo { |
350 |
long f_bsize; /**< Transfer block size */ |
long f_bsize; /**< Transfer block size */ |
400 |
int uid; /**< Owner's uid */ |
int uid; /**< Owner's uid */ |
401 |
int gid; /**< Owner's gid */ |
int gid; /**< Owner's gid */ |
402 |
|
|
|
Port_T portlist; /**< Portnumbers the service listens on */ |
|
|
Checksum_T checksumlist; /**< A list of file associated checksums */ |
|
403 |
Mail_T maillist; /**< Alert notification mailinglist */ |
Mail_T maillist; /**< Alert notification mailinglist */ |
404 |
|
Port_T portlist; /**< Portnumbers the service listens on */ |
405 |
|
Device_T devicelist; /**< Device check list */ |
406 |
Resource_T resourcelist; /**< Resouce check list */ |
Resource_T resourcelist; /**< Resouce check list */ |
407 |
|
Checksum_T checksumlist; /**< A list of file associated checksums */ |
408 |
Dependant_T dependantlist; /**<Dependant service list */ |
Dependant_T dependantlist; /**<Dependant service list */ |
409 |
Timestamp_T timestamplist; /**< Timestamp check list */ |
Timestamp_T timestamplist; /**< Timestamp check list */ |
|
Device_T devicelist; /**< Device check list */ |
|
|
Command_T execlist; /**< External programs to call upon an action */ |
|
410 |
|
|
411 |
/** Runtime parameters */ |
/** Runtime parameters */ |
|
DeviceInfo_T devinfo; /**< Data for the device check */ |
|
412 |
ProcInfo_T procinfo; /**< Data for the procfs check */ |
ProcInfo_T procinfo; /**< Data for the procfs check */ |
413 |
|
DeviceInfo_T devinfo; /**< Data for the device check */ |
414 |
|
|
415 |
/** Context specific parameters */ |
/** Context specific parameters */ |
416 |
char *path; /**< Path to the device, file, directory or process pid file */ |
char *path; /**< Path to the device, file, directory or process pid file */ |
425 |
|
|
426 |
/** Defines process tree */ |
/** Defines process tree */ |
427 |
typedef struct myprocesstree { |
typedef struct myprocesstree { |
428 |
int pid; |
int pid; |
429 |
int ppid; |
int ppid; |
430 |
long mem_kbyte; |
long mem_kbyte; |
431 |
int children_num; |
int children_num; |
432 |
long mem_kbyte_sum; |
int children_sum; |
433 |
int children_sum; |
long mem_kbyte_sum; |
434 |
|
|
435 |
/** For internal use */ |
/** For internal use */ |
|
struct myprocesstree ** children; |
|
436 |
struct myprocesstree * parent; |
struct myprocesstree * parent; |
437 |
|
struct myprocesstree ** children; |
438 |
} ProcessTree_T; |
} ProcessTree_T; |
439 |
|
|
440 |
|
|