139 |
|
|
140 |
set_content_type(res, "text/html"); |
set_content_type(res, "text/html"); |
141 |
|
|
142 |
if ( ACTION(HOME) ) { |
if(ACTION(HOME)) { |
|
|
|
143 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
144 |
do_home(req, res); |
do_home(req, res); |
145 |
END_LOCK; |
END_LOCK; |
146 |
|
} else if(ACTION(RUN)) { |
|
} |
|
|
else if ( ACTION(RUN) ) { |
|
|
|
|
147 |
LOCK(Run.mutex) |
LOCK(Run.mutex) |
148 |
do_runtime(req, res); |
do_runtime(req, res); |
149 |
END_LOCK; |
END_LOCK; |
150 |
|
} else if(ACTION(TEST)) { |
|
} |
|
|
else if ( ACTION(TEST) ) { |
|
|
|
|
151 |
is_monit_running(req, res); |
is_monit_running(req, res); |
152 |
|
} else if(ACTION(VIEWLOG)) { |
|
} |
|
|
else if ( ACTION(VIEWLOG) ) { |
|
|
|
|
153 |
do_viewlog(req, res); |
do_viewlog(req, res); |
154 |
|
} else if(ACTION(ABOUT)) { |
|
} |
|
|
else if ( ACTION(ABOUT) ) { |
|
|
|
|
155 |
do_about(req, res); |
do_about(req, res); |
156 |
|
} else if(ACTION(STOP)) { |
|
} |
|
|
else if ( ACTION(STOP) ) { |
|
|
|
|
157 |
send_error(res, SC_SERVICE_UNAVAILABLE, "The monit http server is stopped"); |
send_error(res, SC_SERVICE_UNAVAILABLE, "The monit http server is stopped"); |
158 |
stop_httpd(); |
stop_httpd(); |
159 |
|
} else if(ACTION(PIXEL)) { |
|
} |
|
|
else if ( ACTION(PIXEL) ) { |
|
|
|
|
160 |
printPixel(res); |
printPixel(res); |
|
|
|
161 |
} else { |
} else { |
|
|
|
162 |
handle_action(req, res); |
handle_action(req, res); |
|
|
|
163 |
} |
} |
|
|
|
164 |
|
|
165 |
} |
} |
166 |
|
|
173 |
int status; |
int status; |
174 |
int monit= exist_daemon(); |
int monit= exist_daemon(); |
175 |
|
|
176 |
if ( monit ) { |
if(monit) { |
|
|
|
177 |
status= SC_OK; |
status= SC_OK; |
|
|
|
178 |
} else { |
} else { |
|
|
|
179 |
status= SC_GONE; |
status= SC_GONE; |
|
|
|
180 |
} |
} |
181 |
|
|
182 |
set_status(res, status); |
set_status(res, status); |
206 |
"</table>", Run.localhostname, uptime); |
"</table>", Run.localhostname, uptime); |
207 |
|
|
208 |
free(uptime); |
free(uptime); |
209 |
|
|
210 |
do_home_process(req, res); |
do_home_process(req, res); |
211 |
do_home_device(req, res); |
do_home_device(req, res); |
212 |
do_home_file(req, res); |
do_home_file(req, res); |
342 |
"<td align=right><form method=GET action=%s>" |
"<td align=right><form method=GET action=%s>" |
343 |
"<input type=submit value=Go style='font-size: 12pt'></font>" |
"<input type=submit value=Go style='font-size: 12pt'></font>" |
344 |
"</form></td>", STOP); |
"</form></td>", STOP); |
345 |
if ( Run.dolog && !Run.use_syslog ) { |
if(Run.dolog && !Run.use_syslog) { |
346 |
out_print(res, "<td><font size=+1>" |
out_print(res, "<td><font size=+1>" |
347 |
"View monit logfile?</font>" |
"View monit logfile?</font>" |
348 |
"<td align=right><form method=GET action=%s>" |
"<td align=right><form method=GET action=%s>" |
360 |
|
|
361 |
HEAD("_viewlog", 100) |
HEAD("_viewlog", 100) |
362 |
|
|
363 |
if ( Run.dolog && !Run.use_syslog ) { |
if(Run.dolog && !Run.use_syslog) { |
364 |
|
|
365 |
struct stat sb; |
struct stat sb; |
366 |
|
|
367 |
if ( !stat(Run.logfile, &sb) ) { |
if(!stat(Run.logfile, &sb)) { |
368 |
|
|
369 |
FILE *f= fopen(Run.logfile, "r"); |
FILE *f= fopen(Run.logfile, "r"); |
370 |
if ( f ) { |
if(f) { |
371 |
|
|
372 |
int n; |
int n; |
373 |
char buf[8192]; |
char buf[8192]; |
374 |
|
|
375 |
out_print(res, "<br><p><form><textarea cols=80 rows=30>"); |
out_print(res, "<br><p><form><textarea cols=80 rows=30>"); |
376 |
|
|
377 |
while ( (n= fread(buf, sizeof(char), 8192, f)) > 0 ) { |
while((n= fread(buf, sizeof(char), 8192, f)) > 0) { |
378 |
|
|
379 |
buf[n]= 0; |
buf[n]= 0; |
380 |
out_print(res, "%s", buf); |
out_print(res, "%s", buf); |
400 |
|
|
401 |
out_print(res, |
out_print(res, |
402 |
"<b>Cannot view logfile:</b><br>"); |
"<b>Cannot view logfile:</b><br>"); |
403 |
if ( !Run.dolog ) { |
if(!Run.dolog) { |
404 |
|
|
405 |
out_print(res, "monit was started without logging"); |
out_print(res, "monit was started without logging"); |
406 |
|
|
428 |
|
|
429 |
Service_T s= get_service(name); |
Service_T s= get_service(name); |
430 |
|
|
431 |
if( IS(action, "start") ) { |
if( IS(action, "start")) { |
432 |
|
|
433 |
if(s->start) { |
if(s->start) { |
434 |
|
|
446 |
|
|
447 |
} |
} |
448 |
|
|
449 |
if( IS(action, "stop") ) { |
if( IS(action, "stop")) { |
450 |
|
|
451 |
if(s->stop) { |
if(s->stop) { |
452 |
|
|
464 |
|
|
465 |
} |
} |
466 |
|
|
467 |
if( IS(action, "restart") ) { |
if( IS(action, "restart")) { |
468 |
|
|
469 |
if(s->start && s->stop) { |
if(s->start && s->stop) { |
470 |
|
|
560 |
char buf[STRLEN]; |
char buf[STRLEN]; |
561 |
ProcInfo_T pi= s->procinfo; |
ProcInfo_T pi= s->procinfo; |
562 |
|
|
563 |
if ( Run.doprocess ) { |
if(Run.doprocess) { |
564 |
|
|
565 |
sprintf(buf, |
sprintf(buf, |
566 |
"Process '%s' is running with pid [%d]\n\tUptime: %s " |
"Process '%s' is running with pid [%d]\n\tUptime: %s " |
581 |
|
|
582 |
} |
} |
583 |
|
|
584 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
585 |
|
|
586 |
printf_ssl_socket(res->ssl, "%s", buf); |
printf_ssl_socket(res->ssl, "%s", buf); |
587 |
|
|
595 |
|
|
596 |
} else { |
} else { |
597 |
|
|
598 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
599 |
|
|
600 |
printf_ssl_socket(res->ssl, "Process '%s' is not running\n", s->name); |
printf_ssl_socket(res->ssl, "Process '%s' is not running\n", s->name); |
601 |
|
|
613 |
|
|
614 |
if(s->devinfo->f_files > 0) { |
if(s->devinfo->f_files > 0) { |
615 |
|
|
616 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
617 |
|
|
618 |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
619 |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
620 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
621 |
s->name, |
s->name, |
622 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
623 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocks, |
624 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / s->devinfo->f_files, |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
625 |
|
1048576 * s->devinfo->f_bsize, |
626 |
|
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
627 |
|
s->devinfo->f_files, |
628 |
s->devinfo->f_files - s->devinfo->f_filesfree, |
s->devinfo->f_files - s->devinfo->f_filesfree, |
629 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
630 |
|
|
634 |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
635 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
636 |
s->name, |
s->name, |
637 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
638 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocks, |
639 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / s->devinfo->f_files, |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
640 |
s->devinfo->f_files - s->devinfo->f_filesfree, |
1048576 * s->devinfo->f_bsize, |
641 |
statusnames[s->do_monitor]); |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
642 |
|
s->devinfo->f_files, |
643 |
|
s->devinfo->f_files - s->devinfo->f_filesfree, |
644 |
|
statusnames[s->do_monitor]); |
645 |
} |
} |
|
|
|
646 |
} else { |
} else { |
647 |
|
if( Run.httpdssl) { |
|
if( Run.httpdssl ) { |
|
|
|
|
648 |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
649 |
"Space: %.1f%% [%.1f MB]\n\t" |
"Space: %.1f%% [%.1f MB]\n\t" |
650 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
651 |
s->name, |
s->name, |
652 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
653 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocks, |
654 |
|
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
655 |
|
1048576 * s->devinfo->f_bsize, |
656 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
|
|
|
657 |
} else { |
} else { |
|
|
|
658 |
fprintf(out, "Device '%s' is accessible\n\t" |
fprintf(out, "Device '%s' is accessible\n\t" |
659 |
"Space: %.1f%% [%.1f MB]\n\t" |
"Space: %.1f%% [%.1f MB]\n\t" |
660 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
661 |
s->name, |
s->name, |
662 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
663 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocks, |
664 |
statusnames[s->do_monitor]); |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
665 |
|
1048576 * s->devinfo->f_bsize, |
666 |
|
statusnames[s->do_monitor]); |
667 |
} |
} |
|
|
|
668 |
} |
} |
|
|
|
669 |
} else { |
} else { |
670 |
|
if( Run.httpdssl) { |
671 |
if( Run.httpdssl ) { |
|
|
|
|
672 |
printf_ssl_socket(res->ssl, "Device '%s' is not accessible\n\t" |
printf_ssl_socket(res->ssl, "Device '%s' is not accessible\n\t" |
673 |
"Space: - Inodes: -\n\t" |
"Space: - Inodes: -\n\t" |
674 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
675 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
676 |
} else { |
} else { |
|
|
|
677 |
fprintf(out, "Device '%s' is not accessible\n\t" |
fprintf(out, "Device '%s' is not accessible\n\t" |
678 |
"Space: - Inodes: -\n\t" |
"Space: - Inodes: -\n\t" |
679 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
680 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
681 |
} |
} |
|
|
|
682 |
} |
} |
|
|
|
683 |
break; |
break; |
684 |
|
|
685 |
case TASK_FILE: |
case TASK_FILE: |
686 |
if( (stat(s->path, &stat_buf) == 0) && S_ISREG(stat_buf.st_mode) ) { |
if( (stat(s->path, &stat_buf) == 0) && S_ISREG(stat_buf.st_mode)) { |
687 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
688 |
|
|
689 |
printf_ssl_socket(res->ssl, |
printf_ssl_socket(res->ssl, |
690 |
"File '%s' exist\n\t" |
"File '%s' exist\n\t" |
708 |
|
|
709 |
} |
} |
710 |
} else { |
} else { |
711 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
712 |
|
printf_ssl_socket(res->ssl, |
713 |
printf_ssl_socket(res->ssl, "File '%s' doesn't exist\n\tMonitoring status: %s\n", |
"File '%s' doesn't exist\n\tMonitoring status: %s\n", |
714 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
715 |
} else { |
} else { |
|
|
|
716 |
fprintf(out, "File '%s' doesn't exist\n\tMonitoring status: %s\n", |
fprintf(out, "File '%s' doesn't exist\n\tMonitoring status: %s\n", |
717 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
718 |
} |
} |
719 |
} |
} |
720 |
break; |
break; |
721 |
|
|
722 |
case TASK_DIRECTORY: |
case TASK_DIRECTORY: |
723 |
if( (stat(s->path, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode) ) { |
if( (stat(s->path, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) { |
724 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
725 |
|
|
726 |
printf_ssl_socket(res->ssl, |
printf_ssl_socket(res->ssl, |
727 |
"Directory '%s' exist\n\t" |
"Directory '%s' exist\n\t" |
728 |
"UID: %d GID: %d Permission: %o\n\t" |
"UID: %d GID: %d Permission: %o\n\t" |
729 |
"Monitoring status: %s\n", |
"Monitoring status: %s\n", |
730 |
s->name, |
s->name, (int)stat_buf.st_uid, |
731 |
(int)stat_buf.st_uid, (int)stat_buf.st_gid, (int)(stat_buf.st_mode & 07777), |
(int)stat_buf.st_gid, (int)(stat_buf.st_mode & 07777), |
732 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
|
|
|
733 |
} else { |
} else { |
734 |
|
fprintf(out, |
735 |
fprintf(out, |
"Directory '%s' exist\n\t" |
736 |
"Directory '%s' exist\n\t" |
"UID: %d GID: %d Permission: %o\n\t" |
737 |
"UID: %d GID: %d Permission: %o\n\t" |
"Monitoring status: %s\n", |
738 |
"Monitoring status: %s\n", |
s->name, (int)stat_buf.st_uid, |
739 |
s->name, |
(int)stat_buf.st_gid, (int)(stat_buf.st_mode & 07777), |
740 |
(int)stat_buf.st_uid, (int)stat_buf.st_gid, (int)(stat_buf.st_mode & 07777), |
statusnames[s->do_monitor]); |
|
statusnames[s->do_monitor]); |
|
|
|
|
741 |
} |
} |
742 |
} else { |
} else { |
743 |
if( Run.httpdssl ) { |
if( Run.httpdssl) { |
744 |
|
printf_ssl_socket(res->ssl, |
745 |
printf_ssl_socket(res->ssl, "Directory '%s' doesn't exist\n\tMonitoring status: %s\n", |
"Directory '%s' doesn't exist\n\tMonitoring status: %s\n", |
746 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
747 |
} else { |
} else { |
748 |
|
fprintf(out, |
749 |
fprintf(out, "Directory '%s' doesn't exist\n\tMonitoring status: %s\n", |
"Directory '%s' doesn't exist\n\tMonitoring status: %s\n", |
750 |
s->name, statusnames[s->do_monitor]); |
s->name, statusnames[s->do_monitor]); |
|
|
|
751 |
} |
} |
752 |
} |
} |
753 |
break; |
break; |
754 |
|
|
755 |
default: |
default: |
756 |
break; |
break; |
|
|
|
757 |
} |
} |
758 |
|
|
759 |
} |
} |
764 |
static int l; |
static int l; |
765 |
static unsigned char *pixel= NULL; |
static unsigned char *pixel= NULL; |
766 |
|
|
767 |
if ( ! pixel ) { |
if(! pixel) { |
|
|
|
768 |
pixel= xcalloc(sizeof(unsigned char), strlen(PIXEL_GIF)); |
pixel= xcalloc(sizeof(unsigned char), strlen(PIXEL_GIF)); |
769 |
l= decode_base64(pixel, PIXEL_GIF); |
l= decode_base64(pixel, PIXEL_GIF); |
|
|
|
770 |
} |
} |
771 |
if (l) { |
if (l) { |
772 |
|
if(Run.httpdssl) { |
|
if ( Run.httpdssl ) { |
|
|
|
|
773 |
res->is_committed= TRUE; |
res->is_committed= TRUE; |
|
|
|
774 |
printf_ssl_socket(res->ssl, "HTTP/1.0 200 OK\r\n"); |
printf_ssl_socket(res->ssl, "HTTP/1.0 200 OK\r\n"); |
775 |
printf_ssl_socket(res->ssl, "Content-length: %d\r\n", l); |
printf_ssl_socket(res->ssl, "Content-length: %d\r\n", l); |
776 |
printf_ssl_socket(res->ssl, "Content-Type: image/gif\r\n"); |
printf_ssl_socket(res->ssl, "Content-Type: image/gif\r\n"); |
777 |
printf_ssl_socket(res->ssl, "Connection: close\r\n\r\n"); |
printf_ssl_socket(res->ssl, "Connection: close\r\n\r\n"); |
|
|
|
778 |
send_ssl_socket(res->ssl, pixel, l); |
send_ssl_socket(res->ssl, pixel, l); |
|
|
|
779 |
} else { |
} else { |
|
|
|
780 |
FILE *out= res->outputstream; |
FILE *out= res->outputstream; |
|
|
|
781 |
res->is_committed= TRUE; |
res->is_committed= TRUE; |
|
|
|
782 |
fprintf(out, "HTTP/1.0 200 OK\r\n"); |
fprintf(out, "HTTP/1.0 200 OK\r\n"); |
783 |
fprintf(out, "Content-length: %d\r\n", l); |
fprintf(out, "Content-length: %d\r\n", l); |
784 |
fprintf(out, "Content-Type: image/gif\r\n"); |
fprintf(out, "Content-Type: image/gif\r\n"); |
785 |
fprintf(out, "Connection: close\r\n\r\n"); |
fprintf(out, "Connection: close\r\n\r\n"); |
|
|
|
786 |
fwrite(pixel, sizeof(unsigned char), l, out); |
fwrite(pixel, sizeof(unsigned char), l, out); |
|
|
|
787 |
} |
} |
|
|
|
788 |
} |
} |
789 |
|
|
790 |
} |
} |
805 |
Service_T s; |
Service_T s; |
806 |
|
|
807 |
for(s= servicelist; s; s= s->next) { |
for(s= servicelist; s; s= s->next) { |
808 |
|
|
809 |
int isrunning; |
int isrunning; |
810 |
char *uptime; |
char *uptime; |
811 |
|
|
812 |
if(s->task != TASK_PROCESS) continue; |
if(s->task != TASK_PROCESS) continue; |
813 |
|
|
814 |
if(header) { |
if(header) { |
815 |
|
|
816 |
if ( Run.doprocess ) { |
if(Run.doprocess) { |
817 |
|
|
818 |
out_print(res, |
out_print(res, |
819 |
"<br><p> </p>" |
"<br><p> </p>" |
820 |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
845 |
|
|
846 |
isrunning= is_process_running(s); |
isrunning= is_process_running(s); |
847 |
uptime= get_process_uptime(s->path); |
uptime= get_process_uptime(s->path); |
848 |
|
|
849 |
if(Run.doprocess) { |
if(Run.doprocess) { |
850 |
ProcInfo_T pi= s->procinfo; |
ProcInfo_T pi= s->procinfo; |
851 |
if(isrunning) { |
if(isrunning) { |
852 |
out_print(res, |
out_print(res, |
853 |
"<tr %s>" |
"<tr %s>" |
854 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
855 |
"<td align=\"left\">%s</td><td align=\"right\">%s</td>" |
"<td align=\"left\">%s</td><td align=\"right\">%s</td>" |
856 |
"<td align=\"right\">%.1f%%</td>" |
"<td align=\"right\">%.1f%%</td>" |
857 |
"<td align=\"right\">%.1f%% [%ldkB]</td></tr>", |
"<td align=\"right\">%.1f%% [%ldkB]</td></tr>", |
858 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
859 |
s->name, s->name, |
s->name, s->name, |
860 |
s->has_checksum_error? |
s->has_checksum_error? |
861 |
"<font color='#ff0000'>Cheksum Error</font>": |
"<font color='#ff0000'>Cheksum Error</font>": |
862 |
isrunning? |
isrunning? |
863 |
"<font color=green>running</font>": |
"<font color=green>running</font>": |
864 |
"<font color=red>not running</font>", |
"<font color=red>not running</font>", |
865 |
uptime, |
uptime, |
866 |
pi->cpu_percent/10.0, |
pi->cpu_percent/10.0, |
867 |
pi->mem_percent/10.0,pi->mem_kbyte |
pi->mem_percent/10.0,pi->mem_kbyte |
868 |
); |
); |
869 |
} else { |
} else { |
870 |
out_print(res, |
out_print(res, |
871 |
"<tr %s>" |
"<tr %s>" |
872 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
873 |
"<td align=\"left\">%s</td>" |
"<td align=\"left\">%s</td>" |
874 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
875 |
"<td align=\"right\">- </td>" |
"<td align=\"right\">- </td>" |
876 |
"<td align=\"right\">- [-]</td></tr>", |
"<td align=\"right\">- [-]</td></tr>", |
877 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
878 |
s->name, s->name, |
s->name, s->name, |
879 |
s->has_checksum_error? |
s->has_checksum_error? |
880 |
"<font color='#ff0000'>Cheksum Error</font>": |
"<font color='#ff0000'>Cheksum Error</font>": |
881 |
"<font color=red>not running</font>" |
"<font color=red>not running</font>" |
882 |
); |
); |
883 |
} |
} |
884 |
} else { |
} else { |
885 |
out_print(res, |
out_print(res, |
886 |
"<tr %s>" |
"<tr %s>" |
887 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
888 |
"<td align=\"left\">%s %s</td>" |
"<td align=\"left\">%s %s</td>" |
889 |
"</tr>", |
"</tr>", |
890 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
891 |
s->name, s->name, |
s->name, s->name, |
892 |
s->has_checksum_error? |
s->has_checksum_error? |
893 |
"<font color='#ff0000'>Cheksum Error</font>": |
"<font color='#ff0000'>Cheksum Error</font>": |
894 |
isrunning? |
isrunning? |
895 |
"<font color=green>running</font>": |
"<font color=green>running</font>": |
896 |
"<font color=red>not running</font>", |
"<font color=red>not running</font>", |
897 |
isrunning?uptime:""); |
isrunning?uptime:""); |
898 |
} |
} |
899 |
|
|
900 |
on= on?FALSE:TRUE; |
on= on?FALSE:TRUE; |
901 |
free(uptime); |
free(uptime); |
902 |
|
|
903 |
} |
} |
904 |
|
|
905 |
out_print(res, "</table>"); |
out_print(res, "</table>"); |
906 |
|
|
907 |
} |
} |
908 |
|
|
909 |
|
|
910 |
static void do_home_device(HttpRequest req, HttpResponse res) { |
static void do_home_device(HttpRequest req, HttpResponse res) { |
911 |
|
|
912 |
Service_T s; |
Service_T s; |
913 |
int on= TRUE; |
int on= TRUE; |
914 |
int header= TRUE; |
int header= TRUE; |
915 |
|
|
916 |
for(s= servicelist; s; s= s->next) { |
for(s= servicelist; s; s= s->next) { |
917 |
|
|
918 |
if(s->task != TASK_DEVICE) continue; |
if(s->task != TASK_DEVICE) continue; |
919 |
|
|
920 |
if(header) { |
if(header) { |
921 |
|
|
922 |
out_print(res, |
out_print(res, |
923 |
"<br><p> </p>" |
"<br><p> </p>" |
924 |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
925 |
"<tr>" |
"<tr>" |
926 |
"<td width=\"20%\"><h3><b>Device</b></h3></td>" |
"<td width=\"20%\"><h3><b>Device</b></h3></td>" |
927 |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
928 |
"<td align=\"right\"><h3><b>Space usage</b></h3></td>" |
"<td align=\"right\"><h3><b>Space usage</b></h3></td>" |
929 |
"<td align=\"right\"><h3><b>Inodes usage</b></h3></td>" |
"<td align=\"right\"><h3><b>Inodes usage</b></h3></td>" |
930 |
"</tr>" |
"</tr>" |
931 |
"<tr><td> </td><td> </td></tr>"); |
"<tr><td> </td><td> </td></tr>" |
932 |
|
); |
933 |
|
|
934 |
header= FALSE; |
header= FALSE; |
935 |
|
|
936 |
} |
} |
937 |
|
|
938 |
if(!DeviceInfo_Usage(s->devinfo, s->path)) { |
if(!DeviceInfo_Usage(s->devinfo, s->path)) { |
|
|
|
939 |
out_print(res, |
out_print(res, |
940 |
"<tr %s>" |
"<tr %s>" |
941 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
942 |
"<td align=\"left\"><font color=red>not accessible</font></td>" |
"<td align=\"left\"><font color=red>not accessible</font></td>" |
943 |
"<td align=\"right\">- [-]</td>" |
"<td align=\"right\">- [-]</td>" |
944 |
"<td align=\"right\">- [-]</td>" |
"<td align=\"right\">- [-]</td>" |
945 |
"</tr>", |
"</tr>", |
946 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
947 |
s->name, s->name); |
s->name, s->name); |
|
|
|
948 |
} else { |
} else { |
949 |
|
|
950 |
if(s->devinfo->f_files > 0) { |
if(s->devinfo->f_files > 0) { |
951 |
|
|
952 |
out_print(res, |
out_print(res, |
953 |
"<tr %s>" |
"<tr %s>" |
954 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
955 |
"<td align=\"left\"><font color=green>accessible</font></td>" |
"<td align=\"left\"><font color=green>accessible</font></td>" |
956 |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
957 |
"<td align=\"right\">%.1f%% [%ld objects]</td>" |
"<td align=\"right\">%.1f%% [%ld objects]</td>" |
958 |
"</tr>", |
"</tr>", |
959 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
960 |
s->name, s->name, |
s->name, s->name, |
961 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * |
962 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize, |
(s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
963 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / s->devinfo->f_files, |
s->devinfo->f_blocks, |
964 |
s->devinfo->f_files - s->devinfo->f_filesfree); |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
965 |
|
1048576 * s->devinfo->f_bsize, |
966 |
|
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree)/ |
967 |
|
s->devinfo->f_files, |
968 |
|
s->devinfo->f_files - s->devinfo->f_filesfree); |
969 |
} else { |
} else { |
970 |
|
|
971 |
out_print(res, |
out_print(res, |
972 |
"<tr %s>" |
"<tr %s>" |
973 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
974 |
"<td align=\"left\"><font color=green>accessible</font></td>" |
"<td align=\"left\"><font color=green>accessible</font></td>" |
975 |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
976 |
"<td align=\"right\"><font color=red>not supported by filesystem</font></td>" |
"<td align=\"right\"><font color=red>not supported by " |
977 |
"</tr>", |
"filesystem</font></td></tr>", |
978 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
979 |
s->name, s->name, |
s->name, s->name, |
980 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / s->devinfo->f_blocks, |
(float) 100 * (s->devinfo->f_blocks - |
981 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / 1048576 * s->devinfo->f_bsize); |
s->devinfo->f_blocksfree) / |
982 |
|
s->devinfo->f_blocks, |
983 |
|
(float) (s->devinfo->f_blocks - |
984 |
|
s->devinfo->f_blocksfree) / |
985 |
|
1048576 * s->devinfo->f_bsize); |
986 |
} |
} |
987 |
} |
} |
988 |
|
|
989 |
on= on?FALSE:TRUE; |
on= on?FALSE:TRUE; |
990 |
|
|
991 |
} |
} |
992 |
|
|
993 |
out_print(res, "</table>"); |
out_print(res, "</table>"); |
994 |
|
|
995 |
} |
} |
996 |
|
|
997 |
|
|
998 |
static void do_home_file(HttpRequest req, HttpResponse res) { |
static void do_home_file(HttpRequest req, HttpResponse res) { |
999 |
|
|
1000 |
Service_T s; |
Service_T s; |
1001 |
int on= TRUE; |
int on= TRUE; |
1002 |
int header= TRUE; |
int header= TRUE; |
1003 |
struct stat stat_buf; |
struct stat stat_buf; |
1004 |
|
|
1005 |
for(s= servicelist; s; s= s->next) { |
for(s= servicelist; s; s= s->next) { |
1006 |
|
|
1007 |
if(s->task != TASK_FILE) continue; |
if(s->task != TASK_FILE) continue; |
1008 |
|
|
1009 |
if(header) { |
if(header) { |
1010 |
|
|
1011 |
out_print(res, |
out_print(res, |
1012 |
"<br><p> </p>" |
"<br><p> </p>" |
1013 |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
1014 |
"<tr>" |
"<tr>" |
1015 |
"<td width=\"20%\"><h3><b>File</b></h3></td>" |
"<td width=\"20%\"><h3><b>File</b></h3></td>" |
1016 |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
1017 |
"<td align=\"right\"><h3><b>Size</b></h3></td>" |
"<td align=\"right\"><h3><b>Size</b></h3></td>" |
1018 |
"<td align=\"right\"><h3><b>Permission</b></h3></td>" |
"<td align=\"right\"><h3><b>Permission</b></h3></td>" |
1019 |
"<td align=\"right\"><h3><b>UID</b></h3></td>" |
"<td align=\"right\"><h3><b>UID</b></h3></td>" |
1020 |
"<td align=\"right\"><h3><b>GID</b></h3></td>" |
"<td align=\"right\"><h3><b>GID</b></h3></td>" |
1021 |
"</tr>" |
"</tr>" |
1022 |
"<tr><td> </td><td> </td></tr>"); |
"<tr><td> </td><td> </td></tr>" |
1023 |
|
); |
1024 |
|
|
1025 |
header= FALSE; |
header= FALSE; |
1026 |
|
|
1027 |
} |
} |
1028 |
|
|
1029 |
if((stat(s->path, &stat_buf) != 0) || !S_ISREG(stat_buf.st_mode) ) { |
if((stat(s->path, &stat_buf) != 0) || !S_ISREG(stat_buf.st_mode)) { |
1030 |
|
|
1031 |
out_print(res, |
out_print(res, |
1032 |
"<tr %s>" |
"<tr %s>" |
1033 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1034 |
"<td align=\"left\"><font color=red>doesn't exist</font></td>" |
"<td align=\"left\"><font color=red>doesn't exist</font></td>" |
1035 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1036 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1037 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1038 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1039 |
"</tr>", |
"</tr>", |
1040 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1041 |
s->name, s->name |
s->name, s->name |
1042 |
); |
); |
1043 |
|
|
1044 |
} else { |
} else { |
1045 |
|
|
1046 |
out_print(res, |
out_print(res, |
1047 |
"<tr %s>" |
"<tr %s>" |
1048 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1049 |
"<td align=\"left\"><font color=green>exist</font></td>" |
"<td align=\"left\"><font color=green>exist</font></td>" |
1050 |
"<td align=\"right\">%.3f MB</td>" |
"<td align=\"right\">%.3f MB</td>" |
1051 |
"<td align=\"right\">%o</td>" |
"<td align=\"right\">%o</td>" |
1052 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1053 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1054 |
"</tr>", |
"</tr>", |
1055 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1056 |
s->name, s->name, |
s->name, s->name, |
1057 |
(float) stat_buf.st_size / 1048576, |
(float) stat_buf.st_size / 1048576, |
1058 |
stat_buf.st_mode & 07777, |
stat_buf.st_mode & 07777, |
1059 |
stat_buf.st_uid, |
stat_buf.st_uid, |
1060 |
stat_buf.st_gid |
stat_buf.st_gid |
1061 |
); |
); |
1062 |
|
|
1063 |
} |
} |
1064 |
|
|
1065 |
on= on?FALSE:TRUE; |
on= on?FALSE:TRUE; |
1066 |
|
|
1067 |
} |
} |
1068 |
|
|
1069 |
out_print(res, "</table>"); |
out_print(res, "</table>"); |
1070 |
|
|
1071 |
} |
} |
1072 |
|
|
1073 |
|
|
1074 |
static void do_home_directory(HttpRequest req, HttpResponse res) { |
static void do_home_directory(HttpRequest req, HttpResponse res) { |
1075 |
|
|
1076 |
Service_T s; |
Service_T s; |
1077 |
int on= TRUE; |
int on= TRUE; |
1078 |
int header= TRUE; |
int header= TRUE; |
1079 |
struct stat stat_buf; |
struct stat stat_buf; |
1080 |
|
|
1081 |
for(s= servicelist; s; s= s->next) { |
for(s= servicelist; s; s= s->next) { |
1082 |
|
|
1083 |
if(s->task != TASK_DIRECTORY) continue; |
if(s->task != TASK_DIRECTORY) continue; |
1084 |
|
|
1085 |
if(header) { |
if(header) { |
1086 |
|
|
1087 |
out_print(res, |
out_print(res, |
1088 |
"<br><p> </p>" |
"<br><p> </p>" |
1089 |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
"<table cellspacing=0 cellpadding=3 border=0 width=\"70%\">" |
1090 |
"<tr>" |
"<tr>" |
1091 |
"<td width=\"20%\"><h3><b>Directory</b></h3></td>" |
"<td width=\"20%\"><h3><b>Directory</b></h3></td>" |
1092 |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
"<td align=\"left\"><h3><b>Status</b></h3></td>" |
1093 |
"<td align=\"right\"><h3><b>Permission</b></h3></td>" |
"<td align=\"right\"><h3><b>Permission</b></h3></td>" |
1094 |
"<td align=\"right\"><h3><b>UID</b></h3></td>" |
"<td align=\"right\"><h3><b>UID</b></h3></td>" |
1095 |
"<td align=\"right\"><h3><b>GID</b></h3></td>" |
"<td align=\"right\"><h3><b>GID</b></h3></td>" |
1096 |
"</tr>" |
"</tr>" |
1097 |
"<tr><td> </td><td> </td></tr>"); |
"<tr><td> </td><td> </td></tr>"); |
1098 |
|
|
1099 |
header= FALSE; |
header= FALSE; |
1100 |
|
|
1101 |
} |
} |
1102 |
|
|
1103 |
if( (stat(s->path, &stat_buf) != 0) || !S_ISDIR(stat_buf.st_mode) ) { |
if( (stat(s->path, &stat_buf) != 0) || !S_ISDIR(stat_buf.st_mode)) { |
1104 |
|
|
1105 |
out_print(res, |
out_print(res, |
1106 |
"<tr %s>" |
"<tr %s>" |
1107 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1108 |
"<td align=\"left\"><font color=red>doesn't exist</font></td>" |
"<td align=\"left\"><font color=red>doesn't exist</font></td>" |
1109 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1110 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1111 |
"<td align=\"right\">-</td>" |
"<td align=\"right\">-</td>" |
1112 |
"</tr>", |
"</tr>", |
1113 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1114 |
s->name, s->name |
s->name, s->name |
1115 |
); |
); |
1116 |
|
|
1117 |
} else { |
} else { |
1118 |
|
|
1119 |
out_print(res, |
out_print(res, |
1120 |
"<tr %s>" |
"<tr %s>" |
1121 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1122 |
"<td align=\"left\"><font color=green>exist</font></td>" |
"<td align=\"left\"><font color=green>exist</font></td>" |
1123 |
"<td align=\"right\">%o</td>" |
"<td align=\"right\">%o</td>" |
1124 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1125 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1126 |
"</tr>", |
"</tr>", |
1127 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1128 |
s->name, s->name, |
s->name, s->name, |
1129 |
stat_buf.st_mode & 07777, |
stat_buf.st_mode & 07777, |
1130 |
stat_buf.st_uid, |
stat_buf.st_uid, |
1131 |
stat_buf.st_gid |
stat_buf.st_gid |
1132 |
); |
); |
1133 |
|
|
1134 |
} |
} |
1135 |
|
|
1136 |
on= on?FALSE:TRUE; |
on= on?FALSE:TRUE; |
1137 |
|
|
1138 |
} |
} |
1139 |
|
|
1140 |
out_print(res, "</table>"); |
out_print(res, "</table>"); |
1141 |
|
|
1142 |
} |
} |
1143 |
|
|
1144 |
|
|
1145 |
static void do_task_device(HttpRequest req, HttpResponse res, Service_T s) { |
static void do_task_device(HttpRequest req, HttpResponse res, Service_T s) { |
1146 |
|
|
1147 |
int state= DeviceInfo_Usage(s->devinfo, s->path); |
int state= DeviceInfo_Usage(s->devinfo, s->path); |
1148 |
|
|
1149 |
out_print(res, |
out_print(res, |
1150 |
"<p><br><h3>Device status</h3><br>"); |
"<p><br><h3>Device status</h3><br>"); |
1151 |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
1152 |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\"><b>Value</b></td></tr>"); |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\">" |
1153 |
|
"<b>Value</b></td></tr>"); |
1154 |
out_print(res, |
out_print(res, |
1155 |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
1156 |
out_print(res, |
out_print(res, |
1157 |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font></td></tr>", |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s" |
1158 |
s->group?s->group:"(not defined)"); |
"</font></td></tr>", s->group?s->group:"(not defined)"); |
1159 |
out_print(res, |
out_print(res, |
1160 |
"<tr><td>Device status</a></td><td>%s</td></tr>", |
"<tr><td>Device status</a></td><td>%s</td></tr>", |
1161 |
state?"<font color='#00ff00'>Accessible</font>": |
state?"<font color='#00ff00'>Accessible</font>": |
1162 |
"<font color='#ff0000'>Not Accessible</font>"); |
"<font color='#ff0000'>Not Accessible</font>"); |
1163 |
out_print(res, |
out_print(res, |
1164 |
"<tr><td>Path</a></td><td>%s</td></tr>", |
"<tr><td>Path</a></td><td>%s</td></tr>", |
1165 |
s->path); |
s->path); |
1166 |
out_print(res, |
out_print(res, |
1167 |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
1168 |
modenames[s->mode]); |
modenames[s->mode]); |
1169 |
out_print(res, |
out_print(res, |
1170 |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
1171 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
1172 |
if(s->start) { |
if(s->start) { |
1173 |
int i = 0; |
int i = 0; |
1174 |
|
|
1175 |
out_print(res, "<tr><td>Start program</a></td><td>"); |
out_print(res, "<tr><td>Start program</a></td><td>"); |
1176 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1177 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1178 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1179 |
} else { |
} else { |
1180 |
out_print(res, |
out_print(res, |
1181 |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
1182 |
} |
} |
1183 |
if(s->stop) { |
if(s->stop) { |
1184 |
int i = 0; |
int i = 0; |
1185 |
|
|
1186 |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
1187 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1188 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1189 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1190 |
} else { |
} else { |
1191 |
out_print(res, |
out_print(res, |
1192 |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
1193 |
} |
} |
1194 |
{ |
{ |
1195 |
Dependant_T d; |
Dependant_T d; |
1196 |
|
|
1197 |
for(d= s->dependantlist; d; d= d->next) { |
for(d= s->dependantlist; d; d= d->next) { |
1198 |
if(d->dependant != NULL) { |
if(d->dependant != NULL) { |
1199 |
out_print(res,"<tr><td>Depends on service </a></td>" |
out_print(res,"<tr><td>Depends on service </a></td>" |
1202 |
} |
} |
1203 |
} |
} |
1204 |
} |
} |
1205 |
|
|
1206 |
out_print(res, |
out_print(res, |
1207 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1208 |
s->every?s->every:1); |
s->every?s->every:1); |
1209 |
out_print(res, |
out_print(res, |
1210 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
1211 |
"</td></tr>", s->to_start, s->to_cycle); |
"</td></tr>", s->to_start, s->to_cycle); |
1212 |
{ |
{ |
1213 |
|
|
1214 |
Device_T dl; |
Device_T dl; |
1215 |
|
|
1216 |
if(s->devicelist) { |
if(s->devicelist) { |
1217 |
|
|
1218 |
for(dl= s->devicelist; dl; dl= dl->next) { |
for(dl= s->devicelist; dl; dl= dl->next) { |
1219 |
|
|
1220 |
if(dl->resource == RESOURCE_ID_INODE) { |
if(dl->resource == RESOURCE_ID_INODE) { |
1221 |
|
|
1222 |
out_print(res, |
out_print(res, |
1223 |
"<tr><td>Inodes usage limit</a></td><td>if %s %ld %s then %s</td></tr>", |
"<tr><td>Inodes usage limit</a></td><td>if %s %ld %s " |
1224 |
operatornames[dl->operator], |
"then %s</td></tr>", operatornames[dl->operator], |
1225 |
(dl->limit_absolute > -1)?dl->limit_absolute:dl->limit_percent, |
(dl->limit_absolute > -1)? |
1226 |
(dl->limit_absolute > -1)?"":"%", |
dl->limit_absolute:dl->limit_percent, |
1227 |
actionnames[dl->action]); |
(dl->limit_absolute > -1)?"":"%", |
1228 |
|
actionnames[dl->action]); |
1229 |
|
|
1230 |
} else if(dl->resource == RESOURCE_ID_SPACE) { |
} else if(dl->resource == RESOURCE_ID_SPACE) { |
1231 |
|
|
1232 |
out_print(res, |
out_print(res, |
1233 |
"<tr><td>Space usage limit</a></td><td>if %s %ld %s then %s</td></tr>", |
"<tr><td>Space usage limit</a></td><td>if %s %ld %s " |
1234 |
operatornames[dl->operator], |
"then %s</td></tr>", operatornames[dl->operator], |
1235 |
(dl->limit_absolute > -1)?dl->limit_absolute:dl->limit_percent, |
(dl->limit_absolute > -1)? |
1236 |
(dl->limit_absolute > -1)?"blocks":"%", |
dl->limit_absolute:dl->limit_percent, |
1237 |
actionnames[dl->action]); |
(dl->limit_absolute > -1)?"blocks":"%", |
1238 |
|
actionnames[dl->action]); |
1239 |
} |
} |
1240 |
|
|
1241 |
} |
} |
1242 |
|
|
1243 |
} |
} |
1244 |
|
|
1245 |
if(state) { |
if(state) { |
1246 |
out_print(res, |
out_print(res, |
1247 |
"<tr><td>Blocks total</a></td><td>%ld [%.1f MB]</td></tr>", |
"<tr><td>Blocks total</a></td><td>%ld [%.1f MB]</td></tr>", |
1248 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
1249 |
(float) s->devinfo->f_blocks / 1048576 * s->devinfo->f_bsize); |
(float) s->devinfo->f_blocks / 1048576 * s->devinfo->f_bsize); |
1250 |
out_print(res, |
out_print(res, |
1251 |
"<tr><td>Blocks free for non superuser</a></td><td>%ld [%.1f MB] [%.1f%%]</font></td></tr>", |
"<tr><td>Blocks free for non superuser</a></td>" |
1252 |
s->devinfo->f_blocksfree, |
"<td>%ld [%.1f MB] [%.1f%%]</font></td></tr>", |
1253 |
(float) s->devinfo->f_blocksfree / 1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocksfree, |
1254 |
(float) 100 * s->devinfo->f_blocksfree / s->devinfo->f_blocks); |
(float) s->devinfo->f_blocksfree / |
1255 |
out_print(res, |
1048576 * s->devinfo->f_bsize, |
1256 |
"<tr><td>Blocks free total</a></td><td>%ld [%.1f MB] [%.1f%%]</td></tr>", |
(float) 100 * s->devinfo->f_blocksfree / s->devinfo->f_blocks); |
1257 |
s->devinfo->f_blocksfreetotal, |
out_print(res, |
1258 |
(float) s->devinfo->f_blocksfreetotal / 1048576 * s->devinfo->f_bsize, |
"<tr><td>Blocks free total</a></td><td>%ld [%.1f MB] [%.1f%%]" |
1259 |
(float) 100 * s->devinfo->f_blocksfreetotal / s->devinfo->f_blocks); |
"</td></tr>", s->devinfo->f_blocksfreetotal, |
1260 |
|
(float) s->devinfo->f_blocksfreetotal / |
1261 |
|
1048576 * s->devinfo->f_bsize, |
1262 |
|
(float) 100 * s->devinfo->f_blocksfreetotal / |
1263 |
|
s->devinfo->f_blocks); |
1264 |
out_print(res, |
out_print(res, |
1265 |
"<tr><td>Block size</a></td><td>%ld B</td></tr>", |
"<tr><td>Block size</a></td><td>%ld B</td></tr>", |
1266 |
s->devinfo->f_bsize); |
s->devinfo->f_bsize); |
1267 |
if(s->devinfo->f_files > 0) { |
if(s->devinfo->f_files > 0) { |
1268 |
out_print(res, |
out_print(res, |
1269 |
"<tr><td>Inodes total</a></td><td>%ld</td></tr>", |
"<tr><td>Inodes total</a></td><td>%ld</td></tr>", |
1270 |
s->devinfo->f_files); |
s->devinfo->f_files); |
1271 |
out_print(res, |
out_print(res, |
1272 |
"<tr><td>Inodes free</a></td><td>%ld [%.1f%%]</font></td></tr>", |
"<tr><td>Inodes free</a></td><td>%ld [%.1f%%]</font>" |
1273 |
s->devinfo->f_filesfree, |
"</td></tr>", s->devinfo->f_filesfree, |
1274 |
(float) 100 * s->devinfo->f_filesfree / s->devinfo->f_files); |
(float) 100 * s->devinfo->f_filesfree / s->devinfo->f_files); |
1275 |
} |
} |
1276 |
} else { |
} else { |
1277 |
out_print(res, |
out_print(res, |
1278 |
"<tr><td>Blocks total</a></td><td>-</td></tr>"); |
"<tr><td>Blocks total</a></td><td>-</td></tr>"); |
1279 |
out_print(res, |
out_print(res, |
1280 |
"<tr><td>Blocks free for non superuser</a></td><td>-</font></td></tr>"); |
"<tr><td>Blocks free for non superuser</a></td>" |
1281 |
|
"<td>-</font></td></tr>"); |
1282 |
out_print(res, |
out_print(res, |
1283 |
"<tr><td>Blocks free total</a></td><td>-</td></tr>"); |
"<tr><td>Blocks free total</a></td><td>-</td></tr>"); |
1284 |
out_print(res, |
out_print(res, |
1285 |
"<tr><td>Block size</a></td><td>-</td></tr>"); |
"<tr><td>Block size</a></td><td>-</td></tr>"); |
1286 |
out_print(res, |
out_print(res, |
1287 |
"<tr><td>Inodes total</a></td><td>-</td></tr>"); |
"<tr><td>Inodes total</a></td><td>-</td></tr>"); |
1288 |
out_print(res, |
out_print(res, |
1289 |
"<tr><td>Inodes free</a></td><td>-</font></td></tr>"); |
"<tr><td>Inodes free</a></td><td>-</font></td></tr>"); |
1290 |
} |
} |
1291 |
} |
} |
1292 |
{ |
{ |
1293 |
Mail_T r; |
Mail_T r; |
1294 |
for(r= s->maillist; r; r= r->next) { |
for(r= s->maillist; r; r= r->next) { |
1295 |
out_print(res, |
out_print(res, |
1296 |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td><td>%s</td></tr>", |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td>" |
1297 |
r->to?r->to:""); |
"<td>%s</td></tr>", r->to?r->to:""); |
1298 |
out_print(res, |
out_print(res, |
1299 |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
1300 |
r->from?r->from:"(default)"); |
r->from?r->from:"(default)"); |
1301 |
out_print(res, |
out_print(res, |
1302 |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
1303 |
r->subject?r->subject:"(default)"); |
r->subject?r->subject:"(default)"); |
1304 |
out_print(res, |
out_print(res, |
1305 |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
1306 |
r->message?r->message:"(default)"); |
r->message?r->message:"(default)"); |
|
|
|
1307 |
out_print(res, |
out_print(res, |
1308 |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
1309 |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
1310 |
out_print(res, |
out_print(res, |
1311 |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
1312 |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
1313 |
out_print(res, |
out_print(res, |
1314 |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
1315 |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
1316 |
out_print(res, |
out_print(res, |
1317 |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
1318 |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
1319 |
out_print(res, |
out_print(res, |
1320 |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
1321 |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
1322 |
out_print(res, |
out_print(res, |
1323 |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
1324 |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
1325 |
out_print(res, |
out_print(res, |
1326 |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
1327 |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
1328 |
} |
} |
1329 |
} |
} |
1331 |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
1332 |
/* Start program */ |
/* Start program */ |
1333 |
if(s->start) |
if(s->start) |
1334 |
out_print(res, |
out_print(res, |
1335 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1336 |
"<input type=hidden value='start' name=action>" |
"<input type=hidden value='start' name=action>" |
1337 |
"<input type=submit value='Start program' style='font-size: 12pt'></font>" |
"<input type=submit value='Start program' style='font-size: " |
1338 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1339 |
/* Stop program */ |
/* Stop program */ |
1340 |
if(s->stop) |
if(s->stop) |
1341 |
out_print(res, |
out_print(res, |
1342 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1343 |
"<input type=hidden value='stop' name=action>" |
"<input type=hidden value='stop' name=action>" |
1344 |
"<input type=submit value='Stop program' style='font-size: 12pt'></font>" |
"<input type=submit value='Stop program' style='font-size: " |
1345 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1346 |
if(s->start && s->stop) |
if(s->start && s->stop) |
1347 |
out_print(res, |
out_print(res, |
1348 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1349 |
"<input type=hidden value='restart' name=action>" |
"<input type=hidden value='restart' name=action>" |
1350 |
"<input type=submit value='Restart program' style='font-size: 12pt'></font>" |
"<input type=submit value='Restart program' style='font-size: " |
1351 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1352 |
out_print(res, "</tr></table>"); |
out_print(res, "</tr></table>"); |
1353 |
|
|
1354 |
} |
} |
1355 |
|
|
1356 |
|
|
1357 |
static void do_task_directory(HttpRequest req, HttpResponse res, Service_T s) { |
static void do_task_directory(HttpRequest req, HttpResponse res, Service_T s) { |
1358 |
|
|
1359 |
struct stat stat_buf; |
struct stat stat_buf; |
1360 |
int state= ( (stat(s->path, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode) ); |
int state=((stat(s->path, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)); |
1361 |
|
|
1362 |
out_print(res, |
out_print(res, |
1363 |
"<p><br><h3>Directory status</h3><br>"); |
"<p><br><h3>Directory status</h3><br>"); |
1364 |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
1365 |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\"><b>Value</b></td></tr>"); |
"<tr><td width=\"30%\"><b>Parameter</b></td>" |
1366 |
|
"<td width=\"70%\"><b>Value</b></td></tr>"); |
1367 |
out_print(res, |
out_print(res, |
1368 |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
1369 |
out_print(res, |
out_print(res, |
1370 |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font></td></tr>", |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font></td></tr>", |
1371 |
s->group?s->group:"(not defined)"); |
s->group?s->group:"(not defined)"); |
1372 |
out_print(res, |
out_print(res, |
1373 |
"<tr><td>Directory status</a></td><td>%s</td></tr>", |
"<tr><td>Directory status</a></td><td>%s</td></tr>", |
1374 |
state?"<font color='#00ff00'>Exist</font>": |
state?"<font color='#00ff00'>Exist</font>": |
1375 |
"<font color='#ff0000'>Doesn't Exist</font>"); |
"<font color='#ff0000'>Doesn't Exist</font>"); |
1376 |
out_print(res, |
out_print(res, |
1377 |
"<tr><td>Path</a></td><td>%s</td></tr>", |
"<tr><td>Path</a></td><td>%s</td></tr>", |
1378 |
s->path); |
s->path); |
1379 |
out_print(res, |
out_print(res, |
1380 |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
1381 |
modenames[s->mode]); |
modenames[s->mode]); |
1382 |
out_print(res, |
out_print(res, |
1383 |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
1384 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
1385 |
if(s->start) { |
if(s->start) { |
1386 |
int i = 0; |
int i = 0; |
1387 |
|
|
1388 |
out_print(res, "<tr><td>Start program</a></td><td>"); |
out_print(res, "<tr><td>Start program</a></td><td>"); |
1389 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1390 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1391 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1392 |
} else { |
} else { |
1393 |
out_print(res, |
out_print(res, |
1394 |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
1395 |
} |
} |
1396 |
if(s->stop) { |
if(s->stop) { |
1397 |
int i = 0; |
int i = 0; |
1398 |
|
|
1399 |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
1400 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1401 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1402 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1403 |
} else { |
} else { |
1404 |
out_print(res, |
out_print(res, |
1405 |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
1406 |
} |
} |
1407 |
{ |
{ |
1408 |
Dependant_T d; |
Dependant_T d; |
1409 |
|
|
1410 |
for(d= s->dependantlist; d; d= d->next) { |
for(d= s->dependantlist; d; d= d->next) { |
1411 |
if(d->dependant != NULL) { |
if(d->dependant != NULL) { |
1412 |
out_print(res,"<tr><td>Depends on service </a></td>" |
out_print(res,"<tr><td>Depends on service </a></td>" |
1419 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1420 |
s->every?s->every:1); |
s->every?s->every:1); |
1421 |
out_print(res, |
out_print(res, |
1422 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
1423 |
"</td></tr>", s->to_start, s->to_cycle); |
"</td></tr>", s->to_start, s->to_cycle); |
1424 |
out_print(res, |
out_print(res, |
1425 |
"<tr><td>UID</a></td><td>%d</td></tr>", |
"<tr><td>UID</a></td><td>%d</td></tr>", |
1426 |
stat_buf.st_uid); |
stat_buf.st_uid); |
1427 |
out_print(res, |
out_print(res, |
1428 |
"<tr><td>GID</a></td><td>%d</td></tr>", |
"<tr><td>GID</a></td><td>%d</td></tr>", |
1429 |
stat_buf.st_gid); |
stat_buf.st_gid); |
1430 |
if(s->perm != -1) |
if(s->perm != -1) |
1431 |
out_print(res, "<tr><td>Associated permission</a></td><td>%o</td></tr>", s->perm); |
out_print(res, "<tr><td>Associated permission</a></td><td>%o</td></tr>", |
1432 |
|
s->perm); |
1433 |
out_print(res, |
out_print(res, |
1434 |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
1435 |
stat_buf.st_mode & 07777); |
stat_buf.st_mode & 07777); |
1436 |
{ |
{ |
1437 |
Mail_T r; |
Mail_T r; |
1438 |
for(r= s->maillist; r; r= r->next) { |
for(r= s->maillist; r; r= r->next) { |
1439 |
out_print(res, |
out_print(res, |
1440 |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td><td>%s</td></tr>", |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td>" |
1441 |
r->to?r->to:""); |
"<td>%s</td></tr>", r->to?r->to:""); |
1442 |
out_print(res, |
out_print(res, |
1443 |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
1444 |
r->from?r->from:"(default)"); |
r->from?r->from:"(default)"); |
1445 |
out_print(res, |
out_print(res, |
1446 |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
1447 |
r->subject?r->subject:"(default)"); |
r->subject?r->subject:"(default)"); |
1448 |
out_print(res, |
out_print(res, |
1449 |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
1450 |
r->message?r->message:"(default)"); |
r->message?r->message:"(default)"); |
1451 |
|
|
1452 |
out_print(res, |
out_print(res, |
1453 |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
1454 |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
1455 |
out_print(res, |
out_print(res, |
1456 |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
1457 |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
1458 |
out_print(res, |
out_print(res, |
1459 |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
1460 |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
1461 |
out_print(res, |
out_print(res, |
1462 |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
1463 |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
1464 |
out_print(res, |
out_print(res, |
1465 |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
1466 |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
1467 |
out_print(res, |
out_print(res, |
1468 |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
1469 |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
1470 |
out_print(res, |
out_print(res, |
1471 |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
1472 |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
1473 |
} |
} |
1474 |
} |
} |
1476 |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
1477 |
/* Start program */ |
/* Start program */ |
1478 |
if(s->start) |
if(s->start) |
1479 |
out_print(res, |
out_print(res, |
1480 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1481 |
"<input type=hidden value='start' name=action>" |
"<input type=hidden value='start' name=action>" |
1482 |
"<input type=submit value='Start program' style='font-size: 12pt'></font>" |
"<input type=submit value='Start program' style='font-size: " |
1483 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1484 |
/* Stop program */ |
/* Stop program */ |
1485 |
if(s->stop) |
if(s->stop) |
1486 |
out_print(res, |
out_print(res, |
1487 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1488 |
"<input type=hidden value='stop' name=action>" |
"<input type=hidden value='stop' name=action>" |
1489 |
"<input type=submit value='Stop program' style='font-size: 12pt'></font>" |
"<input type=submit value='Stop program' style='font-size: " |
1490 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1491 |
if(s->start && s->stop) |
if(s->start && s->stop) |
1492 |
out_print(res, |
out_print(res, |
1493 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1494 |
"<input type=hidden value='restart' name=action>" |
"<input type=hidden value='restart' name=action>" |
1495 |
"<input type=submit value='Restart program' style='font-size: 12pt'></font>" |
"<input type=submit value='Restart program' style='font-size: " |
1496 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1497 |
out_print(res, "</tr></table>"); |
out_print(res, "</tr></table>"); |
1498 |
|
|
1499 |
} |
} |
1500 |
|
|
1501 |
|
|
1502 |
static void do_task_file(HttpRequest req, HttpResponse res, Service_T s) { |
static void do_task_file(HttpRequest req, HttpResponse res, Service_T s) { |
1503 |
|
|
1504 |
struct stat stat_buf; |
struct stat stat_buf; |
1505 |
int state= ( (stat(s->path, &stat_buf) == 0) && S_ISREG(stat_buf.st_mode) ); |
int state=((stat(s->path, &stat_buf) == 0) && S_ISREG(stat_buf.st_mode)); |
1506 |
|
|
1507 |
out_print(res, |
out_print(res, |
1508 |
"<p><br><h3>File status</h3><br>"); |
"<p><br><h3>File status</h3><br>"); |
1509 |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
1510 |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\"><b>Value</b></td></tr>"); |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\">" |
1511 |
|
"<b>Value</b></td></tr>"); |
1512 |
out_print(res, |
out_print(res, |
1513 |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
1514 |
out_print(res, |
out_print(res, |
1515 |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font></td></tr>", |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font>" |
1516 |
s->group?s->group:"(not defined)"); |
"</td></tr>", s->group?s->group:"(not defined)"); |
1517 |
out_print(res, |
out_print(res, |
1518 |
"<tr><td>File status</a></td><td>%s</td></tr>", |
"<tr><td>File status</a></td><td>%s</td></tr>", |
1519 |
state?"<font color='#00ff00'>Exist</font>": |
state?"<font color='#00ff00'>Exist</font>": |
1520 |
"<font color='#ff0000'>Doesn't Exist</font>"); |
"<font color='#ff0000'>Doesn't Exist</font>"); |
1521 |
out_print(res, |
out_print(res, |
1522 |
"<tr><td>Path</a></td><td>%s</td></tr>", |
"<tr><td>Path</a></td><td>%s</td></tr>", |
1523 |
s->path); |
s->path); |
1524 |
out_print(res, |
out_print(res, |
1525 |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
1526 |
modenames[s->mode]); |
modenames[s->mode]); |
1527 |
out_print(res, |
out_print(res, |
1528 |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
1529 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
1530 |
if(s->start) { |
if(s->start) { |
1531 |
int i = 0; |
int i = 0; |
1532 |
|
|
1533 |
out_print(res, "<tr><td>Start program</a></td><td>"); |
out_print(res, "<tr><td>Start program</a></td><td>"); |
1534 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1535 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1536 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1537 |
} else { |
} else { |
1538 |
out_print(res, |
out_print(res, |
1539 |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
1540 |
} |
} |
1541 |
if(s->stop) { |
if(s->stop) { |
1542 |
int i = 0; |
int i = 0; |
1543 |
|
|
1544 |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
1545 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1546 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1547 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1548 |
} else { |
} else { |
1549 |
out_print(res, |
out_print(res, |
1550 |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
1551 |
} |
} |
1552 |
{ |
{ |
1553 |
struct mychecksum *c; |
struct mychecksum *c; |
1557 |
} |
} |
1558 |
{ |
{ |
1559 |
Dependant_T d; |
Dependant_T d; |
1560 |
|
|
1561 |
for(d= s->dependantlist; d; d= d->next) { |
for(d= s->dependantlist; d; d= d->next) { |
1562 |
if(d->dependant != NULL) { |
if(d->dependant != NULL) { |
1563 |
out_print(res,"<tr><td>Depends on service </a></td>" |
out_print(res,"<tr><td>Depends on service </a></td>" |
1568 |
} |
} |
1569 |
{ |
{ |
1570 |
struct mytimestamp *t; |
struct mytimestamp *t; |
1571 |
for(t= s->timestamplist; t; t= t->next) |
for(t= s->timestamplist; t; t= t->next) { |
1572 |
|
if(t->test_changes) { |
1573 |
|
out_print(res, |
1574 |
|
"<tr><td>Associated timestamp</a></td>" |
1575 |
|
"<td>If %s was changed then %s</td></tr>", |
1576 |
|
t->pathname, actionnames[t->action]); |
1577 |
|
} else { |
1578 |
out_print(res, |
out_print(res, |
1579 |
"<tr><td>Associated timestamp</a></td>" |
"<tr><td>Associated timestamp</a></td>" |
1580 |
"<td>If %s %s %d second(s) then %s</td></tr>", |
"<td>If %s %s %d second(s) then %s</td></tr>", |
1581 |
t->pathname, operatornames[t->operator], t->time, actionnames[t->action]); |
t->pathname, operatornames[t->operator], |
1582 |
|
t->time, actionnames[t->action]); |
1583 |
|
} |
1584 |
|
} |
1585 |
} |
} |
1586 |
out_print(res, |
out_print(res, |
1587 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1588 |
s->every?s->every:1); |
s->every?s->every:1); |
1589 |
out_print(res, |
out_print(res, |
1590 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
1591 |
"</td></tr>", s->to_start, s->to_cycle); |
"</td></tr>", s->to_start, s->to_cycle); |
1592 |
out_print(res, |
out_print(res, |
1593 |
"<tr><td>Size</a></td><td>%.3f MB</td></tr>", |
"<tr><td>Size</a></td><td>%.3f MB</td></tr>", |
1594 |
(float) stat_buf.st_size / 1048576); |
(float) stat_buf.st_size / 1048576); |
1595 |
out_print(res, |
out_print(res, |
1596 |
"<tr><td>UID</a></td><td>%d</td></tr>", |
"<tr><td>UID</a></td><td>%d</td></tr>", |
1597 |
stat_buf.st_uid); |
stat_buf.st_uid); |
1598 |
out_print(res, |
out_print(res, |
1599 |
"<tr><td>GID</a></td><td>%d</td></tr>", |
"<tr><td>GID</a></td><td>%d</td></tr>", |
1600 |
stat_buf.st_gid); |
stat_buf.st_gid); |
1601 |
if(s->perm != -1) |
if(s->perm != -1) |
1602 |
out_print(res, "<tr><td>Associated permission</a></td><td>%o</td></tr>", s->perm); |
out_print(res, "<tr><td>Associated permission</a></td><td>%o</td></tr>", |
1603 |
|
s->perm); |
1604 |
out_print(res, |
out_print(res, |
1605 |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
1606 |
stat_buf.st_mode & 07777); |
stat_buf.st_mode & 07777); |
1607 |
{ |
{ |
1608 |
Mail_T r; |
Mail_T r; |
1609 |
for(r= s->maillist; r; r= r->next) { |
for(r= s->maillist; r; r= r->next) { |
1610 |
out_print(res, |
out_print(res, |
1611 |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td><td>%s</td></tr>", |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td><td>%s" |
1612 |
r->to?r->to:""); |
"</td></tr>", r->to?r->to:""); |
1613 |
out_print(res, |
out_print(res, |
1614 |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
1615 |
r->from?r->from:"(default)"); |
r->from?r->from:"(default)"); |
1616 |
out_print(res, |
out_print(res, |
1617 |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
1618 |
r->subject?r->subject:"(default)"); |
r->subject?r->subject:"(default)"); |
1619 |
out_print(res, |
out_print(res, |
1620 |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
1621 |
r->message?r->message:"(default)"); |
r->message?r->message:"(default)"); |
1622 |
|
out_print(res, |
1623 |
out_print(res, |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
|
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
|
1624 |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
1625 |
out_print(res, |
out_print(res, |
1626 |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
1627 |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
1628 |
out_print(res, |
out_print(res, |
1629 |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
1630 |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
1631 |
out_print(res, |
out_print(res, |
1632 |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
1633 |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
1634 |
out_print(res, |
out_print(res, |
1635 |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
1636 |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
1637 |
out_print(res, |
out_print(res, |
1638 |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
1639 |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
1640 |
out_print(res, |
out_print(res, |
1641 |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
1642 |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
1643 |
} |
} |
1644 |
} |
} |
1646 |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
1647 |
/* Start program */ |
/* Start program */ |
1648 |
if(s->start) |
if(s->start) |
1649 |
out_print(res, |
out_print(res, |
1650 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1651 |
"<input type=hidden value='start' name=action>" |
"<input type=hidden value='start' name=action>" |
1652 |
"<input type=submit value='Start program' style='font-size: 12pt'></font>" |
"<input type=submit value='Start program' style='font-size: " |
1653 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1654 |
/* Stop program */ |
/* Stop program */ |
1655 |
if(s->stop) |
if(s->stop) |
1656 |
out_print(res, |
out_print(res, |
1657 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1658 |
"<input type=hidden value='stop' name=action>" |
"<input type=hidden value='stop' name=action>" |
1659 |
"<input type=submit value='Stop program' style='font-size: 12pt'></font>" |
"<input type=submit value='Stop program' style='font-size: " |
1660 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1661 |
if(s->start && s->stop) |
if(s->start && s->stop) |
1662 |
out_print(res, |
out_print(res, |
1663 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1664 |
"<input type=hidden value='restart' name=action>" |
"<input type=hidden value='restart' name=action>" |
1665 |
"<input type=submit value='Restart program' style='font-size: 12pt'></font>" |
"<input type=submit value='Restart program' style='font-size: " |
1666 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1667 |
out_print(res, "</tr></table>"); |
out_print(res, "</tr></table>"); |
1668 |
|
|
1669 |
} |
} |
1670 |
|
|
1671 |
|
|
1672 |
static void do_task_process(HttpRequest req, HttpResponse res, Service_T s) { |
static void do_task_process(HttpRequest req, HttpResponse res, Service_T s) { |
1673 |
|
|
1674 |
int run= is_process_running(s); |
int run= is_process_running(s); |
1675 |
|
|
1676 |
out_print(res, |
out_print(res, |
1677 |
"<p><br><h3>Process status</h3><br>"); |
"<p><br><h3>Process status</h3><br>"); |
1678 |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
out_print(res,"<table cellspacing=0 cellpadding=3 border=1 width=\"90%\">" |
1679 |
"<tr><td width=\"30%\"><b>Parameter</b></td><td width=\"70%\"><b>Value</b></td></tr>"); |
"<tr><td width=\"30%\"><b>Parameter</b></td>" |
1680 |
|
"<td width=\"70%\"><b>Value</b></td></tr>"); |
1681 |
out_print(res, |
out_print(res, |
1682 |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
"<tr><td>Name</a></td><td>%s</td></tr>", s->name); |
1683 |
out_print(res, |
out_print(res, |
1684 |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font></td></tr>", |
"<tr><td>Group</a></td><td><font color='#0000ff'>%s</font>" |
1685 |
s->group?s->group:"(not defined)"); |
"</td></tr>", s->group?s->group:"(not defined)"); |
1686 |
out_print(res, |
out_print(res, |
1687 |
"<tr><td>Process id </a></td><td>%d</td></tr>", run); |
"<tr><td>Process id </a></td><td>%d</td></tr>", run); |
1688 |
out_print(res, |
out_print(res, |
1689 |
"<tr><td>Process status</a></td><td>%s %s</td></tr>", |
"<tr><td>Process status</a></td><td>%s %s</td></tr>", |
1690 |
run?"<font color='#00ff00'>Running</font>": |
run?"<font color='#00ff00'>Running</font>": |
1691 |
"<font color='#ff0000'>Not Running</font>", |
"<font color='#ff0000'>Not Running</font>", |
1692 |
s->has_checksum_error? |
s->has_checksum_error? |
1693 |
"<font color='#ff0000'><b>Checksum error!</b></font>":""); |
"<font color='#ff0000'><b>Checksum error!</b></font>":""); |
1694 |
out_print(res, |
out_print(res, |
1695 |
"<tr><td>Pid file</a></td><td>%s</td></tr>", |
"<tr><td>Pid file</a></td><td>%s</td></tr>", |
1696 |
s->path); |
s->path); |
1697 |
out_print(res, |
out_print(res, |
1698 |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring mode</a></td><td>%s</td></tr>", |
1699 |
modenames[s->mode]); |
modenames[s->mode]); |
1700 |
out_print(res, |
out_print(res, |
1701 |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
"<tr><td>Monitoring status</a></td><td>%s</td></tr>", |
1702 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
1703 |
if(s->start) { |
if(s->start) { |
1704 |
int i = 0; |
int i = 0; |
1705 |
|
|
1706 |
out_print(res, "<tr><td>Start program</a></td><td>"); |
out_print(res, "<tr><td>Start program</a></td><td>"); |
1707 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1708 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1709 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1710 |
} else { |
} else { |
1711 |
out_print(res, |
out_print(res, |
1712 |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
1713 |
} |
} |
1714 |
if(s->stop) { |
if(s->stop) { |
1715 |
int i = 0; |
int i = 0; |
1716 |
|
|
1717 |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
out_print(res, "<tr><td>Stop program</a></td><td>"); |
1718 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1719 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1720 |
printf("</td></tr>"); |
printf("</td></tr>"); |
1721 |
} else { |
} else { |
1722 |
out_print(res, |
out_print(res, |
1723 |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
1724 |
} |
} |
1725 |
{ |
{ |
1726 |
struct mychecksum *c; |
struct mychecksum *c; |
1730 |
} |
} |
1731 |
{ |
{ |
1732 |
Dependant_T d; |
Dependant_T d; |
1733 |
|
|
1734 |
for(d= s->dependantlist; d; d= d->next) { |
for(d= s->dependantlist; d; d= d->next) { |
1735 |
if(d->dependant != NULL) { |
if(d->dependant != NULL) { |
1736 |
out_print(res,"<tr><td>Depends on service </a></td>" |
out_print(res,"<tr><td>Depends on service </a></td>" |
1739 |
} |
} |
1740 |
} |
} |
1741 |
} |
} |
1742 |
if ( Run.doprocess ) { |
if(Run.doprocess) { |
1743 |
ProcInfo_T pi= s->procinfo; |
ProcInfo_T pi= s->procinfo; |
1744 |
|
|
1745 |
out_print(res, |
out_print(res, |
1746 |
"<tr><td>CPU usage</a></td><td>%.1f%%</td></tr>", |
"<tr><td>CPU usage</a></td><td>%.1f%%</td></tr>", |
1747 |
pi->cpu_percent/10.0); |
pi->cpu_percent/10.0); |
1752 |
"<tr><td>Children</a></td><td>%d</td></tr>", |
"<tr><td>Children</a></td><td>%d</td></tr>", |
1753 |
pi->children); |
pi->children); |
1754 |
out_print(res, |
out_print(res, |
1755 |
"<tr><td>Total memory usage (incl. children) </a></td><td>%.1f%% [%ldkB]</td></tr>", |
"<tr><td>Total memory usage (incl. children) </a></td>" |
1756 |
|
"<td>%.1f%% [%ldkB]</td></tr>", |
1757 |
pi->total_mem_percent/10.0,pi->total_mem_kbyte); |
pi->total_mem_percent/10.0,pi->total_mem_kbyte); |
1758 |
} |
} |
1759 |
{ |
{ |
1760 |
Port_T n; |
Port_T n; |
1761 |
for(n= s->portlist; n; n= n->next) { |
for(n= s->portlist; n; n= n->next) { |
1762 |
|
if(n->family == AF_INET) { |
|
if ( n->family == AF_INET ) { |
|
|
|
|
1763 |
if(n->SSL.use_ssl) { |
if(n->SSL.use_ssl) { |
|
|
|
1764 |
out_print(res, |
out_print(res, |
1765 |
"<tr><td>Host:Port</a></td><td>%s:%d%s [%s via SSL]</td></tr>", |
"<tr><td>Host:Port</a></td><td>%s:%d%s [%s via SSL]</td>" |
1766 |
n->hostname, n->port, n->request?n->request:"", |
"</tr>", n->hostname, n->port, n->request?n->request:"", |
1767 |
n->protocol->name); |
n->protocol->name); |
1768 |
|
|
1769 |
if(n->SSL.certmd5 != NULL ) { |
if(n->SSL.certmd5 != NULL) { |
|
|
|
1770 |
out_print(res, |
out_print(res, |
1771 |
"<tr><td>Server certificate md5 sum</a></td><td>%s</td></tr>", |
"<tr><td>Server certificate md5 sum</a></td><td>%s</td></tr>", |
1772 |
n->SSL.certmd5); |
n->SSL.certmd5); |
|
|
|
1773 |
} |
} |
|
|
|
|
|
|
1774 |
} else { |
} else { |
|
|
|
1775 |
out_print(res, |
out_print(res, |
1776 |
"<tr><td>Host:Port</a></td><td>%s:%d%s [%s]</td></tr>", |
"<tr><td>Host:Port</a></td><td>%s:%d%s [%s]</td></tr>", |
1777 |
n->hostname, n->port, n->request?n->request:"", |
n->hostname, n->port, n->request?n->request:"", |
1778 |
n->protocol->name); |
n->protocol->name); |
|
|
|
1779 |
} |
} |
1780 |
|
} else if(n->family == AF_UNIX) { |
|
} else if ( n->family == AF_UNIX ) { |
|
|
|
|
1781 |
out_print(res, |
out_print(res, |
1782 |
"<tr><td>Unix Socket</a></td><td>%s [%s]</td></tr>", |
"<tr><td>Unix Socket</a></td><td>%s [%s]</td></tr>", |
1783 |
n->pathname, n->protocol->name); |
n->pathname, n->protocol->name); |
|
|
|
1784 |
} |
} |
1785 |
} |
} |
1786 |
} |
} |
1787 |
{ |
{ |
1788 |
struct mytimestamp *t; |
struct mytimestamp *t; |
1789 |
for(t= s->timestamplist; t; t= t->next) |
for(t= s->timestamplist; t; t= t->next) { |
1790 |
|
if(t->test_changes) { |
1791 |
|
out_print(res, |
1792 |
|
"<tr><td>Associated timestamp</a></td>" |
1793 |
|
"<td>If %s was changed then %s</td></tr>", |
1794 |
|
t->pathname, actionnames[t->action]); |
1795 |
|
} else { |
1796 |
out_print(res, |
out_print(res, |
1797 |
"<tr><td>Associated timestamp</a></td>" |
"<tr><td>Associated timestamp</a></td>" |
1798 |
"<td>If %s %s %d second(s) then %s</td></tr>", |
"<td>If %s %s %d second(s) then %s</td></tr>", |
1799 |
t->pathname, operatornames[t->operator], t->time, actionnames[t->action]); |
t->pathname, operatornames[t->operator], |
1800 |
|
t->time, actionnames[t->action]); |
1801 |
|
} |
1802 |
|
} |
1803 |
} |
} |
1804 |
{ |
{ |
1805 |
Resource_T q; |
Resource_T q; |
1806 |
|
|
1807 |
for (q= s->resourcelist; q; q= q->next) { |
for (q= s->resourcelist; q; q= q->next) { |
1808 |
switch (q->resource_id) { |
switch (q->resource_id) { |
1809 |
|
|
1810 |
case RESOURCE_ID_CPU_PERCENT: |
case RESOURCE_ID_CPU_PERCENT: |
1811 |
|
|
1812 |
out_print(res,"<tr><td>CPU usage limit</a></td>" |
out_print(res,"<tr><td>CPU usage limit</a></td>" |
1813 |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
1814 |
operatornames[q->operator], |
operatornames[q->operator], |
1815 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1816 |
actionnames[q->action]); |
actionnames[q->action]); |
1817 |
break; |
break; |
1818 |
|
|
1819 |
case RESOURCE_ID_MEM_PERCENT: |
case RESOURCE_ID_MEM_PERCENT: |
1820 |
|
|
1821 |
out_print(res,"<tr><td>Memory usage limit</a></td>" |
out_print(res,"<tr><td>Memory usage limit</a></td>" |
1822 |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
1823 |
operatornames[q->operator], |
operatornames[q->operator], |
1824 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1825 |
actionnames[q->action]); |
actionnames[q->action]); |
1826 |
break; |
break; |
1827 |
|
|
1828 |
case RESOURCE_ID_MEM_KBYTE: |
case RESOURCE_ID_MEM_KBYTE: |
1829 |
|
|
1830 |
out_print(res,"<tr><td>Memory amount limit</a></td>" |
out_print(res,"<tr><td>Memory amount limit</a></td>" |
1831 |
"<td>If %s %ld for %d cycle(s) then %s</td></tr>", |
"<td>If %s %ld for %d cycle(s) then %s</td></tr>", |
1832 |
operatornames[q->operator], |
operatornames[q->operator], |
1833 |
q->limit, q->max_cycle, |
q->limit, q->max_cycle, |
1834 |
actionnames[q->action]); |
actionnames[q->action]); |
1835 |
break; |
break; |
1836 |
|
|
1837 |
case RESOURCE_ID_LOAD1: |
case RESOURCE_ID_LOAD1: |
1838 |
|
|
1839 |
out_print(res,"<tr><td>Load average (1min)</a></td>" |
out_print(res,"<tr><td>Load average (1min)</a></td>" |
1840 |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
1841 |
operatornames[q->operator], |
operatornames[q->operator], |
1842 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1843 |
actionnames[q->action]); |
actionnames[q->action]); |
1844 |
break; |
break; |
1845 |
|
|
1846 |
case RESOURCE_ID_LOAD5: |
case RESOURCE_ID_LOAD5: |
1847 |
|
|
1848 |
out_print(res,"<tr><td>Load average (5min)</a></td>" |
out_print(res,"<tr><td>Load average (5min)</a></td>" |
1849 |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
1850 |
operatornames[q->operator], |
operatornames[q->operator], |
1851 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1852 |
actionnames[q->action]); |
actionnames[q->action]); |
1853 |
break; |
break; |
1854 |
|
|
1855 |
case RESOURCE_ID_LOAD15: |
case RESOURCE_ID_LOAD15: |
1856 |
out_print(res,"<tr><td>Load average (15min)</a></td>" |
out_print(res,"<tr><td>Load average (15min)</a></td>" |
1857 |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f for %d cycle(s) then %s</td></tr>", |
1858 |
operatornames[q->operator], |
operatornames[q->operator], |
1859 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1860 |
actionnames[q->action]); |
actionnames[q->action]); |
1861 |
break; |
break; |
1862 |
|
|
1863 |
case RESOURCE_ID_CHILDREN: |
case RESOURCE_ID_CHILDREN: |
1864 |
out_print(res,"<tr><td>Children</a></td>" |
out_print(res,"<tr><td>Children</a></td>" |
1865 |
"<td>If %s %d for %d cycle(s) then %s</td></tr>", |
"<td>If %s %d for %d cycle(s) then %s</td></tr>", |
1866 |
operatornames[q->operator], |
operatornames[q->operator], |
1867 |
q->limit, q->max_cycle, |
q->limit, q->max_cycle, |
1868 |
actionnames[q->action]); |
actionnames[q->action]); |
1869 |
break; |
break; |
1870 |
|
|
1871 |
case RESOURCE_ID_TOTAL_MEM_KBYTE: |
case RESOURCE_ID_TOTAL_MEM_KBYTE: |
1872 |
out_print(res,"<tr><td>Memory amount limit (incl. children)</a></td>" |
out_print(res,"<tr><td>Memory amount limit (incl. children)</a></td>" |
1873 |
"<td>If %s %d for %d cycle(s) then %s</td></tr>", |
"<td>If %s %d for %d cycle(s) then %s</td></tr>", |
1874 |
operatornames[q->operator], |
operatornames[q->operator], |
1875 |
q->limit, q->max_cycle, |
q->limit, q->max_cycle, |
1876 |
actionnames[q->action]); |
actionnames[q->action]); |
1877 |
break; |
break; |
1878 |
|
|
1879 |
case RESOURCE_ID_TOTAL_MEM_PERCENT: |
case RESOURCE_ID_TOTAL_MEM_PERCENT: |
1880 |
out_print(res,"<tr><td>Memory usage limit (incl. children)</a></td>" |
out_print(res,"<tr><td>Memory usage limit (incl. children)</a></td>" |
1881 |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
"<td>If %s %.1f%% for %d cycle(s) then %s</td></tr>", |
1882 |
operatornames[q->operator], |
operatornames[q->operator], |
1883 |
q->limit/10.0, q->max_cycle, |
q->limit/10.0, q->max_cycle, |
1884 |
actionnames[q->action]); |
actionnames[q->action]); |
1885 |
break; |
break; |
1886 |
|
|
1887 |
} |
} |
1888 |
} |
} |
1889 |
} |
} |
1891 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1892 |
s->every?s->every:1); |
s->every?s->every:1); |
1893 |
out_print(res, |
out_print(res, |
1894 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
1895 |
"</td></tr>", s->to_start, s->to_cycle); |
"</td></tr>", s->to_start, s->to_cycle); |
1896 |
{ |
{ |
1897 |
Mail_T r; |
Mail_T r; |
1898 |
for(r= s->maillist; r; r= r->next) { |
for(r= s->maillist; r; r= r->next) { |
1899 |
out_print(res, |
out_print(res, |
1900 |
"<tr bgcolor=\"#EFEFEF\"><td>Alert mail to</a></td><td>%s</td></tr>", |
"<tr bgcolor=\"#EFEFEF\"><td>" |
1901 |
|
"Alert mail to</a></td><td>%s</td></tr>", |
1902 |
r->to?r->to:""); |
r->to?r->to:""); |
1903 |
out_print(res, |
out_print(res, |
1904 |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
"<tr><td>Alert from</a></td><td>%s</td></tr>", |
1905 |
r->from?r->from:"(default)"); |
r->from?r->from:"(default)"); |
1906 |
out_print(res, |
out_print(res, |
1907 |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
"<tr><td>Alert subject</a></td><td>%s</td></tr>", |
1908 |
r->subject?r->subject:"(default)"); |
r->subject?r->subject:"(default)"); |
1909 |
out_print(res, |
out_print(res, |
1910 |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
"<tr><td>Alert message</a></td><td>%s</td></tr>", |
1911 |
r->message?r->message:"(default)"); |
r->message?r->message:"(default)"); |
1912 |
out_print(res, |
out_print(res, |
1913 |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
"<tr><td>Alert on start</a></td><td>%s</td></tr>", |
1914 |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_START)?"yes":"no"); |
1915 |
out_print(res, |
out_print(res, |
1916 |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
"<tr><td>Alert on stop</a></td><td>%s</td></tr>", |
1917 |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_STOP)?"yes":"no"); |
1918 |
out_print(res, |
out_print(res, |
1919 |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
"<tr><td>Alert on restart</a></td><td>%s</td></tr>", |
1920 |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESTART)?"yes":"no"); |
1921 |
out_print(res, |
out_print(res, |
1922 |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
"<tr><td>Alert on checksum</a></td><td>%s</td></tr>", |
1923 |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_CHECKSUM)?"yes":"no"); |
1924 |
out_print(res, |
out_print(res, |
1925 |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
"<tr><td>Alert on exceeded resource</a></td><td>%s</td></tr>", |
1926 |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_RESOURCE)?"yes":"no"); |
1927 |
out_print(res, |
out_print(res, |
1928 |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timeout</a></td><td>%s</td></tr>", |
1929 |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMEOUT)?"yes":"no"); |
1930 |
out_print(res, |
out_print(res, |
1931 |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
"<tr><td>Alert on timestamp</a></td><td>%s</td></tr>", |
1932 |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
IS_EVENT_SET(r->events, EVENT_TIMESTAMP)?"yes":"no"); |
1933 |
} |
} |
1934 |
} |
} |
1936 |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>"); |
1937 |
/* Start program */ |
/* Start program */ |
1938 |
if(s->start) |
if(s->start) |
1939 |
out_print(res, |
out_print(res, |
1940 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1941 |
"<input type=hidden value='start' name=action>" |
"<input type=hidden value='start' name=action>" |
1942 |
"<input type=submit value='Start program' style='font-size: 12pt'></font>" |
"<input type=submit value='Start program' style='font-size: " |
1943 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1944 |
/* Stop program */ |
/* Stop program */ |
1945 |
if(s->stop) |
if(s->stop) |
1946 |
out_print(res, |
out_print(res, |
1947 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1948 |
"<input type=hidden value='stop' name=action>" |
"<input type=hidden value='stop' name=action>" |
1949 |
"<input type=submit value='Stop program' style='font-size: 12pt'></font>" |
"<input type=submit value='Stop program' style='font-size: " |
1950 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1951 |
if(s->start && s->stop) |
if(s->start && s->stop) |
1952 |
out_print(res, |
out_print(res, |
1953 |
"<td><form method=GET action=/%s>" |
"<td><form method=GET action=/%s>" |
1954 |
"<input type=hidden value='restart' name=action>" |
"<input type=hidden value='restart' name=action>" |
1955 |
"<input type=submit value='Restart program' style='font-size: 12pt'></font>" |
"<input type=submit value='Restart program' style='font-size: " |
1956 |
"</form></td>", s->name); |
"12pt'></font></form></td>", s->name); |
1957 |
out_print(res, "</tr></table>"); |
out_print(res, "</tr></table>"); |
1958 |
|
|
1959 |
} |
} |
1960 |
|
|