diff options
-rw-r--r-- | config/procwatch/procwatch.inc | 39 | ||||
-rw-r--r-- | config/procwatch/procwatch_cron.php | 6 | ||||
-rw-r--r-- | config/servicewatchdog/services_servicewatchdog.php (renamed from config/procwatch/services_procwatch.php) | 44 | ||||
-rw-r--r-- | config/servicewatchdog/services_servicewatchdog_add.php (renamed from config/procwatch/services_procwatch_add.php) | 26 | ||||
-rw-r--r-- | config/servicewatchdog/servicewatchdog.inc | 39 | ||||
-rw-r--r-- | config/servicewatchdog/servicewatchdog.xml (renamed from config/procwatch/procwatch.xml) | 22 | ||||
-rw-r--r-- | config/servicewatchdog/servicewatchdog_cron.php | 6 | ||||
-rw-r--r-- | pkg_config.8.xml | 6 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 6 |
9 files changed, 97 insertions, 97 deletions
diff --git a/config/procwatch/procwatch.inc b/config/procwatch/procwatch.inc deleted file mode 100644 index b2210e03..00000000 --- a/config/procwatch/procwatch.inc +++ /dev/null @@ -1,39 +0,0 @@ -<?php -require_once("config.inc"); -require_once("services.inc"); -require_once("service-utils.inc"); -require_once("util.inc"); - -function procwatch_cron_job() { - global $config; - if (!is_array($config['installedpackages']['procwatch']['item'])) { - $config['installedpackages']['procwatch']['item'] = array(); - } - $a_pwservices = &$config['installedpackages']['procwatch']['item']; - - if (count($a_pwservices) > 0) { - // Add the cron job if it doesn't exist. - install_cron_job("/usr/local/pkg/procwatch_cron.php", true, "*/1"); - } else { - // Remove the cron job - install_cron_job("/usr/local/pkg/procwatch_cron.php", false, "*/1"); - } -} - -function procwatch_check_services() { - global $config; - if (!is_array($config['installedpackages']['procwatch']['item'])) { - $config['installedpackages']['procwatch']['item'] = array(); - } - $a_pwservices = &$config['installedpackages']['procwatch']['item']; - - foreach ($a_pwservices as $svc) { - if (!is_service_running($svc['name'])) { - $descr = strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description']; - log_error("ProcWatch detected service {$svc['name']} stopped. Restarting {$svc['name']} ({$descr})"); - service_control_start($svc['name'], $svc); - } - } -} - -?>
\ No newline at end of file diff --git a/config/procwatch/procwatch_cron.php b/config/procwatch/procwatch_cron.php deleted file mode 100644 index f4cc7608..00000000 --- a/config/procwatch/procwatch_cron.php +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/local/bin/php -f -<?php -require_once("procwatch.inc"); - -procwatch_check_services(); -?>
\ No newline at end of file diff --git a/config/procwatch/services_procwatch.php b/config/servicewatchdog/services_servicewatchdog.php index c8a16b07..920fd1bb 100644 --- a/config/procwatch/services_procwatch.php +++ b/config/servicewatchdog/services_servicewatchdog.php @@ -1,6 +1,6 @@ <?php /* - services_procwatch.php + services_servicewatchdog.php Copyright (C) 2013 Jim Pingle All rights reserved. @@ -30,21 +30,21 @@ */ ##|+PRIV -##|*IDENT=page-services-procwatch -##|*NAME=Services: ProcWatch -##|*DESCR=Allow access to the 'Services: ProcWatch' page. -##|*MATCH=services_procwatch.php* +##|*IDENT=page-services-servicewatchdog +##|*NAME=Services: Service Watchdog +##|*DESCR=Allow access to the 'Services: Service Watchdog' page. +##|*MATCH=services_servicewatchdog.php* ##|-PRIV require("guiconfig.inc"); require_once("functions.inc"); require_once("service-utils.inc"); -require_once("procwatch.inc"); +require_once("servicewatchdog.inc"); -if (!is_array($config['installedpackages']['procwatch']['item'])) - $config['installedpackages']['procwatch']['item'] = array(); +if (!is_array($config['installedpackages']['servicewatchdog']['item'])) + $config['installedpackages']['servicewatchdog']['item'] = array(); -$a_pwservices = &$config['installedpackages']['procwatch']['item']; +$a_pwservices = &$config['installedpackages']['servicewatchdog']['item']; /* if a custom message has been passed along, lets process it */ if ($_GET['savemsg']) @@ -53,9 +53,9 @@ if ($_GET['savemsg']) if ($_GET['act'] == "del") { if ($a_pwservices[$_GET['id']]) { unset($a_pwservices[$_GET['id']]); - procwatch_cron_job(); + servicewatchdog_cron_job(); write_config(); - header("Location: services_procwatch.php"); + header("Location: services_servicewatchdog.php"); exit; } } @@ -66,9 +66,9 @@ if (isset($_POST['del_x'])) { foreach ($_POST['pwservices'] as $servicei) { unset($a_pwservices[$servicei]); } - procwatch_cron_job(); + servicewatchdog_cron_job(); write_config(); - header("Location: services_procwatch.php"); + header("Location: services_servicewatchdog.php"); exit; } } else { @@ -108,15 +108,15 @@ if (isset($_POST['del_x'])) { $a_pwservices_new[] = $a_pwservices[$i]; } $a_pwservices = $a_pwservices_new; - procwatch_cron_job(); + servicewatchdog_cron_job(); write_config(); - header("Location: services_procwatch.php"); + header("Location: services_servicewatchdog.php"); return; } } $closehead = false; -$pgtitle = array(gettext("Services"),gettext("ProcWatch")); +$pgtitle = array(gettext("Services"),gettext("Service Watchdog")); include("head.inc"); ?> @@ -129,7 +129,7 @@ include("head.inc"); </head> <body link="#000000" vlink="#000000" alink="#000000"> <?php include("fbegin.inc"); ?> -<form action="services_procwatch.php" method="post" name="iform"> +<form action="services_servicewatchdog.php" method="post" name="iform"> <script type="text/javascript" language="javascript" src="/javascript/row_toggle.js"></script> <?php if ($savemsg) print_info_box($savemsg); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="services to monitor"> @@ -152,7 +152,7 @@ include("head.inc"); <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" /> <?php endif; ?> </td> - <td><a href="services_procwatch_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td> + <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td> </tr> </table> </td> @@ -164,17 +164,17 @@ foreach ($a_pwservices as $thisservice): ?> <tr valign="top" id="fr<?=$nservices;?>"> <td class="listt"><input type="checkbox" id="frc<?=$nservices;?>" name="pwservices[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nservices;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /></td> - <td class="listlr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_procwatch_add.php?id=<?=$nservices;?>';"> + <td class="listlr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';"> <?=$thisservice['name'];?> </td> - <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_procwatch_add.php?id=<?=$nservices;?>';"> + <td class="listr" onclick="fr_toggle(<?=$nservices;?>)" id="frd<?=$nservices;?>" ondblclick="document.location='services_servicewatchdog_add.php?id=<?=$nservices;?>';"> <?=$thisservice['description'];?> </td> <td valign="middle" class="list" nowrap> <table border="0" cellspacing="0" cellpadding="1" summary="add"> <tr> <td><input onmouseover="fr_insline(<?=$nservices;?>, true)" onmouseout="fr_insline(<?=$nservices;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected services before this service");?>" height="17" type="image" width="17" border="0" /></td> - <td align="center" valign="middle"><a href="services_procwatch.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this service?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete service");?>" alt="delete" /></a></td> + <td align="center" valign="middle"><a href="services_servicewatchdog.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this service?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete service");?>" alt="delete" /></a></td> </tr> </table> </td></tr> @@ -194,7 +194,7 @@ foreach ($a_pwservices as $thisservice): <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="<?=gettext("delete selected services"); ?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected services?");?>')" /> <?php endif; ?> </td> - <td><a href="services_procwatch_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td> + <td><a href="services_servicewatchdog_add.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new service"); ?>" alt="add" /></a></td> </tr> </table> </td> diff --git a/config/procwatch/services_procwatch_add.php b/config/servicewatchdog/services_servicewatchdog_add.php index 457a93a4..e5335540 100644 --- a/config/procwatch/services_procwatch_add.php +++ b/config/servicewatchdog/services_servicewatchdog_add.php @@ -1,6 +1,6 @@ <?php /* - services_procwatch_add.php + services_servicewatchdog_add.php Copyright (C) 2013 Jim Pingle All rights reserved. @@ -30,20 +30,20 @@ */ ##|+PRIV -##|*IDENT=page-services-procwatch-add -##|*NAME=Services: Add ProcWatch Services -##|*DESCR=Allow access to the 'Add ProcWatch Services' page. -##|*MATCH=services_procwatch.php-add* +##|*IDENT=page-services-servicewatchdog-add +##|*NAME=Services: Add Service Watchdog Services +##|*DESCR=Allow access to the 'Add Service Watchdog Services' page. +##|*MATCH=services_servicewatchdog.php-add* ##|-PRIV require("guiconfig.inc"); require_once("service-utils.inc"); -require_once("procwatch.inc"); +require_once("servicewatchdog.inc"); -if (!is_array($config['installedpackages']['procwatch']['item'])) { - $config['installedpackages']['procwatch']['item'] = array(); +if (!is_array($config['installedpackages']['servicewatchdog']['item'])) { + $config['installedpackages']['servicewatchdog']['item'] = array(); } -$a_pwservices = &$config['installedpackages']['procwatch']['item']; +$a_pwservices = &$config['installedpackages']['servicewatchdog']['item']; $a_pwservice_names = array(); foreach ($a_pwservices as $svc) { $a_pwservice_names[] = $svc['name']; @@ -62,16 +62,16 @@ if ($_POST) { if (!$input_errors) { $a_pwservices[] = $system_services[$_POST['svcid']]; - procwatch_cron_job(); + servicewatchdog_cron_job(); write_config(); - header("Location: services_procwatch.php"); + header("Location: services_servicewatchdog.php"); return; } } $closehead = false; -$pgtitle = array(gettext("Services"),gettext("ProcWatch"), gettext("Add")); +$pgtitle = array(gettext("Services"),gettext("servicewatchdog"), gettext("Add")); include("head.inc"); ?> @@ -83,7 +83,7 @@ include("head.inc"); <?php include("fbegin.inc"); ?> <?php if ($input_errors) print_input_errors($input_errors); ?> -<form action="services_procwatch_add.php" method="post" name="iform" id="iform"> +<form action="services_servicewatchdog_add.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="add monitored service"> <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Add Service Entry"); ?></td> diff --git a/config/servicewatchdog/servicewatchdog.inc b/config/servicewatchdog/servicewatchdog.inc new file mode 100644 index 00000000..d96a0f75 --- /dev/null +++ b/config/servicewatchdog/servicewatchdog.inc @@ -0,0 +1,39 @@ +<?php +require_once("config.inc"); +require_once("services.inc"); +require_once("service-utils.inc"); +require_once("util.inc"); + +function servicewatchdog_cron_job() { + global $config; + if (!is_array($config['installedpackages']['servicewatchdog']['item'])) { + $config['installedpackages']['servicewatchdog']['item'] = array(); + } + $a_pwservices = &$config['installedpackages']['servicewatchdog']['item']; + + if (count($a_pwservices) > 0) { + // Add the cron job if it doesn't exist. + install_cron_job("/usr/local/pkg/servicewatchdog_cron.php", true, "*/1"); + } else { + // Remove the cron job + install_cron_job("/usr/local/pkg/servicewatchdog_cron.php", false, "*/1"); + } +} + +function servicewatchdog_check_services() { + global $config; + if (!is_array($config['installedpackages']['servicewatchdog']['item'])) { + $config['installedpackages']['servicewatchdog']['item'] = array(); + } + $a_pwservices = &$config['installedpackages']['servicewatchdog']['item']; + + foreach ($a_pwservices as $svc) { + if (!is_service_running($svc['name'])) { + $descr = strlen($svc['description']) > 50 ? substr($svc['description'], 0, 50) . "..." : $svc['description']; + log_error("Service Watchdog detected service {$svc['name']} stopped. Restarting {$svc['name']} ({$descr})"); + service_control_start($svc['name'], $svc); + } + } +} + +?>
\ No newline at end of file diff --git a/config/procwatch/procwatch.xml b/config/servicewatchdog/servicewatchdog.xml index 9db6d40d..70ecffe8 100644 --- a/config/procwatch/procwatch.xml +++ b/config/servicewatchdog/servicewatchdog.xml @@ -6,7 +6,7 @@ <![CDATA[ /* ========================================================================== */ /* - procwatch.xml + servicewatchdog.xml part of pfSense (http://www.pfSense.com) Copyright (C) 2013 Jim Pingle All rights reserved. @@ -36,37 +36,37 @@ /* ========================================================================== */ ]]> </copyright> - <description>ProcWatch</description> + <description>Service Watchdog</description> <requirements>None</requirements> <faq>Monitors for stopped services and restarts them.</faq> - <name>ProcWatch</name> + <name>Service Watchdog</name> <version>1.0</version> - <title>Services: Procwatch</title> - <include_file>/usr/local/pkg/procwatch.inc</include_file> + <title>Services: Service Watchdog</title> + <include_file>/usr/local/pkg/servicewatchdog.inc</include_file> <menu> - <name>ProcWatch</name> + <name>Service Watchdog</name> <tooltiptext></tooltiptext> <section>Services</section> - <url>/services_procwatch.php</url> + <url>/services_servicewatchdog.php</url> </menu> <additional_files_needed> <prefix>/usr/local/www/</prefix> <chmod>644</chmod> - <item>http://www.pfsense.com/packages/config/procwatch/services_procwatch.php</item> + <item>http://www.pfsense.com/packages/config/servicewatchdog/services_servicewatchdog.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/www/</prefix> <chmod>644</chmod> - <item>http://www.pfsense.com/packages/config/procwatch/services_procwatch_add.php</item> + <item>http://www.pfsense.com/packages/config/servicewatchdog/services_servicewatchdog_add.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> <chmod>755</chmod> - <item>http://www.pfsense.com/packages/config/procwatch/procwatch_cron.php</item> + <item>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog_cron.php</item> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> <chmod>644</chmod> - <item>http://www.pfsense.com/packages/config/procwatch/procwatch.inc</item> + <item>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.inc</item> </additional_files_needed> </packagegui>
\ No newline at end of file diff --git a/config/servicewatchdog/servicewatchdog_cron.php b/config/servicewatchdog/servicewatchdog_cron.php new file mode 100644 index 00000000..5031ab0b --- /dev/null +++ b/config/servicewatchdog/servicewatchdog_cron.php @@ -0,0 +1,6 @@ +#!/usr/local/bin/php -f +<?php +require_once("servicewatchdog.inc"); + +servicewatchdog_check_services(); +?>
\ No newline at end of file diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 6cf0d4b5..a6521070 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1951,16 +1951,16 @@ <depends_on_package_pbi>sudo-1.8.6p8-i386.pbi</depends_on_package_pbi> </package> <package> - <name>ProcWatch</name> + <name>Service Watchdog</name> <descr>Monitors for stopped services and restarts them.</descr> <maintainer>jimp@pfsense.org</maintainer> <version>1.0</version> <category>Services</category> <status>BETA</status> - <config_file>http://www.pfsense.com/packages/config/procwatch/procwatch.xml</config_file> + <config_file>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml</config_file> <pkginfolink></pkginfolink> <required_version>2.1</required_version> - <configurationfile>procwatch.xml</configurationfile> + <configurationfile>servicewatchdog.xml</configurationfile> </package> </packages> </pfsensepkgs> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 9d390583..15ff2856 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -1938,16 +1938,16 @@ <depends_on_package_pbi>sudo-1.8.6p8-amd64.pbi</depends_on_package_pbi> </package> <package> - <name>ProcWatch</name> + <name>Service Watchdog</name> <descr>Monitors for stopped services and restarts them.</descr> <maintainer>jimp@pfsense.org</maintainer> <version>1.0</version> <category>Services</category> <status>BETA</status> - <config_file>http://www.pfsense.com/packages/config/procwatch/procwatch.xml</config_file> + <config_file>http://www.pfsense.com/packages/config/servicewatchdog/servicewatchdog.xml</config_file> <pkginfolink></pkginfolink> <required_version>2.1</required_version> - <configurationfile>procwatch.xml</configurationfile> + <configurationfile>servicewatchdog.xml</configurationfile> </package> </packages> </pfsensepkgs> |