mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
- Use Nagios alerting: 0 = Ok, 1 = Warning, 2 = Critical
- Update documentation - Moved SQL for upstream changes
This commit is contained in:
parent
854812a457
commit
eeb3dff393
@ -22,17 +22,24 @@ $config['nagios_plugins'] = "/usr/lib/nagios/plugins";
|
||||
|
||||
This will point LibreNMS at the location of the nagios plugins - please ensure that any plugins you use are set to executable.
|
||||
|
||||
Finally, you now need to add check-services.php to the current cron file (/etc/cron.d/librenms typically) like:
|
||||
```bash
|
||||
*/5 * * * * librenms /opt/librenms/check-services.php >> /dev/null 2>&1
|
||||
```
|
||||
|
||||
Now you can add services via the main Services link in the navbar, or via the 'Add Service' link within the device, services page.
|
||||
|
||||
## Performance data
|
||||
|
||||
By default, the poller module will collect all performance data that the check script returns and display each datasource on a separate graph.
|
||||
By default, the check-services script will collect all performance data that the Nagios script returns and display each datasource on a separate graph.
|
||||
However for some modules it would be better if some of this information was consolidated on a single graph.
|
||||
An example is the ICMP check. This check returns: Round Trip Average (rta), Round Trip Min (rtmin) and Round Trip Max (rtmax).
|
||||
These have been combined onto a single graph.
|
||||
|
||||
If you find a check script that would benefit from having some datasources graphed together, please log an issue on GitHub with the debug information from the poller, and let us know which DS's should go together. Example below:
|
||||
If you find a check script that would benefit from having some datasources graphed together, please log an issue on GitHub with the debug information from the script, and let us know which DS's should go together. Example below:
|
||||
|
||||
./check-services.php -d
|
||||
-- snip --
|
||||
Nagios Service - 26
|
||||
Request: /usr/lib/nagios/plugins/check_icmp localhost
|
||||
Perf Data - DS: rta, Value: 0.016, UOM: ms
|
||||
@ -48,3 +55,16 @@ If you find a check script that would benefit from having some datasources graph
|
||||
}
|
||||
OK u:0.00 s:0.00 r:40.67
|
||||
RRD[update /opt/librenms/rrd/localhost/services-26.rrd N:0.016:0:0.044:0.009]
|
||||
-- snip --
|
||||
|
||||
## Alerting
|
||||
|
||||
Services uses the Nagios Alerting scheme where:
|
||||
|
||||
0 = Ok,
|
||||
1 = Warning,
|
||||
2 = Critical,
|
||||
|
||||
To create an alerting rule to alert on service=critical, your alerting rule would look like:
|
||||
|
||||
%services.service_status = "2"
|
||||
|
@ -219,13 +219,13 @@ if ($config['show_services']) {
|
||||
|
||||
<?php
|
||||
|
||||
if (($service_status[0] > 0) || ($service_status[2] > 0)) {
|
||||
if (($service_status[1] > 0) || ($service_status[2] > 0)) {
|
||||
echo ' <li role="presentation" class="divider"></li>';
|
||||
if ($service_status[2] > 0) {
|
||||
echo ' <li><a href="services/state=warning/"><i class="fa fa-bell-o fa-col-warning fa-fw fa-lg"></i> Warning ('.$service_status[2].')</a></li>';
|
||||
if ($service_status[1] > 0) {
|
||||
echo ' <li><a href="services/state=warning/"><i class="fa fa-bell-o fa-col-warning fa-fw fa-lg"></i> Warning ('.$service_status[1].')</a></li>';
|
||||
}
|
||||
if ($service_status[0] > 0) {
|
||||
echo ' <li><a href="services/state=critical/"><i class="fa fa-bell-o fa-col-danger fa-fw fa-lg"></i> Critical ('.$service_status[0].')</a></li>';
|
||||
if ($service_status[2] > 0) {
|
||||
echo ' <li><a href="services/state=critical/"><i class="fa fa-bell-o fa-col-danger fa-fw fa-lg"></i> Critical ('.$service_status[2].')</a></li>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,13 +51,13 @@ if (count($services) > '0') {
|
||||
<?php
|
||||
foreach ($services as $service) {
|
||||
$service['service_ds'] = htmlspecialchars_decode($service['service_ds']);
|
||||
if ($service['service_status'] == 1) {
|
||||
if ($service['service_status'] == 0) {
|
||||
$status = "<span class='green'>Ok</span>";
|
||||
}
|
||||
elseif ($service['service_status'] == 2) {
|
||||
elseif ($service['service_status'] == 1) {
|
||||
$status = "<span class='red'>Warning</span>";
|
||||
}
|
||||
elseif ($service['service_status'] == 0) {
|
||||
elseif ($service['service_status'] == 2) {
|
||||
$status = "<span class='red'>Critical</span>";
|
||||
}
|
||||
else {
|
||||
|
@ -74,14 +74,14 @@ print_optionbar_end();
|
||||
$sql_param = array();
|
||||
if (isset($vars['state'])) {
|
||||
if ($vars['state'] == 'ok') {
|
||||
$state = '1';
|
||||
}
|
||||
elseif ($vars['state'] == 'critical') {
|
||||
$state = '0';
|
||||
}
|
||||
elseif ($vars['state'] == 'warning') {
|
||||
elseif ($vars['state'] == 'critical') {
|
||||
$state = '2';
|
||||
}
|
||||
elseif ($vars['state'] == 'warning') {
|
||||
$state = '1';
|
||||
}
|
||||
}
|
||||
if (isset($state)) {
|
||||
$where .= " AND service_status= ? AND service_disabled='0' AND `service_ignore`='0'";
|
||||
@ -123,10 +123,10 @@ foreach (dbFetchRows($host_sql, $host_par) as $device) {
|
||||
}
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service) {
|
||||
if ($service['service_status'] == '0') {
|
||||
if ($service['service_status'] == '2') {
|
||||
$status = "<span class='red'><b>".$service['service_type']."</b></span>";
|
||||
}
|
||||
else if ($service['service_status'] == '1') {
|
||||
else if ($service['service_status'] == '0') {
|
||||
$status = "<span class='green'><b>".$service['service_type']."</b></span>";
|
||||
}
|
||||
else {
|
||||
|
@ -128,28 +128,9 @@ function poll_service($service) {
|
||||
// Some debugging
|
||||
d_echo("\nNagios Service - ".$service['service_id']."\n");
|
||||
d_echo("Request: ".$check_cmd."\n");
|
||||
list($status, $msg, $perf) = check_service($check_cmd);
|
||||
list($new_status, $msg, $perf) = check_service($check_cmd);
|
||||
d_echo("Response: ".$msg."\n");
|
||||
|
||||
// TODO: Use proper Nagios service status. 0=Ok,1=Warning,2=Critical,Else=Unknown
|
||||
// Not now because we dont want to break existing alerting rules.
|
||||
if ($status == 0) {
|
||||
// Nagios 0 = Libre 1 - Ok
|
||||
$new_status = 1;
|
||||
}
|
||||
elseif ($status == 1) {
|
||||
// Nagios 1 = Libre 2 - Warning
|
||||
$new_status = 2;
|
||||
}
|
||||
elseif ($status == 2) {
|
||||
// Nagios 2 = Libre 0 - Critical
|
||||
$new_status = 0;
|
||||
}
|
||||
else {
|
||||
// Unknown
|
||||
$new_status = 2;
|
||||
}
|
||||
|
||||
// If we have performance data we will store it.
|
||||
if (count($perf) > 0) {
|
||||
// Yes, We have perf data.
|
||||
|
Loading…
Reference in New Issue
Block a user