71 |
static void do_runtime(HttpRequest, HttpResponse); |
static void do_runtime(HttpRequest, HttpResponse); |
72 |
static void do_viewlog(HttpRequest, HttpResponse); |
static void do_viewlog(HttpRequest, HttpResponse); |
73 |
static void handle_action(HttpRequest, HttpResponse); |
static void handle_action(HttpRequest, HttpResponse); |
74 |
|
static void print_status(Process_T, HttpResponse res); |
75 |
static void is_monit_running(HttpRequest, HttpResponse); |
static void is_monit_running(HttpRequest, HttpResponse); |
76 |
static void do_process(HttpRequest, HttpResponse, char *); |
static void do_process(HttpRequest, HttpResponse, char *); |
77 |
|
|
232 |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
233 |
"<tr><td><h3><b>Server</b></h3></td>" |
"<tr><td><h3><b>Server</b></h3></td>" |
234 |
"<td align=\"right\"><h3><b>Status</b></h3></td>" |
"<td align=\"right\"><h3><b>Status</b></h3></td>" |
235 |
"<td align=\"center\"><h3><b>Uptime</b></h3></td>" |
"<td align=\"right\"><h3><b>Uptime</b></h3></td>" |
236 |
"<td align=\"center\"><h3><b>CPU</b></h3></td>" |
"<td align=\"right\"><h3><b>CPU</b></h3></td>" |
237 |
"<td align=\"center\"><h3><b>Memory</b></h3></td>" |
"<td align=\"right\"><h3><b>Memory</b></h3></td>" |
238 |
"</tr>" |
"</tr>" |
239 |
"<tr><td> </td><td> </td></tr>", Run.localhostname, uptime); |
"<tr><td> </td><td> </td></tr>", Run.localhostname, uptime); |
240 |
} else { |
} else { |
319 |
} |
} |
320 |
out_print(res, "</table>"); |
out_print(res, "</table>"); |
321 |
FOOT |
FOOT |
|
|
|
322 |
|
|
323 |
} |
} |
324 |
|
|
500 |
char *name= req->url; |
char *name= req->url; |
501 |
char *action= get_parameter(req, "action"); |
char *action= get_parameter(req, "action"); |
502 |
|
|
503 |
if ( exist_process(++name) ) { |
if(exist_process(++name)) { |
504 |
|
|
505 |
if ( action ) { |
if(action) { |
506 |
|
|
507 |
struct myprocess *p= get_process(name); |
struct myprocess *p= get_process(name); |
508 |
|
|
509 |
if ( strstr(action, "start") ) { |
if(is(action, "start")) { |
510 |
|
|
511 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
512 |
p->do_validate= TRUE; |
p->do_validate= TRUE; |
515 |
|
|
516 |
} |
} |
517 |
|
|
518 |
if ( strstr(action, "stop") ) { |
if(is(action, "stop")) { |
519 |
|
|
520 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
521 |
p->do_validate= FALSE; |
p->do_validate= FALSE; |
524 |
|
|
525 |
} |
} |
526 |
|
|
527 |
if ( strstr(action, "status") ) { |
if(is(action, "status")) { |
|
|
|
|
FILE *out= res->outputstream; |
|
|
pid_t pid= -1; |
|
|
|
|
|
res->is_committed= TRUE; |
|
|
|
|
|
|
|
|
if ( (pid= is_process_running(p)) ) { |
|
528 |
|
|
529 |
char *uptime= get_process_uptime(p->pidfile); |
print_status(p, res); |
530 |
ProcInfo_T pi= p->procinfo; |
goto quit; |
531 |
|
|
|
fprintf(out, |
|
|
"Process '%s' is running with pid [%d] Uptime: %s " |
|
|
"CPU: %.1f%% Memory: %.1f%% [%ldkB]\n", |
|
|
p->name, (int)pid, uptime, |
|
|
pi->cpu_percent/10.0, |
|
|
pi->mem_percent/10.0,pi->mem_kbyte); |
|
|
|
|
|
free(uptime); |
|
|
|
|
|
} else { |
|
|
|
|
|
fprintf(out, "Process '%s' is not running\n", p->name); |
|
|
|
|
|
} |
|
|
|
|
|
fputc(0,out); |
|
|
free(action); |
|
|
|
|
|
return; |
|
532 |
} |
} |
533 |
|
|
534 |
sleep(2); |
sleep(2); |
545 |
|
|
546 |
} |
} |
547 |
|
|
548 |
|
quit: |
549 |
free(action); |
free(action); |
550 |
|
|
551 |
} |
} |
740 |
|
|
741 |
} |
} |
742 |
|
|
743 |
|
|
744 |
|
static void print_status(Process_T p, HttpResponse res) { |
745 |
|
|
746 |
|
FILE *out= res->outputstream; |
747 |
|
pid_t pid= -1; |
748 |
|
|
749 |
|
res->is_committed= TRUE; |
750 |
|
|
751 |
|
if((pid= is_process_running(p))) { |
752 |
|
|
753 |
|
char *uptime= get_process_uptime(p->pidfile); |
754 |
|
ProcInfo_T pi= p->procinfo; |
755 |
|
|
756 |
|
fprintf(out, |
757 |
|
"Process '%s' is running with pid [%d] \n\tUptime: %s " |
758 |
|
"CPU: %.1f%% Memory: %.1f%% [%ldkB]\n", |
759 |
|
p->name, (int)pid, uptime, |
760 |
|
pi->cpu_percent/10.0, |
761 |
|
pi->mem_percent/10.0,pi->mem_kbyte); |
762 |
|
|
763 |
|
free(uptime); |
764 |
|
|
765 |
|
} else { |
766 |
|
|
767 |
|
fprintf(out, "Process '%s' is not running\n", p->name); |
768 |
|
|
769 |
|
} |
770 |
|
|
771 |
|
} |
772 |
|
|
773 |
|
|
774 |
static void printPixel(HttpResponse res) { |
static void printPixel(HttpResponse res) { |
775 |
|
|