mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Dynamic use of nagios-service checks
This commit is contained in:
@@ -31,8 +31,16 @@ foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.devi
|
|||||||
include $checker_script;
|
include $checker_script;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$status = '2';
|
$cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
|
||||||
$check = "Error : Script not found ($checker_script)";
|
$cmd .= " ".$service['service_param'];
|
||||||
|
$check = shell_exec($cmd);
|
||||||
|
list($check, $time) = split("\|", $check);
|
||||||
|
if(stristr($check, "ok -")) {
|
||||||
|
$status = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$status = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$update = array();
|
$update = array();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ else {
|
|||||||
$updated = '1';
|
$updated = '1';
|
||||||
|
|
||||||
// FIXME should call add_service (needs more parameters)
|
// FIXME should call add_service (needs more parameters)
|
||||||
$service_id = dbInsert(array('device_id' => $_POST['device'], 'service_ip' => $_POST['ip'], 'service_type' => $_POST['type'], 'service_desc' => $_POST['descr'], 'service_param' => $_POST['params'], 'service_ignore' => '0'), 'services');
|
$service_id = dbInsert(array('device_id' => $_POST['device'], 'service_ip' => $_POST['ip'], 'service_type' => $_POST['type'], 'service_desc' => $_POST['descr'], 'service_param' => $_POST['params'], 'service_ignore' => '0', 'service_status' => '0', 'service_checked' => '0', 'service_changed' => '0', 'service_message' => 'New check', 'service_disabled' => '0'), 'services');
|
||||||
|
|
||||||
if ($service_id) {
|
if ($service_id) {
|
||||||
$message .= $message_break.'Service added ('.$service_id.')!';
|
$message .= $message_break.'Service added ('.$service_id.')!';
|
||||||
@@ -18,10 +18,11 @@ else {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($handle = opendir($config['install_dir'].'/includes/services/')) {
|
if ($handle = opendir($config['nagios_plugins'])) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
if ($file != '.' && $file != '..' && !strstr($file, '.')) {
|
if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
|
||||||
$servicesform .= "<option value='$file'>$file</option>";
|
list(,$check_name) = explode('_',$file);
|
||||||
|
$servicesform .= "<option value='$check_name'>$check_name</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user