From 7de56f6a89ffe80e0a314b1b9f3617fd143454c4 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 9 Jun 2011 08:57:36 -0400 Subject: Accidentally missed this file for the previous commit. --- config/nrpe2/nrpe2.inc | 56 +++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'config/nrpe2') diff --git a/config/nrpe2/nrpe2.inc b/config/nrpe2/nrpe2.inc index 5f26fe56..3bc97b21 100644 --- a/config/nrpe2/nrpe2.inc +++ b/config/nrpe2/nrpe2.inc @@ -3,30 +3,31 @@ /** * Author: Erik Kristensen * Email: erik@erikkristensen.com - * + * * Developed for: pfSense.com - * + * * Copyright (c) 2009, pfSense.com * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * */ require_once('filter.inc'); -function nrpe2_custom_php_install_command() -{ +$nagios_check_path = "/usr/local/libexec/nagios"; + +function nrpe2_custom_php_install_command() { global $g, $config; conf_mount_rw(); @@ -131,25 +132,23 @@ EOD; conf_mount_ro(); } -function nrpe2_custom_php_deinstall_command() -{ +function nrpe2_custom_php_deinstall_command() { global $g, $config; conf_mount_rw(); - + conf_mount_ro(); } - -function nrpe2_custom_php_write_config() -{ - global $g, $config; + +function nrpe2_custom_php_write_config() { + global $g, $config, $nagios_check_path; conf_mount_rw(); - - foreach ($config['installedpackages']['nrpe2']['config'][0]['row'] as $cmd) - { - $cmds[] = "command[{$cmd['name']}]=/usr/local/libexec/nagios/{$cmd['command']} -w {$cmd['warning']} -c {$cmd['critical']} {$cmd['extra']}\n"; + + foreach ($config['installedpackages']['nrpe2']['config'][0]['row'] as $cmd) { + if (is_executable("{$nagios_check_path}/{$cmd['command']}")) + $cmds[] = "command[{$cmd['name']}]={$nagios_check_path}/{$cmd['command']} -w {$cmd['warning']} -c {$cmd['critical']} {$cmd['extra']}\n"; } $commands = implode($cmds); - + $server_port = $config['installedpackages']['nrpe2']['config'][0]['server_port']; $server_address = $config['installedpackages']['nrpe2']['config'][0]['server_address']; $allowed_hosts = $config['installedpackages']['nrpe2']['config'][0]['allowed_hosts']; @@ -174,18 +173,23 @@ EOD; conf_mount_ro(); } -function nrpe2_custom_php_service() -{ +function nrpe2_custom_php_service() { global $g, $config; - - if ($config['installedpackages']['nrpe2']['config'][0]['enabled'] == "on") - { + + if ($config['installedpackages']['nrpe2']['config'][0]['enabled'] == "on") { exec("/usr/local/etc/rc.d/nrpe2.sh restart"); } - else - { + else { exec("/usr/local/etc/rc.d/nrpe2.sh stop"); } } +function nrpe2_get_commands() { + global $nagios_check_path; + $commands = glob("{$nagios_check_path}/check_*"); + $cmdarr = array(); + foreach ($commands as $cmd) + $cmdarr[]["command"] = basename($cmd); + return $cmdarr; +} ?> -- cgit v1.2.3