446 |
if(s->start) { |
if(s->start) { |
447 |
LOCK(s->mutex) |
LOCK(s->mutex) |
448 |
check_service(name, action); |
check_service(name, action); |
449 |
|
if(s->type==TYPE_PROCESS) { |
450 |
|
/* Wait for the service to start (or fail) */ |
451 |
|
int max_tries= Run.polltime; |
452 |
|
while(max_tries-- && !Run.stopped) { |
453 |
|
if(is_process_running(s)) |
454 |
|
break; |
455 |
|
sleep(1); |
456 |
|
} |
457 |
|
} |
458 |
END_LOCK; |
END_LOCK; |
459 |
|
if(s->type==TYPE_PROCESS && !is_process_running(s)) { |
460 |
|
send_error(res, SC_INTERNAL_SERVER_ERROR, |
461 |
|
"Could not start the service"); |
462 |
|
goto quit; |
463 |
|
} |
464 |
} else { |
} else { |
465 |
send_error(res, SC_BAD_REQUEST, |
send_error(res, SC_BAD_REQUEST, |
466 |
"Start method not defined for the service"); |
"Start method not defined for the service"); |
611 |
break; |
break; |
612 |
|
|
613 |
case TYPE_DEVICE: |
case TYPE_DEVICE: |
614 |
if(DeviceInfo_Usage(s->devinfo, s->path) && stat(s->path, &stat_buf) == 0 ) { |
if(DeviceInfo_Usage(s->devinfo, s->path) && |
615 |
|
stat(s->path, &stat_buf) == 0 ) { |
616 |
|
|
617 |
if(s->devinfo->f_files > 0) { |
if(s->devinfo->f_files > 0) { |
618 |
|
|
631 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
632 |
"GID error": |
"GID error": |
633 |
"is accessible", |
"is accessible", |
634 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) 100 * |
635 |
s->devinfo->f_blocks, |
(s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
636 |
|
s->devinfo->f_blocks, |
637 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
638 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
639 |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
(float) 100 * (s->devinfo->f_files - s->devinfo->f_filesfree) / |
658 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
659 |
"GID error": |
"GID error": |
660 |
"is accessible", |
"is accessible", |
661 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) 100 * |
662 |
|
(s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
663 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
664 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
665 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
685 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
686 |
"GID error": |
"GID error": |
687 |
"is accessible", |
"is accessible", |
688 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) 100 * |
689 |
|
(s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
690 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
691 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
692 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
707 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
708 |
"GID error": |
"GID error": |
709 |
"is accessible", |
"is accessible", |
710 |
(float) 100 * (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) 100 * |
711 |
|
(s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
712 |
s->devinfo->f_blocks, |
s->devinfo->f_blocks, |
713 |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
(float) (s->devinfo->f_blocks - s->devinfo->f_blocksfreetotal) / |
714 |
1048576 * s->devinfo->f_bsize, |
1048576 * s->devinfo->f_bsize, |
748 |
s->name, |
s->name, |
749 |
(s->perm&&s->perm->has_error)? |
(s->perm&&s->perm->has_error)? |
750 |
"permission error": |
"permission error": |
|
(s->checksum&&s->checksum->has_error)? |
|
|
"checksum error": |
|
751 |
(s->uid&&s->uid->has_error)? |
(s->uid&&s->uid->has_error)? |
752 |
"UID error": |
"UID error": |
753 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
754 |
"GID error": |
"GID error": |
755 |
"exist", |
"exist", |
756 |
(unsigned long)stat_buf.st_size, (int)stat_buf.st_uid, (int)stat_buf.st_gid, |
(unsigned long)stat_buf.st_size, (int)stat_buf.st_uid, |
757 |
|
(int)stat_buf.st_gid, |
758 |
(int)(stat_buf.st_mode & 07777), |
(int)(stat_buf.st_mode & 07777), |
759 |
statusnames[s->do_monitor]); |
statusnames[s->do_monitor]); |
760 |
|
|
767 |
s->name, |
s->name, |
768 |
(s->perm&&s->perm->has_error)? |
(s->perm&&s->perm->has_error)? |
769 |
"permission error": |
"permission error": |
|
(s->checksum&&s->checksum->has_error)? |
|
|
"checksum error": |
|
770 |
(s->uid&&s->uid->has_error)? |
(s->uid&&s->uid->has_error)? |
771 |
"UID error": |
"UID error": |
772 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
1150 |
s->name, s->name, |
s->name, s->name, |
1151 |
(s->perm&&s->perm->has_error)? |
(s->perm&&s->perm->has_error)? |
1152 |
"<font color='#ff0000'>Permission Error</font>": |
"<font color='#ff0000'>Permission Error</font>": |
|
(s->checksum&&s->checksum->has_error)? |
|
|
"<font color='#ff0000'>Checksum Error</font>": |
|
1153 |
(s->uid&&s->uid->has_error)? |
(s->uid&&s->uid->has_error)? |
1154 |
"<font color='#ff0000'>UID Error</font>": |
"<font color='#ff0000'>UID Error</font>": |
1155 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
1293 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1294 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1295 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
|
1296 |
} |
} |
1297 |
if(s->stop) { |
if(s->stop) { |
1298 |
int i = 0; |
int i = 0; |
1301 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1302 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1303 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
|
1304 |
} |
} |
1305 |
if(s->perm) |
if(s->perm) |
1306 |
out_print(res, "<tr><td>Associated permission</a></td><td>if failed %o then %s</td></tr>", |
out_print(res, "<tr><td>Associated permission</a></td><td>if failed %o then %s</td></tr>", |
1343 |
out_print(res, |
out_print(res, |
1344 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1345 |
s->every?s->every:1); |
s->every?s->every:1); |
1346 |
out_print(res, |
if(s->def_timeout) { |
1347 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
out_print(res, |
1348 |
"</td></tr>", s->to_start, s->to_cycle); |
"<tr><td>Timeout</a></td><td>" |
1349 |
|
"Timeout if %d restart within %d cycles</td></tr>", |
1350 |
|
s->to_start, s->to_cycle); |
1351 |
|
} |
1352 |
{ |
{ |
1353 |
|
|
1354 |
Device_T dl; |
Device_T dl; |
1551 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1552 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1553 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
|
1554 |
} |
} |
1555 |
if(s->stop) { |
if(s->stop) { |
1556 |
int i = 0; |
int i = 0; |
1559 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1560 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1561 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
|
1562 |
} |
} |
1563 |
{ |
{ |
1564 |
Dependant_T d; |
Dependant_T d; |
1589 |
} |
} |
1590 |
} |
} |
1591 |
if(s->perm) |
if(s->perm) |
1592 |
out_print(res, "<tr><td>Associated permission</a></td><td>if failed %o then %s</td></tr>", |
out_print(res, |
1593 |
s->perm->perm, actionnames[s->perm->action]); |
"<tr><td>Associated permission</a></td><td>" |
1594 |
|
"if failed %o then %s</td></tr>", |
1595 |
|
s->perm->perm, actionnames[s->perm->action]); |
1596 |
if(s->uid) |
if(s->uid) |
1597 |
out_print(res, "<tr><td>Associated UID</a></td><td>if failed %d then %s</td></tr>", |
out_print(res, "<tr><td>Associated UID</a></td><td>" |
1598 |
(int)s->uid->uid, actionnames[s->uid->action]); |
"if failed %d then %s</td></tr>", |
1599 |
|
(int)s->uid->uid, actionnames[s->uid->action]); |
1600 |
if(s->gid) |
if(s->gid) |
1601 |
out_print(res, "<tr><td>Associated GID</a></td><td>if failed %d then %s</td></tr>", |
out_print(res, "<tr><td>Associated GID</a></td><td>" |
1602 |
(int)s->gid->gid, actionnames[s->gid->action]); |
"if failed %d then %s</td></tr>", |
1603 |
|
(int)s->gid->gid, actionnames[s->gid->action]); |
1604 |
out_print(res, |
out_print(res, |
1605 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1606 |
s->every?s->every:1); |
s->every?s->every:1); |
1607 |
out_print(res, |
if(s->def_timeout) { |
1608 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
out_print(res, |
1609 |
"</td></tr>", s->to_start, s->to_cycle); |
"<tr><td>Timeout</a></td><td>" |
1610 |
|
"Timeout if %d restart within %d cycles</td></tr>", |
1611 |
|
s->to_start, s->to_cycle); |
1612 |
|
} |
1613 |
out_print(res, |
out_print(res, |
1614 |
"<tr><td>Permission</a></td><td>%s%o</font></td></tr>", |
"<tr><td>Permission</a></td><td>%s%o</font></td></tr>", |
1615 |
(s->perm&&s->perm->has_error)? |
(s->perm&&s->perm->has_error)? |
1728 |
"<tr><td>File status</a></td><td>%s</td></tr>", |
"<tr><td>File status</a></td><td>%s</td></tr>", |
1729 |
(s->perm&&s->perm->has_error)? |
(s->perm&&s->perm->has_error)? |
1730 |
"<font color='#ff0000'>Permission Error</font>": |
"<font color='#ff0000'>Permission Error</font>": |
|
(s->checksum&&s->checksum->has_error)? |
|
|
"<font color='#ff0000'>Checksum Error</font>": |
|
1731 |
(s->uid&&s->uid->has_error)? |
(s->uid&&s->uid->has_error)? |
1732 |
"<font color='#ff0000'>UID Error</font>": |
"<font color='#ff0000'>UID Error</font>": |
1733 |
(s->gid&&s->gid->has_error)? |
(s->gid&&s->gid->has_error)? |
1751 |
while(s->start->arg[i]) |
while(s->start->arg[i]) |
1752 |
out_print(res, "%s ", s->start->arg[i++]); |
out_print(res, "%s ", s->start->arg[i++]); |
1753 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Start program</a></td><td>(not defined)</td></tr>"); |
|
1754 |
} |
} |
1755 |
if(s->stop) { |
if(s->stop) { |
1756 |
int i = 0; |
int i = 0; |
1759 |
while(s->stop->arg[i]) |
while(s->stop->arg[i]) |
1760 |
out_print(res, "%s ", s->stop->arg[i++]); |
out_print(res, "%s ", s->stop->arg[i++]); |
1761 |
printf("</td></tr>"); |
printf("</td></tr>"); |
|
} else { |
|
|
out_print(res, |
|
|
"<tr><td>Stop program</a></td><td>(not defined)</td></tr>"); |
|
1762 |
} |
} |
1763 |
{ |
{ |
1764 |
Dependant_T d; |
Dependant_T d; |
1806 |
} |
} |
1807 |
} |
} |
1808 |
if(s->checksum) |
if(s->checksum) |
1809 |
out_print(res, "<tr><td>Associated checksum</a></td><td>if failed %s then %s</td></tr>", |
out_print(res, "<tr><td>Associated checksum</a></td><td>" |
1810 |
s->checksum->md5, actionnames[s->checksum->action]); |
"if failed %s then %s</td></tr>", |
1811 |
|
s->checksum->md5, actionnames[s->checksum->action]); |
1812 |
if(s->perm) |
if(s->perm) |
1813 |
out_print(res, "<tr><td>Associated permission</a></td><td>if failed %o then %s</td></tr>", |
out_print(res, "<tr><td>Associated permission</a></td><td>" |
1814 |
s->perm->perm, actionnames[s->perm->action]); |
"if failed %o then %s</td></tr>", |
1815 |
|
s->perm->perm, actionnames[s->perm->action]); |
1816 |
if(s->uid) |
if(s->uid) |
1817 |
out_print(res, "<tr><td>Associated UID</a></td><td>if failed %d then %s</td></tr>", |
out_print(res, "<tr><td>Associated UID</a></td><td>" |
1818 |
(int)s->uid->uid, actionnames[s->uid->action]); |
"if failed %d then %s</td></tr>", |
1819 |
|
(int)s->uid->uid, actionnames[s->uid->action]); |
1820 |
if(s->gid) |
if(s->gid) |
1821 |
out_print(res, "<tr><td>Associated GID</a></td><td>if failed %d then %s</td></tr>", |
out_print(res, "<tr><td>Associated GID</a></td><td>" |
1822 |
(int)s->gid->gid, actionnames[s->gid->action]); |
"if failed %d then %s</td></tr>", |
1823 |
|
(int)s->gid->gid, actionnames[s->gid->action]); |
1824 |
out_print(res, |
out_print(res, |
1825 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
1826 |
s->every?s->every:1); |
s->every?s->every:1); |
1827 |
out_print(res, |
if(s->def_timeout) { |
1828 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
out_print(res, |
1829 |
"</td></tr>", s->to_start, s->to_cycle); |
"<tr><td>Timeout</a></td><td>" |
1830 |
|
"Timeout if %d restart within %d cycles</td></tr>", |
1831 |
|
s->to_start, s->to_cycle); |
1832 |
|
} |
1833 |
out_print(res, |
out_print(res, |
1834 |
"<tr><td>Size</a></td><td>%lu B</td></tr>", |
"<tr><td>Size</a></td><td>%lu B</td></tr>", |
1835 |
(unsigned long)stat_buf.st_size); |
(unsigned long)stat_buf.st_size); |
2127 |
out_print(res, |
out_print(res, |
2128 |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
"<tr><td>Check service</a></td><td>Every %d cycle</td></tr>", |
2129 |
s->every?s->every:1); |
s->every?s->every:1); |
2130 |
out_print(res, |
if(s->def_timeout) { |
2131 |
"<tr><td>Timeout</a></td><td>Timeout if %d restart within %d cycles" |
out_print(res, |
2132 |
"</td></tr>", s->to_start, s->to_cycle); |
"<tr><td>Timeout</a></td><td>" |
2133 |
|
"Timeout if %d restart within %d cycles</td></tr>", |
2134 |
|
s->to_start, s->to_cycle); |
2135 |
|
} |
2136 |
{ |
{ |
2137 |
Mail_T r; |
Mail_T r; |
2138 |
for(r= s->maillist; r; r= r->next) { |
for(r= s->maillist; r; r= r->next) { |