From 0c12fb6c9421baf2baacc3c005666228de72d3df Mon Sep 17 00:00:00 2001 From: Slashdoom <5092581+slashdoom@users.noreply.github.com> Date: Fri, 5 Jan 2018 15:33:04 +1300 Subject: [PATCH] refactoring: freeradius app metrics (#8002) Add metrics to Free Radius app --- .../polling/applications/freeradius.inc.php | 11 +- tests/data/linux_freeradius.json | 277 ++++++++++++++++++ tests/snmpsim/linux_freeradius.snmprec | 10 + 3 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 tests/data/linux_freeradius.json create mode 100644 tests/snmpsim/linux_freeradius.snmprec diff --git a/includes/polling/applications/freeradius.inc.php b/includes/polling/applications/freeradius.inc.php index cb73ba6bfa..e94d84cd1d 100644 --- a/includes/polling/applications/freeradius.inc.php +++ b/includes/polling/applications/freeradius.inc.php @@ -14,12 +14,11 @@ if (!empty($agent_data['app'][$name])) { $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.102.114.101.101.114.97.100.105.117.115'; $rawdata = snmp_get($device, $oid, $options); } -update_application($app, $rawdata); - #Format Data $lines = explode("\n", $rawdata); $freeradius = array(); +$metrics = array(); foreach ($lines as $line) { list($var,$value) = explode(' = ', $line); $freeradius[$var] = $value; @@ -38,6 +37,7 @@ $fields = array ( 'rejects' => $freeradius['FreeRADIUS-Total-Access-Rejects'], 'challenges' => $freeradius['FreeRADIUS-Total-Access-Challenges'] ); +$metrics['access'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -58,6 +58,7 @@ $fields = array ( 'dropped_requests' => $freeradius['FreeRADIUS-Total-Auth-Dropped-Requests'], 'unknown_types' => $freeradius['FreeRADIUS-Total-Auth-Unknown-Types'] ); +$metrics['auth'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -80,6 +81,7 @@ $fields = array ( 'dropped_requests' => $freeradius['FreeRADIUS-Total-Acct-Dropped-Requests'], 'unknown_types' => $freeradius['FreeRADIUS-Total-Acct-Unknown-Types'] ); +$metrics['acct'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -96,6 +98,7 @@ $fields = array ( 'rejects' => $freeradius['FreeRADIUS-Total-Proxy-Access-Rejects'], 'challenges' => $freeradius['FreeRADIUS-Total-Proxy-Access-Challenges'] ); +$metrics['proxy_access'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -116,6 +119,7 @@ $fields = array ( 'dropped_requests' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Dropped-Requests'], 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Unknown-Types'] ); +$metrics['proxy_auth'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -138,6 +142,7 @@ $fields = array ( 'dropped_requests' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Dropped-Requests'], 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Unknown-Types'] ); +$metrics['proxy_acct'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -160,7 +165,9 @@ $fields = array ( 'pps_in' => $freeradius['FreeRADIUS-Queue-PPS-In'], 'pps_out' => $freeradius['FreeRADIUS-Queue-PPS-Out'] ); +$metrics['queue'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); +update_application($app, $rawdata, $metrics); unset($lines, $freeradius, $rrd_name, $rrd_def, $fields, $tags); diff --git a/tests/data/linux_freeradius.json b/tests/data/linux_freeradius.json new file mode 100644 index 0000000000..0b1aca9627 --- /dev/null +++ b/tests/data/linux_freeradius.json @@ -0,0 +1,277 @@ +{ + "applications": { + "discovery": { + "applications": [ + { + "app_type": "freeradius", + "app_state": "UNKNOWN", + "discovered": "1", + "app_state_prev": null, + "app_status": "", + "app_instance": "" + } + ], + "application_metrics": [] + }, + "poller": { + "applications": [ + { + "app_type": "freeradius", + "app_state": "OK", + "discovered": "1", + "app_state_prev": "UNKNOWN", + "app_status": "", + "app_instance": "" + } + ], + "application_metrics": [ + { + "metric": "access_accepts", + "value": "235", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "access_challenges", + "value": "490", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "access_rejects", + "value": "4", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "access_requests", + "value": "7758", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_dropped_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_duplicate_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_invalid_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_malformed_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_requests", + "value": "1685", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_responses", + "value": "1685", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "acct_unknown_types", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_dropped_requests", + "value": "5", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_duplicate_requests", + "value": "5", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_invalid_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_malformed_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_responses", + "value": "729", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "auth_unknown_types", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_access_accepts", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_access_challenges", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_access_rejects", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_access_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_dropped_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_duplicate_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_invalid_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_malformed_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_responses", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_acct_unknown_types", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_dropped_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_duplicate_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_invalid_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_malformed_requests", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_responses", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "proxy_auth_unknown_types", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_len_acct", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_len_auth", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_len_detail", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_len_internal", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_len_proxy", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_pps_in", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + }, + { + "metric": "queue_pps_out", + "value": "0", + "value_prev": null, + "app_type": "freeradius" + } + ] + } + } +} diff --git a/tests/snmpsim/linux_freeradius.snmprec b/tests/snmpsim/linux_freeradius.snmprec new file mode 100644 index 0000000000..8fc2f53e7e --- /dev/null +++ b/tests/snmpsim/linux_freeradius.snmprec @@ -0,0 +1,10 @@ +1.3.6.1.2.1.1.1.0|4|Linux SERVERNAME 3.10.0-514.6.1.el7.x86_64 #1 SMP Sat Dec 10 11:15:38 EST 2016 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|153017404 +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|982537914 +1.3.6.1.4.1.8072.1.3.2.2.1.21.10.102.114.101.101.114.97.100.105.117.115|2|1 +1.3.6.1.4.1.8072.1.3.2.3.1.2.10.102.114.101.101.114.97.100.105.117.115|4x|467265655241444955532d546f74616c2d4163636573732d5265717565737473203d20373735380a467265655241444955532d546f74616c2d4163636573732d41636365707473203d203233350a467265655241444955532d546f74616c2d4163636573732d52656a65637473203d20340a467265655241444955532d546f74616c2d4163636573732d4368616c6c656e676573203d203439300a467265655241444955532d546f74616c2d417574682d526573706f6e736573203d203732390a467265655241444955532d546f74616c2d417574682d4475706c69636174652d5265717565737473203d20350a467265655241444955532d546f74616c2d417574682d4d616c666f726d65642d5265717565737473203d20300a467265655241444955532d546f74616c2d417574682d496e76616c69642d5265717565737473203d20300a467265655241444955532d546f74616c2d417574682d44726f707065642d5265717565737473203d20350a467265655241444955532d546f74616c2d417574682d556e6b6e6f776e2d5479706573203d20300a467265655241444955532d546f74616c2d4163636f756e74696e672d5265717565737473203d20313638350a467265655241444955532d546f74616c2d4163636f756e74696e672d526573706f6e736573203d20313638350a467265655241444955532d546f74616c2d416363742d4475706c69636174652d5265717565737473203d20300a467265655241444955532d546f74616c2d416363742d4d616c666f726d65642d5265717565737473203d20300a467265655241444955532d546f74616c2d416363742d496e76616c69642d5265717565737473203d20300a467265655241444955532d546f74616c2d416363742d44726f707065642d5265717565737473203d20300a467265655241444955532d546f74616c2d416363742d556e6b6e6f776e2d5479706573203d20300a467265655241444955532d546f74616c2d50726f78792d4163636573732d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d4163636573732d41636365707473203d20300a467265655241444955532d546f74616c2d50726f78792d4163636573732d52656a65637473203d20300a467265655241444955532d546f74616c2d50726f78792d4163636573732d4368616c6c656e676573203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d526573706f6e736573203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d4475706c69636174652d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d4d616c666f726d65642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d496e76616c69642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d44726f707065642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d417574682d556e6b6e6f776e2d5479706573203d20300a467265655241444955532d546f74616c2d50726f78792d4163636f756e74696e672d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d4163636f756e74696e672d526573706f6e736573203d20300a467265655241444955532d546f74616c2d50726f78792d416363742d4475706c69636174652d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d416363742d4d616c666f726d65642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d416363742d496e76616c69642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d416363742d44726f707065642d5265717565737473203d20300a467265655241444955532d546f74616c2d50726f78792d416363742d556e6b6e6f776e2d5479706573203d20300a467265655241444955532d51756575652d4c656e2d496e7465726e616c203d20300a467265655241444955532d51756575652d4c656e2d50726f7879203d20300a467265655241444955532d51756575652d4c656e2d41757468203d20300a467265655241444955532d51756575652d4c656e2d41636374203d20300a467265655241444955532d51756575652d4c656e2d44657461696c203d20300a467265655241444955532d51756575652d5050532d496e203d20300a467265655241444955532d51756575652d5050532d4f7574203d2030 +1.3.6.1.6.3.10.2.1.3.0|2|1530174