583 |
break; |
break; |
584 |
|
|
585 |
case TASK_DEVICE: |
case TASK_DEVICE: |
586 |
if(DeviceInfo_Usage(s->devinfo, s->path)) { |
if(DeviceInfo_Usage(s->devinfo, s->path) && stat(s->path, &stat_buf) == 0 ) { |
587 |
|
|
588 |
if(s->devinfo->f_files > 0) { |
if(s->devinfo->f_files > 0) { |
589 |
|
|
590 |
if( Run.httpdssl) { |
if( Run.httpdssl) { |
591 |
|
|
592 |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
printf_ssl_socket(res->ssl, |
593 |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
"Device '%s' is accessible\n\t" |
594 |
"Monitoring status: %s\n", |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
595 |
s->name, |
"Permission: %o\n\t" |
596 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
"Monitoring status: %s\n", |
597 |
|
s->name, |
598 |
|
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
599 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
600 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
601 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
602 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
603 |
s->devinfo->f_files, |
s->devinfo->f_files, |
604 |
s->devinfo->f_files - s->devinfo->f_filesfree, |
s->devinfo->f_files - s->devinfo->f_filesfree, |
605 |
statusnames[s->do_monitor]); |
(int)(stat_buf.st_mode & 07777), |
606 |
|
statusnames[s->do_monitor]); |
607 |
|
|
608 |
} else { |
} else { |
609 |
|
|
610 |
fprintf(out, "Device '%s' is accessible\n\t" |
fprintf(out, |
611 |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
"Device '%s' is accessible\n\t" |
612 |
"Monitoring status: %s\n", |
"Space: %.1f%% [%.1f MB] Inodes: %.1f%% [%ld objects]\n\t" |
613 |
s->name, |
"Permission: %o\n\t" |
614 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
"Monitoring status: %s\n", |
615 |
|
s->name, |
616 |
|
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
617 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
618 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
619 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
620 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
621 |
s->devinfo->f_files, |
s->devinfo->f_files, |
622 |
s->devinfo->f_files - s->devinfo->f_filesfree, |
s->devinfo->f_files - s->devinfo->f_filesfree, |
623 |
statusnames[s->do_monitor]); |
(int)(stat_buf.st_mode & 07777), |
624 |
|
statusnames[s->do_monitor]); |
625 |
} |
} |
626 |
} else { |
} else { |
627 |
if( Run.httpdssl) { |
if( Run.httpdssl) { |
628 |
printf_ssl_socket(res->ssl, "Device '%s' is accessible\n\t" |
printf_ssl_socket(res->ssl, |
629 |
"Space: %.1f%% [%.1f MB]\n\t" |
"Device '%s' is accessible\n\t" |
630 |
"Monitoring status: %s\n", |
"Space: %.1f%% [%.1f MB]\n\t" |
631 |
s->name, |
"Permission: %o\n\t" |
632 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
"Monitoring status: %s\n", |
633 |
s->devinfo->f_blocks, |
s->name, |
634 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
635 |
1048576 * s->devinfo->f_bsize, |
s->devinfo->f_blocks, |
636 |
statusnames[s->do_monitor]); |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
637 |
|
1048576 * s->devinfo->f_bsize, |
638 |
|
(int)(stat_buf.st_mode & 07777), |
639 |
|
statusnames[s->do_monitor]); |
640 |
} else { |
} else { |
641 |
fprintf(out, "Device '%s' is accessible\n\t" |
fprintf(out, |
642 |
"Space: %.1f%% [%.1f MB]\n\t" |
"Device '%s' is accessible\n\t" |
643 |
"Monitoring status: %s\n", |
"Space: %.1f%% [%.1f MB]\n\t" |
644 |
s->name, |
"Permission: %o\n\t" |
645 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
"Monitoring status: %s\n", |
646 |
|
s->name, |
647 |
|
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
648 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
649 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
650 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
651 |
statusnames[s->do_monitor]); |
(int)(stat_buf.st_mode & 07777), |
652 |
|
statusnames[s->do_monitor]); |
653 |
} |
} |
654 |
} |
} |
655 |
} else { |
} else { |
656 |
if( Run.httpdssl) { |
if( Run.httpdssl) { |
657 |
|
|
658 |
printf_ssl_socket(res->ssl, "Device '%s' is not accessible\n\t" |
printf_ssl_socket(res->ssl, |
659 |
"Space: - Inodes: -\n\t" |
"Device '%s' is not accessible\n\t" |
660 |
"Monitoring status: %s\n", |
"Space: - Inodes: -\n\t" |
661 |
s->name, statusnames[s->do_monitor]); |
"Permission: -\n\t" |
662 |
|
"Monitoring status: %s\n", |
663 |
|
s->name, statusnames[s->do_monitor]); |
664 |
} else { |
} else { |
665 |
fprintf(out, "Device '%s' is not accessible\n\t" |
fprintf(out, |
666 |
"Space: - Inodes: -\n\t" |
"Device '%s' is not accessible\n\t" |
667 |
"Monitoring status: %s\n", |
"Space: - Inodes: -\n\t" |
668 |
s->name, statusnames[s->do_monitor]); |
"Permission: -\n\t" |
669 |
|
"Monitoring status: %s\n", |
670 |
|
s->name, statusnames[s->do_monitor]); |
671 |
} |
} |
672 |
} |
} |
673 |
break; |
break; |
850 |
s->has_checksum_error? |
s->has_checksum_error? |
851 |
"<font color='#ff0000'>Cheksum Error</font>": |
"<font color='#ff0000'>Cheksum Error</font>": |
852 |
isrunning? |
isrunning? |
853 |
"<font color=green>running</font>": |
"<font color='#00ff00'>running</font>": |
854 |
"<font color=red>not running</font>", |
"<font color='#ff0000'>not running</font>", |
855 |
uptime, |
uptime, |
856 |
pi->cpu_percent/10.0, |
pi->cpu_percent/10.0, |
857 |
pi->mem_percent/10.0,pi->mem_kbyte |
pi->mem_percent/10.0,pi->mem_kbyte |
942 |
out_print(res, |
out_print(res, |
943 |
"<tr %s>" |
"<tr %s>" |
944 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
945 |
"<td align=\"left\"><font color=green>accessible</font></td>" |
"<td align=\"left\">%s</td>" |
946 |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
947 |
"<td align=\"right\">%.1f%% [%ld objects]</td>" |
"<td align=\"right\">%.1f%% [%ld objects]</td>" |
948 |
"</tr>", |
"</tr>", |
949 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
950 |
s->name, s->name, |
s->name, s->name, |
951 |
|
s->has_permission_error? |
952 |
|
"<font color='#ff0000'>Permission Error</font>": |
953 |
|
"<font color='#00ff00'>accessible</font>", |
954 |
(float) 100 * |
(float) 100 * |
955 |
(s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
(s->devinfo->f_blocks - s->devinfo->f_blocksfree) / |
956 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
964 |
out_print(res, |
out_print(res, |
965 |
"<tr %s>" |
"<tr %s>" |
966 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
967 |
"<td align=\"left\"><font color=green>accessible</font></td>" |
"<td align=\"left\">%s</td>" |
968 |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
"<td align=\"right\">%.1f%% [%.1f MB]</td>" |
969 |
"<td align=\"right\"><font color=red>not supported by " |
"<td align=\"right\"><font color=red>not supported by " |
970 |
"filesystem</font></td></tr>", |
"filesystem</font></td></tr>", |
971 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
972 |
s->name, s->name, |
s->name, s->name, |
973 |
|
s->has_permission_error? |
974 |
|
"<font color='#ff0000'>Permission Error</font>": |
975 |
|
"<font color='#00ff00'>accessible</font>", |
976 |
(float) 100 * (s->devinfo->f_blocks - |
(float) 100 * (s->devinfo->f_blocks - |
977 |
s->devinfo->f_blocksfree) / |
s->devinfo->f_blocksfree) / |
978 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
1042 |
out_print(res, |
out_print(res, |
1043 |
"<tr %s>" |
"<tr %s>" |
1044 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1045 |
"<td align=\"left\"><font color=green>exist</font></td>" |
"<td align=\"left\">%s</td>" |
1046 |
"<td align=\"right\">%lu B</td>" |
"<td align=\"right\">%lu B</td>" |
1047 |
"<td align=\"right\">%o</td>" |
"<td align=\"right\">%o</td>" |
1048 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1050 |
"</tr>", |
"</tr>", |
1051 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1052 |
s->name, s->name, |
s->name, s->name, |
1053 |
|
s->has_permission_error? |
1054 |
|
"<font color='#ff0000'>Permission Error</font>": |
1055 |
|
s->has_checksum_error? |
1056 |
|
"<font color='#ff0000'>Checksum Error</font>": |
1057 |
|
"<font color='#00ff00'>accessible</font>", |
1058 |
(unsigned long)stat_buf.st_size, |
(unsigned long)stat_buf.st_size, |
1059 |
stat_buf.st_mode & 07777, |
stat_buf.st_mode & 07777, |
1060 |
stat_buf.st_uid, |
stat_buf.st_uid, |
1120 |
out_print(res, |
out_print(res, |
1121 |
"<tr %s>" |
"<tr %s>" |
1122 |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
"<td width=\"20%\"><a href='/%s'>%s</a></td>" |
1123 |
"<td align=\"left\"><font color=green>exist</font></td>" |
"<td align=\"left\">%s</td>" |
1124 |
"<td align=\"right\">%o</td>" |
"<td align=\"right\">%o</td>" |
1125 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1126 |
"<td align=\"right\">%d</td>" |
"<td align=\"right\">%d</td>" |
1127 |
"</tr>", |
"</tr>", |
1128 |
on?"bgcolor=\"#EFEFEF\"":"", |
on?"bgcolor=\"#EFEFEF\"":"", |
1129 |
s->name, s->name, |
s->name, s->name, |
1130 |
|
s->has_permission_error? |
1131 |
|
"<font color='#ff0000'>Permission Error</font>": |
1132 |
|
s->has_checksum_error? |
1133 |
|
"<font color='#ff0000'>Checksum Error</font>": |
1134 |
|
"<font color='#00ff00'>accessible</font>", |
1135 |
stat_buf.st_mode & 07777, |
stat_buf.st_mode & 07777, |
1136 |
stat_buf.st_uid, |
stat_buf.st_uid, |
1137 |
stat_buf.st_gid |
stat_buf.st_gid |
1150 |
|
|
1151 |
static void do_task_device(HttpRequest req, HttpResponse res, Service_T s) { |
static void do_task_device(HttpRequest req, HttpResponse res, Service_T s) { |
1152 |
|
|
1153 |
int state= DeviceInfo_Usage(s->devinfo, s->path); |
struct stat stat_buf; |
1154 |
|
|
1155 |
|
int state= ( DeviceInfo_Usage(s->devinfo, s->path) && stat(s->path, &stat_buf) == 0 ); |
1156 |
|
|
1157 |
out_print(res, |
out_print(res, |
1158 |
"<p><br><h3>Device status</h3><br>"); |
"<p><br><h3>Device status</h3><br>"); |
1166 |
"</font></td></tr>", s->group?s->group:"(not defined)"); |
"</font></td></tr>", s->group?s->group:"(not defined)"); |
1167 |
out_print(res, |
out_print(res, |
1168 |
"<tr><td>Device status</a></td><td>%s</td></tr>", |
"<tr><td>Device status</a></td><td>%s</td></tr>", |
1169 |
state?"<font color='#00ff00'>Accessible</font>": |
s->has_permission_error? |
1170 |
|
"<font color='#ff0000'>Permission error</font>": |
1171 |
|
state? |
1172 |
|
"<font color='#00ff00'>Accessible</font>": |
1173 |
"<font color='#ff0000'>Not Accessible</font>"); |
"<font color='#ff0000'>Not Accessible</font>"); |
1174 |
out_print(res, |
out_print(res, |
1175 |
"<tr><td>Path</a></td><td>%s</td></tr>", |
"<tr><td>Path</a></td><td>%s</td></tr>", |
1202 |
out_print(res, |
out_print(res, |
1203 |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
1204 |
} |
} |
1205 |
|
if(s->perm != -1) |
1206 |
|
out_print(res, "<tr><td>Associated permission</a></td><td>%o</td></tr>", |
1207 |
|
s->perm); |
1208 |
|
out_print(res, |
1209 |
|
"<tr><td>Permission</a></td><td>%s%o</font></td></tr>", |
1210 |
|
s->has_permission_error? |
1211 |
|
"<font color='#ff0000'>": |
1212 |
|
"<font>", |
1213 |
|
stat_buf.st_mode & 07777); |
1214 |
{ |
{ |
1215 |
Dependant_T d; |
Dependant_T d; |
1216 |
|
|
1451 |
"<tr><td>GID</a></td><td>%d</td></tr>", |
"<tr><td>GID</a></td><td>%d</td></tr>", |
1452 |
stat_buf.st_gid); |
stat_buf.st_gid); |
1453 |
out_print(res, |
out_print(res, |
1454 |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
"<tr><td>Permission</a></td><td>%s%o</font></td></tr>", |
1455 |
|
s->has_permission_error? |
1456 |
|
"<font color='#ff0000'>": |
1457 |
|
"<font>", |
1458 |
stat_buf.st_mode & 07777); |
stat_buf.st_mode & 07777); |
1459 |
{ |
{ |
1460 |
Mail_T r; |
Mail_T r; |
1642 |
"<tr><td>GID</a></td><td>%d</td></tr>", |
"<tr><td>GID</a></td><td>%d</td></tr>", |
1643 |
stat_buf.st_gid); |
stat_buf.st_gid); |
1644 |
out_print(res, |
out_print(res, |
1645 |
"<tr><td>Permission</a></td><td>%o</td></tr>", |
"<tr><td>Permission</a></td><td>%s%o</td></tr>", |
1646 |
|
s->has_permission_error? |
1647 |
|
"<font color='#ff0000'>": |
1648 |
|
"<font>", |
1649 |
stat_buf.st_mode & 07777); |
stat_buf.st_mode & 07777); |
1650 |
{ |
{ |
1651 |
Mail_T r; |
Mail_T r; |