Copyright (C) 2011-2013 Jim Pingle Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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"); require_once("pkg-utils.inc"); require_once("util.inc"); global $pfs_version; $pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3); if ($pfs_version == "2.1" || $pfs_version == "2.2") { define('NRPE_BASE', '/usr/pbi/nrpe-' . php_uname("m")); } else { define('NRPE_BASE', '/usr/local'); } if ($pfs_version == "2.1") { define('NRPE_BINARY', NRPE_BASE . "/sbin/nrpe2"); } else { define('NRPE_BINARY', "/usr/local/sbin/nrpe2"); } define('NRPE_CONFIG_DIR', NRPE_BASE . '/etc'); define('NRPE_RCFILE', '/usr/local/etc/rc.d/nrpe2.sh'); function nrpe2_custom_php_install_command() { global $config; /* Create default commands configuration */ if (!is_array($config['installedpackages']['nrpe2']['config'][0]['row'])) { $config['installedpackages']['nrpe2']['config'][0]['row'] = array( 0 => array( 'name' => 'check_users', 'command' => 'check_users', 'warning' => '5', 'critical' => '10' ), 1 => array( 'name' => 'check_load', 'command' => 'check_load', 'warning' => '15,10,5', 'critical' => '30,25,20', ), 2 => array( 'name' => 'check_root', 'command' => 'check_disk', 'warning' => '20%', 'critical' => '10%', 'extra' => '-p /' ), 3 => array( 'name' => 'check_var', 'command' => 'check_disk', 'warning' => '20%', 'critical' => '10%', 'extra' => '-p /var/run' ), 4 => array( 'name' => 'check_zombie_procs', 'command' => 'check_procs', 'warning' => '5', 'critical' => '10', 'extra' => '-s Z' ), 5 => array( 'name' => 'check_total_procs', 'command' => 'check_procs', 'warning' => '150', 'critical' => '200' ) ); } /* Remove the rc script installed with the package */ unlink_if_exists(NRPE_CONFIG_DIR . '/rc.d/nrpe2'); } function nrpe2_custom_php_deinstall_command() { unlink_if_exists(NRPE_RCFILE); } function nrpe2_write_rc_file() { $NRPE_CONFIG_DIR = NRPE_CONFIG_DIR; $NRPE2_BINARY = NRPE_BINARY; $fd = fopen(NRPE_RCFILE, 'w'); $rc_file = <<