From 184f5a5f99ebee2a873499aba70208d76a6ed024 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 16 Aug 2018 11:11:03 -0500 Subject: [PATCH] Fix invalid json in test data (#9015) * Fix invalid json in test data Most simply needed the syntax fixed fail2ban needed updated data (added non-zero values in test data too) awplus: ntp application cannot be enabled by tests since it doesn't use snmp extend... ntp app is enabled by ntp module... pass on that for now. * missed awplus change somehow... --- LibreNMS/Util/ModuleTestHelper.php | 5 +++++ includes/polling/applications/fail2ban.inc.php | 8 +++----- tests/data/arbos.json | 2 +- tests/data/awplus.json | 13 ------------- tests/data/fortiweb.json | 2 +- tests/data/hiveos-wireless.json | 2 +- tests/data/hiveos-wireless_ap130.json | 2 +- tests/data/linux_fail2ban-legacy.json | 14 +++++++------- tests/data/linux_fail2ban-v1.json | 14 +++++++------- tests/data/voss_8404c.json | 2 +- tests/snmpsim/linux_fail2ban-legacy.snmprec | 2 +- tests/snmpsim/linux_fail2ban-v1.snmprec | 2 +- 12 files changed, 29 insertions(+), 39 deletions(-) diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index cb065112bc..92d4928de4 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -238,6 +238,11 @@ class ModuleTestHelper // calculate valid modules $data_modules = array_keys(json_decode(file_get_contents($file), true)); + if (json_last_error()) { + echo "Invalid json data: $base_name\n"; + exit(1); + } + if (empty($modules)) { $valid_modules = $data_modules; } else { diff --git a/includes/polling/applications/fail2ban.inc.php b/includes/polling/applications/fail2ban.inc.php index 61ebe2e228..5adf9ba52d 100644 --- a/includes/polling/applications/fail2ban.inc.php +++ b/includes/polling/applications/fail2ban.inc.php @@ -43,11 +43,9 @@ $rrd_def = RrdDefinition::make() ->addDataset('firewalled', 'GAUGE', 0); -$fields = array( - 'banned' => $f2b['total'], - 'firewalled'=>'U', // legacy ds -); -$metrics['total'] = $fields; +$fields = ['banned' => $f2b['total']]; +$metrics['total'] = $fields; // don't include legacy ds in db +$fields['firewalled'] = 'U'; // legacy ds $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); data_update($device, 'app', $tags, $fields); diff --git a/tests/data/arbos.json b/tests/data/arbos.json index 6c0db47c3d..786902d02e 100644 --- a/tests/data/arbos.json +++ b/tests/data/arbos.json @@ -2888,7 +2888,7 @@ "processors": [] }, "poller": "matches discovery" - } + }, "storage": { "discovery": { "storage": [ diff --git a/tests/data/awplus.json b/tests/data/awplus.json index 6f09348467..5ae8387b21 100644 --- a/tests/data/awplus.json +++ b/tests/data/awplus.json @@ -12442,19 +12442,6 @@ ] } }, - "applications": { - "poller": { - "applications": [ - { - "app_type": "ntp", - "app_state": "UNKNOWN", - "discovered": "0", - "app_state_prev": null, - "app_status": "", - "app_instance": "" - } - ], - "application_metrics": [] "vlans": { "discovery": { "vlans": [ diff --git a/tests/data/fortiweb.json b/tests/data/fortiweb.json index 542376e04f..9b15eb17a3 100644 --- a/tests/data/fortiweb.json +++ b/tests/data/fortiweb.json @@ -466,5 +466,5 @@ } ] } - }, + } } diff --git a/tests/data/hiveos-wireless.json b/tests/data/hiveos-wireless.json index a071b75405..0d15dc5de7 100644 --- a/tests/data/hiveos-wireless.json +++ b/tests/data/hiveos-wireless.json @@ -437,5 +437,5 @@ "state_indexes": [] }, "poller": "matches discovery" - }, + } } diff --git a/tests/data/hiveos-wireless_ap130.json b/tests/data/hiveos-wireless_ap130.json index d8da61e649..5eade152d6 100644 --- a/tests/data/hiveos-wireless_ap130.json +++ b/tests/data/hiveos-wireless_ap130.json @@ -437,5 +437,5 @@ } ] } - }, + } } diff --git a/tests/data/linux_fail2ban-legacy.json b/tests/data/linux_fail2ban-legacy.json index 3678f92815..9a727ff5c9 100644 --- a/tests/data/linux_fail2ban-legacy.json +++ b/tests/data/linux_fail2ban-legacy.json @@ -26,23 +26,23 @@ ], "application_metrics": [ { - "metric": "jail_dovecot", - "value": "0", + "metric": "jail_dovecot_banned", + "value": "6", "value_prev": null, "app_type": "fail2ban" }, { - "metric": "jail_sshd", - "value": "0", + "metric": "jail_sshd_banned", + "value": "4", "value_prev": null, "app_type": "fail2ban" }, { - "metric": "total", - "value": "0", + "metric": "total_banned", + "value": "10", "value_prev": null, "app_type": "fail2ban" - }, + } ] } } diff --git a/tests/data/linux_fail2ban-v1.json b/tests/data/linux_fail2ban-v1.json index 3678f92815..293b9b6617 100644 --- a/tests/data/linux_fail2ban-v1.json +++ b/tests/data/linux_fail2ban-v1.json @@ -26,23 +26,23 @@ ], "application_metrics": [ { - "metric": "jail_dovecot", - "value": "0", + "metric": "jail_dovecot_banned", + "value": "5", "value_prev": null, "app_type": "fail2ban" }, { - "metric": "jail_sshd", - "value": "0", + "metric": "jail_sshd_banned", + "value": "3", "value_prev": null, "app_type": "fail2ban" }, { - "metric": "total", - "value": "0", + "metric": "total_banned", + "value": "8", "value_prev": null, "app_type": "fail2ban" - }, + } ] } } diff --git a/tests/data/voss_8404c.json b/tests/data/voss_8404c.json index e06a9d8391..07532cc372 100644 --- a/tests/data/voss_8404c.json +++ b/tests/data/voss_8404c.json @@ -91,7 +91,7 @@ "ifOutUcastPkts_prev": null, "ifOutUcastPkts_delta": null, "ifOutUcastPkts_rate": null, - "ifInErrors": null,extreme + "ifInErrors": null, "ifInErrors_prev": null, "ifInErrors_delta": null, "ifInErrors_rate": null, diff --git a/tests/snmpsim/linux_fail2ban-legacy.snmprec b/tests/snmpsim/linux_fail2ban-legacy.snmprec index afd2e9c6d4..de9509e000 100644 --- a/tests/snmpsim/linux_fail2ban-legacy.snmprec +++ b/tests/snmpsim/linux_fail2ban-legacy.snmprec @@ -7,5 +7,5 @@ 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.8.102.97.105.108.50.98.97.110|2|1 -1.3.6.1.4.1.8072.1.3.2.3.1.2.8.102.97.105.108.50.98.97.110|4x|300a646f7665636f7420300a7373686420300a +1.3.6.1.4.1.8072.1.3.2.3.1.2.8.102.97.105.108.50.98.97.110|4x|31300a646f7665636f7420360a7373686420340a 1.3.6.1.6.3.10.2.1.3.0|2|775505 diff --git a/tests/snmpsim/linux_fail2ban-v1.snmprec b/tests/snmpsim/linux_fail2ban-v1.snmprec index d9050749a6..ee32f71380 100644 --- a/tests/snmpsim/linux_fail2ban-v1.snmprec +++ b/tests/snmpsim/linux_fail2ban-v1.snmprec @@ -7,5 +7,5 @@ 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.8.102.97.105.108.50.98.97.110|2|1 -1.3.6.1.4.1.8072.1.3.2.3.1.2.8.102.97.105.108.50.98.97.110|4x|7b2264617461223a7b226a61696c73223a7b2273736864223a2230222c22646f7665636f74223a2230227d2c22746f74616c223a307d2c226572726f72223a2230222c2276657273696f6e223a312c226572726f72537472696e67223a226661696c3262616e2d636c69656e742065786974656420776974682030227d0a +1.3.6.1.4.1.8072.1.3.2.3.1.2.8.102.97.105.108.50.98.97.110|4x|7b2264617461223a7b226a61696c73223a7b2273736864223a2233222c22646f7665636f74223a2235227d2c22746f74616c223a387d2c226572726f72223a2230222c2276657273696f6e223a312c226572726f72537472696e67223a226661696c3262616e2d636c69656e742065786974656420776974682030227d0a 1.3.6.1.6.3.10.2.1.3.0|2|775505