80 |
/* -------------------------------------------------------------- Prototypes */ |
/* -------------------------------------------------------------- Prototypes */ |
81 |
|
|
82 |
|
|
|
static void set_monit_environment(Service_T s); |
|
83 |
static void exec_alert_mail(Service_T s, Command_T c); |
static void exec_alert_mail(Service_T s, Command_T c); |
84 |
|
static void set_monit_environment(Service_T s, const char *event); |
85 |
|
|
86 |
|
|
87 |
/* ------------------------------------------------------------------ Public */ |
/* ------------------------------------------------------------------ Public */ |
93 |
* registred interest for restart alerts. |
* registred interest for restart alerts. |
94 |
* @param P A Service object |
* @param P A Service object |
95 |
* @param C A Command object |
* @param C A Command object |
96 |
|
* @param E An optional event string, specifying why this function was |
97 |
|
* called. May be NULL. |
98 |
*/ |
*/ |
99 |
void spawn(Service_T S, Command_T C) { |
void spawn(Service_T S, Command_T C, const char *E) { |
100 |
|
|
101 |
pid_t pid; |
pid_t pid; |
102 |
sigset_t mask, save; |
sigset_t mask, save; |
161 |
} |
} |
162 |
} |
} |
163 |
|
|
164 |
set_monit_environment(S); |
set_monit_environment(S, E); |
165 |
|
|
166 |
if(! Run.isdaemon) { |
if(! Run.isdaemon) { |
167 |
redirect_stdfd(); |
redirect_stdfd(); |
240 |
* Setup the environment with special MONIT_xxx variables. The program |
* Setup the environment with special MONIT_xxx variables. The program |
241 |
* executed may use such variable for various purposes. |
* executed may use such variable for various purposes. |
242 |
*/ |
*/ |
243 |
static void set_monit_environment(Service_T s) { |
static void set_monit_environment(Service_T s, const char *event) { |
244 |
|
|
245 |
int i, j; |
int i, j; |
246 |
char buf[10][STRLEN]; |
char buf[10][STRLEN]; |
247 |
char *date= get_RFC822date(NULL); |
char *date= get_RFC822date(NULL); |
248 |
|
|
249 |
i= 0; |
i= 0; |
250 |
|
|
251 |
snprintf(buf[i++], STRLEN, "MONIT_DATE=%s", date); |
snprintf(buf[i++], STRLEN, "MONIT_DATE=%s", date); |
252 |
snprintf(buf[i++], STRLEN, "MONIT_SERVICE=%s", s->name); |
snprintf(buf[i++], STRLEN, "MONIT_SERVICE=%s", s->name); |
253 |
snprintf(buf[i++], STRLEN, "MONIT_HOST=%s", Run.localhostname); |
snprintf(buf[i++], STRLEN, "MONIT_HOST=%s", Run.localhostname); |
254 |
|
snprintf(buf[i++], STRLEN, "MONIT_EVENT=%s", event?event:"No Event"); |
255 |
|
|
256 |
if(s->type == TYPE_PROCESS) { |
if(s->type == TYPE_PROCESS) { |
257 |
snprintf(buf[i++], STRLEN, "MONIT_PROCESS_PID=%d", is_process_running(s)); |
snprintf(buf[i++], STRLEN, "MONIT_PROCESS_PID=%d", is_process_running(s)); |