210 |
struct myprocess *p; |
struct myprocess *p; |
211 |
char *uptime= get_process_uptime(Run.pidfile); |
char *uptime= get_process_uptime(Run.pidfile); |
212 |
|
|
213 |
|
if ( Run.doprocess ) { |
214 |
|
HEAD("", Run.polltime) |
215 |
|
out_print(res, |
216 |
|
"<table cellspacing=\"0\" cellpadding=\"5\" width=\"100%%\" border=\"0\">" |
217 |
|
" <tr bgcolor=\"#BBDDFF\">" |
218 |
|
" <td colspan=2 valign=\"top\" align=\"left\" bgcolor=\"#EFF7FF\" width=\"100%%\">" |
219 |
|
" <br><h2 align=\"center\">Monit Process Manager</h2>" |
220 |
|
" <p align=\"center\">Monit is <a href='/_runtime'>running</a> on %s " |
221 |
|
" with <i>uptime, %s</i> and monitoring:</p><br>" |
222 |
|
" </td>" |
223 |
|
" </tr>" |
224 |
|
"</table>" |
225 |
|
"<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\" border=\"0\">" |
226 |
|
" <tr valign=\"middle\" bgcolor=\"#6F6F6F\">" |
227 |
|
" <td><img src=\"/_pixel\" width=\"1\" height=\"1\" alt=\"\"></td>" |
228 |
|
" </tr>" |
229 |
|
"</table>" |
230 |
|
"<br><p> </p>" |
231 |
|
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
232 |
|
"<tr><td><h3><b>Server</b></h3></td>" |
233 |
|
"<td align=\"right\"><h3><b>Status</b></h3></td>" |
234 |
|
"<td align=\"center\"><h3><b>Uptime</b></h3></td>" |
235 |
|
"<td align=\"center\"><h3><b>CPU</b></h3></td>" |
236 |
|
"<td align=\"center\"><h3><b>Memory</b></h3></td>" |
237 |
|
"</tr>" |
238 |
|
"<tr><td> </td><td> </td></tr>", Run.localhostname, uptime); |
239 |
|
} else { |
240 |
HEAD("", Run.polltime) |
HEAD("", Run.polltime) |
241 |
out_print(res, |
out_print(res, |
242 |
"<table cellspacing=\"0\" cellpadding=\"5\" width=\"100%%\" border=\"0\">" |
"<table cellspacing=\"0\" cellpadding=\"5\" width=\"100%%\" border=\"0\">" |
258 |
"<tr><td><h3><b>Server</b></h3></td>" |
"<tr><td><h3><b>Server</b></h3></td>" |
259 |
"<td align=\"right\"><h3><b>Status</b></h3></td></tr>" |
"<td align=\"right\"><h3><b>Status</b></h3></td></tr>" |
260 |
"<tr><td> </td><td> </td></tr>", Run.localhostname, uptime); |
"<tr><td> </td><td> </td></tr>", Run.localhostname, uptime); |
261 |
|
} |
262 |
|
|
263 |
free(uptime); |
free(uptime); |
264 |
|
|
267 |
int isrunning= is_process_running(p); |
int isrunning= is_process_running(p); |
268 |
char *uptime= get_process_uptime(p->pidfile); |
char *uptime= get_process_uptime(p->pidfile); |
269 |
|
|
270 |
out_print(res,"<tr %s><td><a href='/%s'>%s</a></td><td align=\"right\">" |
if ( Run.doprocess ) { |
271 |
"%s %s</td></tr>", |
ProcInfo_T pi= p->procinfo; |
272 |
on?"bgcolor=\"#EFEFEF\"":"", |
if ( isrunning ) { |
273 |
p->name, p->name, |
out_print(res,"<tr %s><td><a href='/%s'>%s</a></td><td align=\"right\">" |
274 |
p->has_checksum_error? |
"%s</td><td align=\"right\">%s</td>" |
275 |
"<font color='#ff0000'>Cheksum Error</font>": |
"<td align=\"right\">%.1f%%</td>" |
276 |
isrunning? |
"<td align=\"right\">%.1f%% [%ldkB]</td></tr>", |
277 |
"<font color=green>running</font>": |
on?"bgcolor=\"#EFEFEF\"":"", |
278 |
"<font color=red>not running</font>", |
p->name, p->name, |
279 |
isrunning?uptime:""); |
p->has_checksum_error? |
280 |
|
"<font color='#ff0000'>Cheksum Error</font>": |
281 |
|
isrunning? |
282 |
|
"<font color=green>running</font>": |
283 |
|
"<font color=red>not running</font>", |
284 |
|
uptime, |
285 |
|
pi->cpu_percent/10.0, |
286 |
|
pi->mem_percent/10.0,pi->mem_kbyte |
287 |
|
); |
288 |
|
} else { |
289 |
|
out_print(res,"<tr %s><td><a href='/%s'>%s</a></td>" |
290 |
|
"<td align=\"right\">%s</td>" |
291 |
|
"<td align=\"right\">-</td>" |
292 |
|
"<td align=\"right\">- </td>" |
293 |
|
"<td align=\"right\">- [-]</td></tr>", |
294 |
|
on?"bgcolor=\"#EFEFEF\"":"", |
295 |
|
p->name, p->name, |
296 |
|
p->has_checksum_error? |
297 |
|
"<font color='#ff0000'>Cheksum Error</font>": |
298 |
|
"<font color=red>not running</font>" |
299 |
|
); |
300 |
|
} |
301 |
|
} else { |
302 |
|
out_print(res,"<tr %s><td><a href='/%s'>%s</a></td><td align=\"right\">" |
303 |
|
"%s %s</td></tr>", |
304 |
|
on?"bgcolor=\"#EFEFEF\"":"", |
305 |
|
p->name, p->name, |
306 |
|
p->has_checksum_error? |
307 |
|
"<font color='#ff0000'>Cheksum Error</font>": |
308 |
|
isrunning? |
309 |
|
"<font color=green>running</font>": |
310 |
|
"<font color=red>not running</font>", |
311 |
|
isrunning?uptime:""); |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
on= on?FALSE:TRUE; |
on= on?FALSE:TRUE; |
316 |
free(uptime); |
free(uptime); |
317 |
|
|
523 |
stop_process(p); |
stop_process(p); |
524 |
|
|
525 |
} |
} |
526 |
|
|
527 |
|
if ( strstr(action, "status") ) { |
528 |
|
|
529 |
|
FILE *out= res->outputstream; |
530 |
|
pid_t pid= -1; |
531 |
|
|
532 |
|
res->is_committed= TRUE; |
533 |
|
|
534 |
|
|
535 |
|
if ( (pid= is_process_running(p)) ) { |
536 |
|
|
537 |
|
char *uptime= get_process_uptime(p->pidfile); |
538 |
|
ProcInfo_T pi= p->procinfo; |
539 |
|
|
540 |
|
fprintf(out, |
541 |
|
"Process '%s' is running with pid [%d] Uptime: %s " |
542 |
|
"CPU: %.1f%% Memory: %.1f%% [%ldkB]\n", |
543 |
|
p->name, (int)pid, uptime, |
544 |
|
pi->cpu_percent/10.0, |
545 |
|
pi->mem_percent/10.0,pi->mem_kbyte); |
546 |
|
|
547 |
|
free(uptime); |
548 |
|
|
549 |
|
} else { |
550 |
|
|
551 |
|
fprintf(out, "Process '%s' is not running\n", p->name); |
552 |
|
|
553 |
|
} |
554 |
|
|
555 |
|
fputc(0,out); |
556 |
|
free(action); |
557 |
|
|
558 |
|
return; |
559 |
|
} |
560 |
|
|
561 |
sleep(2); |
sleep(2); |
562 |
|
|