diff --git a/check_ispconfig/README b/check_ispconfig/README new file mode 100644 index 0000000000000000000000000000000000000000..24e0f6efe0505d0378f8de7aa217aabad4746e9a --- /dev/null +++ b/check_ispconfig/README @@ -0,0 +1,20 @@ +# check_ispconfig + +Nagios compatible script to export data from the monitor page. + +Outputs a single line like: `WARNING: (ok: 12, info: system_update, warning: sys_log)` + + +## Installation + +- In an NRPE compatibe config file, such as /etc/nagios/nrpe.cfg: +`command[check_ispconfig]=/usr/bin/sudo /usr/local/ispconfig/server/scripts/check_ispconfig.php` + +- To allow an nrpe user to run this, add /etc/sudoers.d/ispconfig: +``` +Cmnd_Alias CHECK_ISPCONFIG = /usr/local/ispconfig/server/scripts/check_ispconfig.php + +nagios ALL = NOPASSWD : CHECK_ISPCONFIG +``` + +- Setup your monitoring tool of choice to call this script. diff --git a/check_ispconfig/check_ispconfig.php b/check_ispconfig/check_ispconfig.php new file mode 100755 index 0000000000000000000000000000000000000000..6d3bd9141081e7bc0a06b69a63fd74293235b710 --- /dev/null +++ b/check_ispconfig/check_ispconfig.php @@ -0,0 +1,92 @@ +#!/usr/bin/env php +dbmaster->queryAllRecords("SELECT DISTINCT type, state FROM monitor_data + WHERE server_id = ? AND state != 'no_state'", $conf['server_id']); + +foreach($records as $record) { + $server_states[$record['state']][] = $record['type']; +} + +foreach ($server_states as $state => $data) { + if ($state == 'ok') { + $state_list[] = "$state: " . count($data); + } + else { + $state_list[] = "$state: " . join(', ', $data); + } +} +if (empty($server_states)) { + $server_state = 'unknown'; + $retval = 3; +} +elseif (is_array($server_states['critical']) && count($server_states['critical']) > 0 || is_array($server_states['error']) && count($server_states['error']) > 0) { + $server_state = 'critical'; + $retval = 2; +} +elseif ($server_states['warning'] > 0) { + $server_state = 'warning'; + $retval = 1; +} + +$status_line = strtoupper($server_state) . ': (' . join(', ', $state_list) . ')'; + +echo $status_line . PHP_EOL; +exit($retval);