From 5da8e70bf48b6f5bd4f7eee6e62344de9dcbb752 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Thu, 15 Jun 2023 09:06:28 -0500 Subject: [PATCH] add Sneck support, making it very trivial to use Nagios style checks in a NRPE like manner (#13954) * code stuff done for Sneck * whoops, correct the abs value post adding it post rrd update * return a array for getting the sneck data and nicely print the raw return value * add test stuff and freeze time at 1650911765 for tests * move the freezeTime * add use Illuminate\Support\Carbon; * more test changes * rework freezeTime a bit more * more test stuff * another test * rework it a bit again * correct variable spelling for $time_diff * remove freezeTime as we are using a old version of Laravel * finalize graphs * misc * finalize sneck page * mve the sneck tests as it needs a newer version of laravel than we are using * add documents for sneck * finalize the poller * formatting cleanup * correct comment type * correct the spelling of description * more documentation * save the check returns as metrics * add some more examples * fix some of the sneck alerts and add a few more examples * turn off time to polling by default * suggest using ntp if enabled * since we are zeroing time_to_polling by default, this now works * backout some suggested changes for once we change to larval 9 * remove del_sneck_data as it is no longer used * add more docs on the metrics * php-cs-fixer to fix a few things * update and fix sneck tests * remote a metric from the test * another minor tweak to the test * one more minor change * ahh! derp! think I found it finally... hopefully hanging this for the last time... * now use app data * now logs check changes * add a missing ) * add a missing ) * some style fixes * update the sneck page use to the app data stuff * update the poller to use the new app data * misc * update sneck to log check status changes * correct alert log messages * correct a comment * fix metrics * derp, another fix * test fix * re-order to avoid warning * poller update * update sneck graphs * update sneck graphs * remove a unneeded line * test update for discovery * minor tweaks to the test and fix update the polling a bit * style fix * fix return data printing * fix the test data to include app data * attempted test fix * add config def to apps.sneck.polling_time_diff * cleanup docs a bit * minor config tweaks * minor doc cleanup --- doc/Extensions/Applications.md | 95 +++++++++++ .../graphs/application/sneck_results.inc.php | 45 +++++ .../graphs/application/sneck_time.inc.php | 29 ++++ includes/html/pages/apps.inc.php | 4 + includes/html/pages/device/apps/sneck.inc.php | 52 ++++++ includes/polling/applications/sneck.inc.php | 159 ++++++++++++++++++ misc/alert_rules.json | 120 +++++++++++++ misc/config_definitions.json | 4 + tests/data/linux_sneck-v1.json | 122 ++++++++++++++ tests/snmpsim/linux_sneck-v1.snmprec | 10 ++ 10 files changed, 640 insertions(+) create mode 100644 includes/html/graphs/application/sneck_results.inc.php create mode 100644 includes/html/graphs/application/sneck_time.inc.php create mode 100644 includes/html/pages/device/apps/sneck.inc.php create mode 100644 includes/polling/applications/sneck.inc.php create mode 100644 tests/data/linux_sneck-v1.json create mode 100644 tests/snmpsim/linux_sneck-v1.snmprec diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 01d198bdd7..ea28856608 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -2508,6 +2508,101 @@ Also if the system you are using uses non-static device naming based on bus information, it may be worthwhile just using the SN as the device ID is going to be irrelevant in that case. +## Sneck + +This is for replacing Nagios/Icinga or the LibreNMS service +integration in regards to NRPE. This allows LibreNMS to query what +checks were ran on the server and keep track of totals of OK, WARNING, +CRITICAL, and UNKNOWN statuses. + +The big advantage over this compared to a NRPE are as below. + +- It does not need to know what checks are configured on it. +- Also does not need to wait for the tests to run as sneck is meant to + be ran via cron and the then return the cache when queried via SNMP, + meaning a lot faster response time, especially if slow checks are + being performed. +- Works over proxied SNMP connections. + +Included are alert examples. Although for setting up custom ones, the +metrics below are provided. + +| Metric | Description | +|---------------------|-----------------------------------------------------------------------------------------------------------------------| +| ok | Total OK checks | +| warning | Total WARNING checks | +| critical | Total CRITICAL checks | +| unknown | Total UNKNOWN checks | +| errored | Total checks that errored | +| time_to_polling | Differnce in seconds between when polling data was generated and when polled | +| time_to_polling_abs | The aboslute value of time_to_polling. | +| check_$CHECK | Exit status of a specific check `$CHECK` is equal to the name of the check in question. So `foo` would be `check_foo` | + +The standard Nagios/Icinga style exit codes are used and those are as +below. + +| Exit | Meaning | +|------|----------| +| 0 | okay | +| 1 | warning | +| 2 | critical | +| 3+ | unknown | + +To use `time_to_polling`, it will need to enabled via setting the +config item below. The default is false. Unless set to true, this +value will default to 0. If enabling this, one will want to make sure +that NTP is in use every were or it will alert if it goes over a +difference of 540s. + +``` +lnms config:set app.sneck.polling_time_diff true +``` + +For more information on Sneck, check it out at +[MetaCPAN](https://metacpan.org/dist/Monitoring-Sneck) or +[Github](https://github.com/VVelox/Monitoring-Sneck). + +For poking systems using Sneck, also check out boop_snoot +if one wants to query those systems via the CLI. Docs on it +at [MetaCPAN](https://metacpan.org/dist/Monitoring-Sneck-Boop_Snoot) and +[Github](https://github.com/VVelox/Monitoring-Sneck-Boop_Snoot). + +### SNMP Extend + +1. Install the extend. + +``` +# FreeBSD +pkg install p5-JSON p5-File-Slurp p5-MIME-Base64 p5-Gzip-Faster p5-App-cpanminus +cpanm Monitoring::Sneck +# Debian based systems +apt-get install zlib1g-dev cpanminus +cpanm Monitoring::Sneck +``` + +2. Configure any of the checks you want to run in + `/usr/local/etc/sneck.conf`. You con find it documented + [here](https://metacpan.org/pod/Monitoring::Sneck#CONFIG-FORMAT). + +3. Set it up in cron. This will mean you don't need to wait for all + the checks to complete when polled via SNMP, which for like SMART + or other long running checks will mean it timing out. Also means it + does not need called via sudo as well. + +``` +*/5 * * * * /usr/bin/env PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin /usr/local/bin/sneck -u 2> /dev/null > /dev/null +``` + +4. Set it up in the snmpd config and restart snmpd. The `-c` flag will + tell read it to read from cache instead of rerunning the checks. + +``` +extend sneck /usr/bin/env PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin /usr/local/bin/sneck -c +``` + +5. In LibreNMS, enable the application for the server in question or wait for auto + discovery to find it. + ## Squid ### SNMP Proxy diff --git a/includes/html/graphs/application/sneck_results.inc.php b/includes/html/graphs/application/sneck_results.inc.php new file mode 100644 index 0000000000..20f1f7b8c7 --- /dev/null +++ b/includes/html/graphs/application/sneck_results.inc.php @@ -0,0 +1,45 @@ +app_id]); + +$rrd_list = []; +if (Rrd::checkRrdExists($rrd_filename)) { + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'OK', + 'ds' => 'ok', + ]; + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'Warning', + 'ds' => 'warning', + ]; + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'Critical', + 'ds' => 'critical', + ]; + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'Unknown', + 'ds' => 'unknown', + ]; + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'Errored', + 'ds' => 'errored', + ]; +} else { + d_echo('RRD "' . $rrd_filename . '" not found'); +} + +require 'includes/html/graphs/generic_multi_line.inc.php'; diff --git a/includes/html/graphs/application/sneck_time.inc.php b/includes/html/graphs/application/sneck_time.inc.php new file mode 100644 index 0000000000..93493acccf --- /dev/null +++ b/includes/html/graphs/application/sneck_time.inc.php @@ -0,0 +1,29 @@ +app_id]); + +$rrd_list = []; +if (Rrd::checkRrdExists($rrd_filename)) { + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'On Dev', + 'ds' => 'time', + ]; + $rrd_list[] = [ + 'filename' => $rrd_filename, + 'descr' => 'To Polling', + 'ds' => 'time_to_polling', + ]; +} else { + d_echo('RRD "' . $rrd_filename . '" not found'); +} + +require 'includes/html/graphs/generic_multi_line.inc.php'; diff --git a/includes/html/pages/apps.inc.php b/includes/html/pages/apps.inc.php index f5a2f35021..af2195d504 100644 --- a/includes/html/pages/apps.inc.php +++ b/includes/html/pages/apps.inc.php @@ -96,6 +96,10 @@ $graphs['powerdns'] = [ 'queries', 'queries_udp', ]; +$graphs['sneck'] = [ + 'results', + 'time', +]; $graphs['ntp-client'] = [ 'stats', 'freq', diff --git a/includes/html/pages/device/apps/sneck.inc.php b/includes/html/pages/device/apps/sneck.inc.php new file mode 100644 index 0000000000..e537d5871f --- /dev/null +++ b/includes/html/pages/device/apps/sneck.inc.php @@ -0,0 +1,52 @@ + 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', + 'app' => 'sneck', +]; + +$link_array = [ + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', + 'app' => 'sneck', +]; + +$graphs = [ + 'sneck_results'=>'Results', + 'sneck_time'=>'Time Difference', +]; + +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = \LibreNMS\Config::get('time.now'); + $graph_array['id'] = $app->app_id; + $graph_array['type'] = 'application_' . $key; + + echo '
+
+

' . $text . '

+
+
+
'; + include 'includes/html/print-graphrow.inc.php'; + echo '
'; + echo '
'; + echo '
'; +} + +// print any alerts if found +$sneck_data = $app->app_id; +if (isset($sneck_data)) { + print_optionbar_start(); + echo 'Last Return...
'; + echo "Alert(s):
\n"; + echo str_replace("\n", "
\n", $app->data['data']['alertString']) . "

\n"; + echo "Raw JSON:
\n"; + echo "
\n" . json_encode($app->data, JSON_PRETTY_PRINT) . "
\n"; + print_optionbar_end(); +} diff --git a/includes/polling/applications/sneck.inc.php b/includes/polling/applications/sneck.inc.php new file mode 100644 index 0000000000..1835c21bfe --- /dev/null +++ b/includes/polling/applications/sneck.inc.php @@ -0,0 +1,159 @@ +data['data']) && isset($app->data['data']['checks'])) { + $old_checks = array_keys($app->data['data']['checks']); + $old_checks_data = $app->data['data']['checks']; +} + +if (Config::has('apps.sneck.polling_time_diff')) { + $compute_time_diff = Config::get('apps.sneck.polling_time_diff'); +} else { + $compute_time_diff = false; +} + +try { + $json_return = json_app_get($device, $name, 1); +} catch (JsonAppException $e) { + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + // Set empty metrics and error message + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); + + return; +} + +$app->data = $json_return; + +$new_checks = []; +if (isset($json_return['data']) and isset($json_return['data']['checks'])) { + $new_checks = array_keys($json_return['data']['checks']); +} + +$rrd_name = ['app', $name, $app->app_id]; +$rrd_def = RrdDefinition::make() + ->addDataset('time', 'DERIVE', 0) + ->addDataset('time_to_polling', 'GAUGE', 0) + ->addDataset('ok', 'GAUGE', 0) + ->addDataset('warning', 'GAUGE', 0) + ->addDataset('critical', 'GAUGE', 0) + ->addDataset('unknown', 'GAUGE', 0) + ->addDataset('errored', 'GAUGE', 0); + +// epoch off set between poller and when the when the JSON was generated +// only compueted if +if ($compute_time_diff) { + $time_to_polling = Carbon::now()->timestamp - $json_return['data']['time']; +} else { + $time_to_polling = 0; +} + +$fields = [ + 'time' => $json_return['data']['time'], + 'time_to_polling' => $time_to_polling, + 'ok' => $json_return['data']['ok'], + 'warning' => $json_return['data']['warning'], + 'critical' => $json_return['data']['critical'], + 'unknown' => $json_return['data']['unknown'], + 'errored' => $json_return['data']['errored'], +]; + +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; +data_update($device, 'app', $tags, $fields); + +// save the return status for each alerting possibilities +foreach ($json_return['data']['checks'] as $key => $value) { + $fields['check_' . $key] = $value['exit']; +} + +$fields['time_to_polling_abs'] = abs($time_to_polling); + +if (abs($time_to_polling) > 540) { + $json_return['data']['alertString'] = $json_return['data']['alertString'] . "\nGreater than 540 seconds since the polled data was generated"; + $json_return['data']['alert'] = 1; +} + +//check for added checks +$added_checks = array_values(array_diff($new_checks, $old_checks)); + +//check for removed checks +$removed_checks = array_values(array_diff($old_checks, $new_checks)); + +// if we have any check changes, log it +if (sizeof($added_checks) > 0 || sizeof($removed_checks) > 0) { + $log_message = 'Sneck Check Change:'; + $log_message .= count($added_checks) > 0 ? ' Added ' . json_encode($added_checks) : ''; + $log_message .= count($removed_checks) > 0 ? ' Removed ' . json_encode($added_checks) : ''; + log_event($log_message, $device, 'application'); +} + +// go through and looking for status changes +$cleared = []; +$warned = []; +$alerted = []; +$unknowned = []; +foreach ($new_checks as $check) { + if (isset($old_checks_data[$check]) && isset($old_checks_data[$check]['exit']) && isset($old_checks_data[$check]['output'])) { + if ($json_return['data']['checks'][$check]['exit'] != $app->data['data']['checks'][$check]['exit']) { + $check_output = $json_return['data']['checks'][$check]['output']; + $exit_code = $json_return['data']['checks'][$check]['exit']; + + if ($exit_code == 1) { + $warned[$check] = $check_output; + } elseif ($exit_code == 2) { + $alerted[$check] = $check_output; + } elseif ($exit_code >= 3) { + $unknowned[$check] = $check_output; + } elseif ($exit_code == 0) { + $cleared[$check] = $check_output; + } + } + } else { + if (isset($json_return['data']['checks'][$check]['exit']) && isset($json_return['data']['checks'][$check]['output'])) { + $check_output = $json_return['data']['checks'][$check]['output']; + $exit_code = $json_return['data']['checks'][$check]['exit']; + + if ($exit_code == 1) { + $warned[$check] = $check_output; + } elseif ($exit_code == 2) { + $alerted[$check] = $check_output; + } elseif ($exit_code >= 3) { + $unknowned[$check] = $check_output; + } + } + } +} + +// log any clears +if (sizeof($cleared) > 0) { + $log_message = 'Sneck Check Clears: ' . json_encode($cleared); + log_event($log_message, $device, 'application', 1); +} + +// log any warnings +if (sizeof($warned) > 0) { + $log_message = 'Sneck Check Warns: ' . json_encode($warned); + log_event($log_message, $device, 'application', 4); +} + +// log any alerts +if (sizeof($alerted) > 0) { + $log_message = 'Sneck Check Alerts: ' . json_encode($alerted); + log_event($log_message, $device, 'application', 5); +} + +// log any unknowns +if (sizeof($unknowned) > 0) { + $log_message = 'Sneck Check Unknowns: ' . json_encode($unknownwed); + log_event($log_message, $device, 'application', 6); +} + +// update it here as we are done with this mostly +update_application($app, 'OK', $fields); diff --git a/misc/alert_rules.json b/misc/alert_rules.json index 93b6ad21f8..0cd49f16dd 100644 --- a/misc/alert_rules.json +++ b/misc/alert_rules.json @@ -483,6 +483,126 @@ "builder": {"condition":"AND","rules":[{"id":"ports.ifSpeed","field":"ports.ifSpeed","type":"string","input":"text","operator":"greater","value":"0"},{"id":"ports.ifSpeed","field":"ports.ifSpeed","type":"string","input":"text","operator":"less","value":"`ports.ifSpeed_prev`"},{"id":"eventlog.message","field":"eventlog.message","type":"string","input":"text","operator":"begins_with","value":"ifSpeed:"},{"id":"eventlog.datetime","field":"eventlog.datetime","type":"datetime","input":"text","operator":"greater_or_equal","value":"`macros.past_10m`"},{"id":"ports.port_id","field":"ports.port_id","type":"string","input":"text","operator":"equal","value":"`eventlog.reference`"},{"id":"ports.ifOperStatus","field":"ports.ifOperStatus","type":"string","input":"text","operator":"equal","value":"up"},{"id":"ports.disabled","field":"ports.disabled","type":"string","input":"text","operator":"equal","value":"0"}],"valid":true}, "name": "Port Speed Degraded" }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"warning\" && application_metrics.value >= \"1\"", + "name": "Sneck Warnings >= 1", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"critical\" && application_metrics.value >= \"1\"", + "name": "Sneck Critical >= 1", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"unknown\" && application_metrics.value >= \"1\"", + "name": "Sneck Unknown >= 1", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"errored\" && application_metrics.value >= \"1\"", + "name": "Sneck Errored >= 1", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_psu\" && application_metrics.value = \"1\"", + "name": "Sneck - IPMI PSU Warning", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_psu\" && application_metrics.value = \"2\"", + "name": "Sneck - IPMI PSU Critical", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_psu\" && application_metrics.value = \"3\"", + "name": "Sneck - IPMI PSU Unknown", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_fan\" && application_metrics.value = \"1\"", + "name": "Sneck - IPMI Fan Warning", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_fan\" && application_metrics.value = \"2\"", + "name": "Sneck - IPMI Fan Critical", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_fan\" && application_metrics.value = \"3\"", + "name": "Sneck - IPMI Fan Unknown", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_temp\" && application_metrics.value = \"1\"", + "name": "Sneck - IPMI Temperature Warning", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_temp\" && application_metrics.value = \"2\"", + "name": "Sneck - IPMI Temperature Critical", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_temp\" && application_metrics.value = \"3\"", + "name": "Sneck - IPMI Temperature Unknown", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_volts\" && application_metrics.value = \"1\"", + "name": "Sneck - IPMI Volts Warning", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_volts\" && application_metrics.value = \"2\"", + "name": "Sneck - IPMI Volts Critical", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_volts\" && application_metrics.value = \"3\"", + "name": "Sneck - IPMI Volts Unknown", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_amps\" && application_metrics.value = \"1\"", + "name": "Sneck - IPMI Amps Warning", + "severity": "warning" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_amps\" && application_metrics.value = \"2\"", + "name": "Sneck - IPMI Amps Critical", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_ipmi_amps\" && application_metrics.value = \"3\"", + "name": "Sneck - IPMI Amps Unknown", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_suricata_procs\" && application_metrics.value != \"0\"", + "name": "Sneck - Wrong Number Of Suricata Procs Running", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_meer_procs\" && application_metrics.value != \"0\"", + "name": "Sneck - Wrong Number Of Meer Procs Running", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_sagan_procs\" && application_metrics.value != \"0\"", + "name": "Sneck - Wrong Number Of Sagan Procs Running", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"check_daemonlogger_procs\" && application_metrics.value != \"0\"", + "name": "Sneck - Wrong Number Of Daemonlogger Procs Running", + "severity": "critical" + }, + { + "rule": "applications.app_type = \"sneck\" && application_metrics.metric = \"time_to_polling_abs\" && application_metrics.value >= \"540\"", + "name": "Sneck Has Not Run For Over 540 Seconds", + "severity": "critical" + }, { "rule": "applications.app_type = \"suricata\" && application_metrics.metric = \"alert\" && application_metrics.value = \"1\"", "name": "Suricata has a WARNING alert", diff --git a/misc/config_definitions.json b/misc/config_definitions.json index f633aa9bb1..d0d57ef536 100644 --- a/misc/config_definitions.json +++ b/misc/config_definitions.json @@ -359,6 +359,10 @@ "default": 8082, "type": "integer" }, + "apps.sneck.polling_time_diff": { + "default": false, + "type": "boolean" + }, "astext": { "default": { "65332": "Cymru FullBogon Feed", diff --git a/tests/data/linux_sneck-v1.json b/tests/data/linux_sneck-v1.json new file mode 100644 index 0000000000..7ff5a6cf31 --- /dev/null +++ b/tests/data/linux_sneck-v1.json @@ -0,0 +1,122 @@ +{ + "applications": { + "discovery": { + "applications": [ + { + "app_type": "sneck", + "app_state": "UNKNOWN", + "discovered": 1, + "app_state_prev": null, + "app_status": "", + "app_instance": "", + "data": null + } + ] + }, + "poller": { + "applications": [ + { + "app_type": "sneck", + "app_state": "OK", + "discovered": 1, + "app_state_prev": "UNKNOWN", + "app_status": "", + "app_instance": "", + "data": "{\"data\":{\"alert\":0,\"alertString\":\"\",\"checks\":{\"clamav\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_clamav -w 2 -c 3\",\"exit\":0,\"output\":\"ClamAV OK: daily.cvd 26579 (Tue Jun 21 08:15:30 2022) is up to date\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_clamav -w 2 -c 3\"},\"entropy\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_entropy\",\"exit\":0,\"output\":\"OK: 3649 bytes in the pool.|entropy=3649 bytes\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_entropy\"},\"http\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_http -H 127.0.0.1:8000\",\"exit\":0,\"output\":\"HTTP OK: HTTP\\/1.1 200 OK - 6249 bytes in 0.057 second response time |time=0.057237s;;;0.000000;10.000000 size=6249B;;;0\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_http -H 127.0.0.1:8000\"},\"ipmi_sensor\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_ipmi_sensor --nosel\",\"exit\":0,\"output\":\"IPMI Status: OK | 'CPU Temp'=50.00;0.00:97.00;0.00:102.00 'System Temp'=37.00;0.00:80.00;-5.00:85.00 'Peripheral Temp'=47.00;0.00:80.00;-5.00:85.00 'DIMMB1 Temp'=36.00;5.00:80.00;0.00:85.00 'DIMMB2 Temp'=38.00;5.00:80.00;0.00:85.00 'FAN1'=4100.00;700.00:25300.00;500.00:25400.00 'FAN2'=3400.00;700.00:25300.00;500.00:25400.00 'FAN3'=4300.00;700.00:25300.00;500.00:25400.00 'VCCP'=1.86;1.57:2.02;1.46:2.13 'VDIMM'=1.20;1.05:1.34;0.97:1.43 '12V'=12.13;10.78:12.96;10.27:13.28 '5VCC'=5.03;4.48:5.39;4.30:5.55 '3.3VCC'=3.40;2.96:3.55;2.82:3.66 'VBAT'=3.14;2.59:3.49;2.47:3.57 '5V Dual'=5.00;4.49:5.38;4.30:5.54 '3.3V AUX'=3.32;2.96:3.55;2.82:3.66\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_ipmi_sensor --nosel\"},\"mongodb\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_mongodb.py\",\"exit\":0,\"output\":\"OK - Connection took 0.011 seconds\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_mongodb.py\"},\"raid\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_raid\",\"exit\":0,\"output\":\"OK: mdstat:[md0(2.73 TiB raid1):UU]\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_raid\"},\"virtqemud_procs\":{\"check\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_procs --ereg-argument-array '^\\/usr\\/sbin\\/virtqemud' 1:2\",\"exit\":0,\"output\":\"PROCS OK: 1 process with regex args '^\\/usr\\/sbin\\/virtqemud' | procs=1;1:2;;0;\",\"ran\":\"\\/usr\\/lib\\/nagios\\/plugins\\/check_procs --ereg-argument-array '^\\/usr\\/sbin\\/virtqemud' 1:2\"}},\"critical\":0,\"errored\":0,\"hostname\":\"nagi\",\"ok\":7,\"time\":1655835901,\"unknown\":0,\"vars\":[],\"warning\":0},\"error\":0,\"errorString\":\"\",\"version\":1}" + } + ], + "application_metrics": [ + { + "metric": "check_clamav", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_entropy", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_http", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_ipmi_sensor", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_mongodb", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_raid", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "check_virtqemud_procs", + "value": 0.0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "critical", + "value": 0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "errored", + "value": 0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "ok", + "value": 7, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "time", + "value": 1655835901, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "time_to_polling", + "value": 0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "time_to_polling_abs", + "value": 0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "unknown", + "value": 0, + "value_prev": null, + "app_type": "sneck" + }, + { + "metric": "warning", + "value": 0, + "value_prev": null, + "app_type": "sneck" + } + ] + } + } +} diff --git a/tests/snmpsim/linux_sneck-v1.snmprec b/tests/snmpsim/linux_sneck-v1.snmprec new file mode 100644 index 0000000000..5a7d268ce2 --- /dev/null +++ b/tests/snmpsim/linux_sneck-v1.snmprec @@ -0,0 +1,10 @@ +1.3.6.1.2.1.1.1.0|4|Linux server 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.10 +1.3.6.1.2.1.1.3.0|67|77550514 +1.3.6.1.2.1.1.4.0|4| +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.2.1.1.6.0|4| +1.3.6.1.2.1.25.1.1.0|67|77552962 +1.3.6.1.4.1.8072.1.3.2.2.1.21.6.100.105.115.116.114.111|2|1 +1.3.6.1.4.1.8072.1.3.2.2.1.21.5.115.110.101.99.107|2|1 +1.3.6.1.4.1.8072.1.3.2.3.1.2.5.115.110.101.99.107|4x|7b0a20202264617461223a207b0a2020202022616c657274223a20302c0a2020202022616c657274537472696e67223a2022222c0a2020202022636865636b73223a207b0a20202020202022636c616d6176223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f636c616d6176202d772032202d632033222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a2022436c616d4156204f4b3a206461696c792e6376642032363537392028547565204a756e2032312030383a31353a333020323032322920697320757020746f2064617465222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f636c616d6176202d772032202d632033220a2020202020207d2c0a20202020202022656e74726f7079223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f656e74726f7079222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a20224f4b3a203336343920627974657320696e2074686520706f6f6c2e7c656e74726f70793d33363439206279746573222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f656e74726f7079220a2020202020207d2c0a2020202020202268747470223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f68747470202d48203132372e302e302e313a38303030222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a202248545450204f4b3a20485454502f312e3120323030204f4b202d203632343920627974657320696e20302e303537207365636f6e6420726573706f6e73652074696d65207c74696d653d302e303537323337733b3b3b302e3030303030303b31302e3030303030302073697a653d36323439423b3b3b30222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f68747470202d48203132372e302e302e313a38303030220a2020202020207d2c0a2020202020202269706d695f73656e736f72223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f69706d695f73656e736f72202d2d6e6f73656c222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a202249504d49205374617475733a204f4b207c20274350552054656d70273d35302e30303b302e30303a39372e30303b302e30303a3130322e3030202753797374656d2054656d70273d33372e30303b302e30303a38302e30303b2d352e30303a38352e303020275065726970686572616c2054656d70273d34372e30303b302e30303a38302e30303b2d352e30303a38352e3030202744494d4d42312054656d70273d33362e30303b352e30303a38302e30303b302e30303a38352e3030202744494d4d42322054656d70273d33382e30303b352e30303a38302e30303b302e30303a38352e3030202746414e31273d343130302e30303b3730302e30303a32353330302e30303b3530302e30303a32353430302e3030202746414e32273d333430302e30303b3730302e30303a32353330302e30303b3530302e30303a32353430302e3030202746414e33273d343330302e30303b3730302e30303a32353330302e30303b3530302e30303a32353430302e3030202756434350273d312e38363b312e35373a322e30323b312e34363a322e313320275644494d4d273d312e32303b312e30353a312e33343b302e39373a312e34332027313256273d31322e31333b31302e37383a31322e39363b31302e32373a31332e3238202735564343273d352e30333b342e34383a352e33393b342e33303a352e35352027332e33564343273d332e34303b322e39363a332e35353b322e38323a332e3636202756424154273d332e31343b322e35393a332e34393b322e34373a332e353720273556204475616c273d352e30303b342e34393a352e33383b342e33303a352e35342027332e335620415558273d332e33323b322e39363a332e35353b322e38323a332e3636222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f69706d695f73656e736f72202d2d6e6f73656c220a2020202020207d2c0a202020202020226d6f6e676f6462223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f6d6f6e676f64622e7079222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a20224f4b202d20436f6e6e656374696f6e20746f6f6b20302e303131207365636f6e6473222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f6d6f6e676f64622e7079220a2020202020207d2c0a2020202020202272616964223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f72616964222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a20224f4b3a206d64737461743a5b6d643028322e373320546942207261696431293a55555d222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f72616964220a2020202020207d2c0a202020202020227669727471656d75645f70726f6373223a207b0a202020202020202022636865636b223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f70726f6373202d2d657265672d617267756d656e742d617272617920275e2f7573722f7362696e2f7669727471656d75642720313a32222c0a20202020202020202265786974223a20302c0a2020202020202020226f7574707574223a202250524f4353204f4b3a20312070726f636573732077697468207265676578206172677320275e2f7573722f7362696e2f7669727471656d756427207c2070726f63733d313b313a323b3b303b222c0a20202020202020202272616e223a20222f7573722f6c69622f6e6167696f732f706c7567696e732f636865636b5f70726f6373202d2d657265672d617267756d656e742d617272617920275e2f7573722f7362696e2f7669727471656d75642720313a32220a2020202020207d0a202020207d2c0a2020202022637269746963616c223a20302c0a20202020226572726f726564223a20302c0a2020202022686f73746e616d65223a20226e616769222c0a20202020226f6b223a20372c0a202020202274696d65223a20313635353833353930312c0a2020202022756e6b6e6f776e223a20302c0a202020202276617273223a207b7d2c0a20202020227761726e696e67223a20300a20207d2c0a2020226572726f72223a20302c0a2020226572726f72537472696e67223a2022222c0a20202276657273696f6e223a20310a7d0a