From 56b31ba49b7a3fc6fa4567787fe5750e98920cc4 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 16 Oct 2023 01:23:16 -0500 Subject: [PATCH 1/2] Unix Agent and Application fixes --- LibreNMS/Modules/LegacyModule.php | 1 + includes/discovery/hr-device.inc.php | 4 +- includes/discovery/ucd-diskio.inc.php | 2 +- includes/polling/applications/apache.inc.php | 17 +- .../polling/applications/asterisk.inc.php | 21 ++- includes/polling/applications/bind.inc.php | 17 +- includes/polling/applications/cape.inc.php | 174 +++++++++--------- includes/polling/applications/ceph.inc.php | 30 ++- includes/polling/applications/chronyd.inc.php | 1 - .../polling/applications/exim-stats.inc.php | 8 +- .../polling/applications/freeradius.inc.php | 62 +++++-- .../polling/applications/freeswitch.inc.php | 10 +- includes/polling/applications/gpsd.inc.php | 8 +- .../polling/applications/hv-monitor.inc.php | 18 +- includes/polling/applications/icecast.inc.php | 8 +- .../applications/linux_softnet_stat.inc.php | 8 +- .../applications/mailcow-postfix.inc.php | 9 +- .../polling/applications/mailscanner.inc.php | 8 +- .../polling/applications/memcached.inc.php | 9 +- includes/polling/applications/mysql.inc.php | 23 ++- .../polling/applications/nfs-stats.inc.php | 10 +- .../polling/applications/nfs-v3-stats.inc.php | 10 +- includes/polling/applications/nginx.inc.php | 21 ++- .../polling/applications/ntp-client.inc.php | 8 +- .../polling/applications/ntp-server.inc.php | 8 +- .../applications/opengridscheduler.inc.php | 10 +- .../polling/applications/opensips.inc.php | 9 +- .../applications/powerdns-recursor.inc.php | 13 +- .../polling/applications/powerdns.inc.php | 8 +- .../polling/applications/powermon.inc.php | 8 +- includes/polling/applications/proxmox.inc.php | 19 +- .../polling/applications/rrdcached.inc.php | 10 +- .../polling/applications/shoutcast.inc.php | 10 +- includes/polling/applications/ss.inc.php | 61 +++--- .../applications/suricata_extract.inc.php | 8 +- includes/polling/applications/systemd.inc.php | 65 +++---- includes/polling/applications/tinydns.inc.php | 8 +- includes/polling/applications/unbound.inc.php | 47 +++-- .../polling/applications/ups-apcups.inc.php | 8 +- includes/polling/applications/ups-nut.inc.php | 8 +- .../polling/applications/voip-monitor.inc.php | 9 +- .../polling/applications/wireguard.inc.php | 4 +- misc/config_definitions.json | 14 +- 43 files changed, 522 insertions(+), 292 deletions(-) diff --git a/LibreNMS/Modules/LegacyModule.php b/LibreNMS/Modules/LegacyModule.php index 7c6906117c64..f07dd38836b4 100644 --- a/LibreNMS/Modules/LegacyModule.php +++ b/LibreNMS/Modules/LegacyModule.php @@ -114,6 +114,7 @@ public function poll(OS $os, DataStorageInterface $datastore): void $device = &$os->getDeviceArray(); Debug::disableErrorReporting(); // ignore errors in legacy code + global $agent_data; include_once base_path('includes/datastore.inc.php'); include_once base_path('includes/dbFacile.php'); diff --git a/includes/discovery/hr-device.inc.php b/includes/discovery/hr-device.inc.php index 5d8b43ecaae5..a7abca0447a5 100644 --- a/includes/discovery/hr-device.inc.php +++ b/includes/discovery/hr-device.inc.php @@ -1,8 +1,8 @@ $hrDevice['hrDeviceStatus'] ?? 'unknown', 'hrDeviceErrors' => $hrDevice['hrDeviceErrors'] ?? 0, ]; - if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor') { + if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor' && isset($hrDevice['hrProcessorLoad'])) { $update_array['hrProcessorLoad'] = $hrDevice['hrProcessorLoad']; } diff --git a/includes/discovery/ucd-diskio.inc.php b/includes/discovery/ucd-diskio.inc.php index f19e4e704102..abb83603ac13 100644 --- a/includes/discovery/ucd-diskio.inc.php +++ b/includes/discovery/ucd-diskio.inc.php @@ -10,7 +10,7 @@ if (dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = ? AND `diskio_index` = ? and `diskio_descr` = ?', [$device['device_id'], $index, $entry['diskIODevice']]) == '0') { $inserted = dbInsert(['device_id' => $device['device_id'], 'diskio_index' => $index, 'diskio_descr' => $entry['diskIODevice']], 'ucd_diskio'); echo '+'; - d_echo($sql . " - $inserted inserted "); + d_echo("$inserted inserted "); } else { echo '.'; // FIXME Need update code here! diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index 27955b2bee92..2fd204441cdb 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -13,12 +13,18 @@ $apache = snmp_get($device, $oid, $options); } +$apache_data = explode("\n", $apache); +if (count($apache_data) !== 20) { + echo " Incorrect number of datapoints returned from device, skipping\n"; + + return; +} + [$total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, - $score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = explode("\n", $apache); + $score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = $apache_data; -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('access', 'DERIVE', 0, 125000000000) ->addDataset('kbyte', 'DERIVE', 0, 125000000000) @@ -64,6 +70,11 @@ 'sb_open' => intval(trim($score_open, '"')), ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $apache, $fields); diff --git a/includes/polling/applications/asterisk.inc.php b/includes/polling/applications/asterisk.inc.php index 66f4378b46dd..4588226bdc81 100644 --- a/includes/polling/applications/asterisk.inc.php +++ b/includes/polling/applications/asterisk.inc.php @@ -3,7 +3,6 @@ use LibreNMS\RRD\RrdDefinition; $name = 'asterisk'; -$app_id = $app->app_id; if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; @@ -46,13 +45,17 @@ ]; $asterisk_metrics['stats'] = $sip_fields; -$sip_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$sip_tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $sip_tags, $sip_fields); unset($rrd_name, $rrd_def, $sip_fields, $sip_tags); // Additional iax2 stats -$rrd_name = ['app', $name, 'iax2', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('iax2peers', 'GAUGE', 0, 10000) ->addDataset('iax2online', 'GAUGE', 0, 10000) @@ -67,11 +70,17 @@ ]; $asterisk_metrics['iax2'] = $iax2_fields; -$iax2_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$iax2_tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'iax2', + 'rrd_name' => ['app', $name, 'iax2', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $iax2_tags, $iax2_fields); update_application($app, $rawdata, $asterisk_metrics); -unset($rrd_name, $rrd_def, $iax2_fields, $iax2_tags); +unset($rrd_def, $iax2_fields, $iax2_tags); -unset($asterisk, $asterisk_metrics, $rawdata, $app_id); // these are used for all rrds +unset($asterisk, $asterisk_metrics, $rawdata); // these are used for all rrds diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php index 15f9b791e5e8..5dc0bb16e80a 100644 --- a/includes/polling/applications/bind.inc.php +++ b/includes/polling/applications/bind.inc.php @@ -13,7 +13,14 @@ $bind = snmp_get($device, $oid, $options, $mib); } -[$incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets] = explode("\n", $bind); +$bind_data = explode("\n", $bind); +if (count($bind_data) !== 8) { + echo " Incorrect number of datapoints returned from device, skipping\n"; + + return; +} + +[$incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets] = $bind_data; // // INCOMING PROCESSING @@ -359,7 +366,6 @@ [$ch, $cm, $chfq, $cmfq, $crddtme, $crddtte, $cdn, $cdhb, $ctmt, $ctmiu, $cthmiu, $chmt, $chmiu, $chhmiu] = explode(',', $cache); -$rrd_name = ['app', $name, $app->app_id, 'cache']; $rrd_def = RrdDefinition::make() ->addDataset('ch', 'DERIVE', 0) ->addDataset('cm', 'DERIVE', 0) @@ -394,7 +400,12 @@ ]; $metrics['cache'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id, 'cache'], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); // diff --git a/includes/polling/applications/cape.inc.php b/includes/polling/applications/cape.inc.php index 45d6556c9a03..e36279cfdfb9 100644 --- a/includes/polling/applications/cape.inc.php +++ b/includes/polling/applications/cape.inc.php @@ -4,8 +4,6 @@ use LibreNMS\RRD\RrdDefinition; $name = 'cape'; -$app_id = $app['app_id']; - try { $returned = json_app_get($device, $name, 1)['data']; } catch (JsonAppException $e) { @@ -18,7 +16,7 @@ $current_packages = Rrd::getRrdApplicationArrays($device, $app['app_id'], 'cape', 'pkg-dropped_files___-___'); // general RRD def for base stats -$rrd_name = ['app', $name, $app_id]; +$rrd_name = ['app', $name, $app->app_id]; $rrd_def_general = RrdDefinition::make() ->addDataset('banned', 'GAUGE', 0) ->addDataset('completed', 'GAUGE', 0) @@ -58,12 +56,12 @@ 'warning' => $returned['warning'], 'wrong_prog' => $returned['wrong_prog'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_general, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_general, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = $fields; // aggregate dropped files stats -$rrd_name = ['app', $name, $app_id, 'dropped_files']; +$rrd_name = ['app', $name, $app->app_id, 'dropped_files']; $rrd_def_dropped_files = RrdDefinition::make() ->addDataset('dropped_files', 'GAUGE', 0) ->addDataset('s0dropped_files', 'GAUGE', 0) @@ -89,12 +87,12 @@ 's8dropped_files' => $returned['vp.dropped_files'], 's9dropped_files' => $returned['sdp.dropped_files'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate running procs stats -$rrd_name = ['app', $name, $app_id, 'running_processes']; +$rrd_name = ['app', $name, $app->app_id, 'running_processes']; $rrd_def_running_processes = RrdDefinition::make() ->addDataset('running_processes', 'GAUGE', 0) ->addDataset('s0running_processes', 'GAUGE', 0) @@ -120,12 +118,12 @@ 's8running_processes' => $returned['vp.running_processes'], 's9running_processes' => $returned['sdp.running_processes'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields_running_processes); $metrics = array_merge($metrics, $fields_running_processes); // aggregate api calls stats -$rrd_name = ['app', $name, $app_id, 'api_calls']; +$rrd_name = ['app', $name, $app->app_id, 'api_calls']; $rrd_def_api_calls = RrdDefinition::make() ->addDataset('api_calls', 'GAUGE', 0) ->addDataset('s0api_calls', 'GAUGE', 0) @@ -151,12 +149,12 @@ 's8api_calls' => $returned['vp.api_calls'], 's9api_calls' => $returned['sdp.api_calls'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields_api_calls); $metrics = array_merge($metrics, $fields_api_calls); // aggregate domains stats -$rrd_name = ['app', $name, $app_id, 'domains']; +$rrd_name = ['app', $name, $app->app_id, 'domains']; $rrd_def_domains = RrdDefinition::make() ->addDataset('domains', 'GAUGE', 0) ->addDataset('s0domains', 'GAUGE', 0) @@ -182,12 +180,12 @@ 's8domains' => $returned['vp.domains'], 's9domains' => $returned['sdp.domains'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields_domains); $metrics = array_merge($metrics, $fields_domains); // aggregate signatures total stats -$rrd_name = ['app', $name, $app_id, 'signatures_total']; +$rrd_name = ['app', $name, $app->app_id, 'signatures_total']; $rrd_def_signatures_total = RrdDefinition::make() ->addDataset('signatures_total', 'GAUGE', 0) ->addDataset('s0signatures_total', 'GAUGE', 0) @@ -213,12 +211,12 @@ 's8signatures_total' => $returned['vp.signatures_total'], 's9signatures_total' => $returned['sdp.signatures_total'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields_signatures_total); $metrics = array_merge($metrics, $fields_signatures_total); // aggregate signatures alert stats -$rrd_name = ['app', $name, $app_id, 'signatures_alert']; +$rrd_name = ['app', $name, $app->app_id, 'signatures_alert']; $rrd_def_signatures_alert = RrdDefinition::make() ->addDataset('signatures_alert', 'GAUGE', 0) ->addDataset('s0signatures_alert', 'GAUGE', 0) @@ -244,12 +242,12 @@ 's8signatures_alert' => $returned['vp.signatures_alert'], 's9signatures_alert' => $returned['sdp.signatures_alert'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate reg keys mod stats -$rrd_name = ['app', $name, $app_id, 'reg_keys_mod']; +$rrd_name = ['app', $name, $app->app_id, 'reg_keys_mod']; $rrd_def_reg_keys_mod = RrdDefinition::make() ->addDataset('reg_keys_mod', 'GAUGE', 0) ->addDataset('s0regkeysmod', 'GAUGE', 0) @@ -275,12 +273,12 @@ 's8regkeysmod' => $returned['vp.registry_keys_modified'], 's9regkeysmod' => $returned['sdp.registry_keys_modified'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate crash issues stats -$rrd_name = ['app', $name, $app_id, 'crash_issues']; +$rrd_name = ['app', $name, $app->app_id, 'crash_issues']; $rrd_def_crash_issues = RrdDefinition::make() ->addDataset('crash_issues', 'GAUGE', 0) ->addDataset('s0crash_issues', 'GAUGE', 0) @@ -306,12 +304,12 @@ 's8crash_issues' => $returned['vp.crash_issues'], 's9crash_issues' => $returned['sdp.crash_issues'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate anti issues stats -$rrd_name = ['app', $name, $app_id, 'anti_issues']; +$rrd_name = ['app', $name, $app->app_id, 'anti_issues']; $rrd_def_anti_issues = RrdDefinition::make() ->addDataset('anti_issues', 'GAUGE', 0) ->addDataset('s0anti_issues', 'GAUGE', 0) @@ -337,12 +335,12 @@ 's8anti_issues' => $returned['vp.anti_issues'], 's9anti_issues' => $returned['sdp.anti_issues'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate files written stats -$rrd_name = ['app', $name, $app_id, 'files_written']; +$rrd_name = ['app', $name, $app->app_id, 'files_written']; $rrd_def_files_written = RrdDefinition::make() ->addDataset('files_written', 'GAUGE', 0) ->addDataset('s0files_written', 'GAUGE', 0) @@ -368,12 +366,12 @@ 's8files_written' => $returned['vp.files_written'], 's9files_written' => $returned['sdp.files_written'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate malscore stats -$rrd_name = ['app', $name, $app_id, 'malscore']; +$rrd_name = ['app', $name, $app->app_id, 'malscore']; $rrd_def_malscore = RrdDefinition::make() ->addDataset('malscore', 'GAUGE', 0) ->addDataset('s0malscore', 'GAUGE', 0) @@ -399,12 +397,12 @@ 's8malscore' => $returned['vp.malscore'], 's9malscore' => $returned['sdp.malscore'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate severity stats -$rrd_name = ['app', $name, $app_id, 'severity']; +$rrd_name = ['app', $name, $app->app_id, 'severity']; $rrd_def_severity = RrdDefinition::make() ->addDataset('severity', 'GAUGE', 0) ->addDataset('s0severity', 'GAUGE', 0) @@ -430,12 +428,12 @@ 's8severity' => $returned['vp.severity'], 's9severity' => $returned['sdp.severity'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_severity, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_severity, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate confidence stats -$rrd_name = ['app', $name, $app_id, 'confidence']; +$rrd_name = ['app', $name, $app->app_id, 'confidence']; $rrd_def_confidence = RrdDefinition::make() ->addDataset('confidence', 'GAUGE', 0) ->addDataset('s0confidence', 'GAUGE', 0) @@ -461,12 +459,12 @@ 's8confidence' => $returned['vp.confidence'], 's9confidence' => $returned['sdp.confidence'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); // aggregate weight stats -$rrd_name = ['app', $name, $app_id, 'weight']; +$rrd_name = ['app', $name, $app->app_id, 'weight']; $rrd_def_weight = RrdDefinition::make() ->addDataset('weight', 'GAUGE', 0) ->addDataset('s0weight', 'GAUGE', 0) @@ -492,7 +490,7 @@ 's8weight' => $returned['vp.weight'], 's9weight' => $returned['sdp.weight'], ]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $metrics = array_merge($metrics, $fields); @@ -516,7 +514,7 @@ foreach ($returned['pkg_stats'] as $pkg => $stats) { $found_packages['pkg-dropped_files___-___-' . $pkg] = $pkg; - $rrd_name = ['app', $name, $app_id, 'pkg___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg___-___', $pkg]; $fields = [ 'tasks' => $returned['pkg_stats'][$pkg]['tasks'], 'pending' => null, @@ -529,10 +527,10 @@ 'failed_analysis' => $returned['pkg_stats'][$pkg]['failed_analysis'], 'failed_processing' => $returned['pkg_stats'][$pkg]['failed_processing'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_pkg, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_pkg, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-dropped_files___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-dropped_files___-___', $pkg]; $fields = [ 'dropped_files' => $returned['pkg_stats'][$pkg]['dropped_files'], 's0dropped_files' => $returned['pkg_stats'][$pkg]['min.dropped_files'], @@ -546,10 +544,10 @@ 's8dropped_files' => $returned['pkg_stats'][$pkg]['vp.dropped_files'], 's9dropped_files' => $returned['pkg_stats'][$pkg]['sdp.dropped_files'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-running_processes___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-running_processes___-___', $pkg]; $fields = [ 'running_processes' => $returned['pkg_stats'][$pkg]['running_processes'], 's0running_processes' => $returned['pkg_stats'][$pkg]['min.running_processes'], @@ -563,10 +561,10 @@ 's8running_processes' => $returned['pkg_stats'][$pkg]['vp.running_processes'], 's9running_processes' => $returned['pkg_stats'][$pkg]['sdp.running_processes'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-api_calls___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-api_calls___-___', $pkg]; $fields = [ 'api_calls' => $returned['pkg_stats'][$pkg]['api_calls'], 's0api_calls' => $returned['pkg_stats'][$pkg]['min.api_calls'], @@ -580,10 +578,10 @@ 's8api_calls' => $returned['pkg_stats'][$pkg]['vp.api_calls'], 's9api_calls' => $returned['pkg_stats'][$pkg]['sdp.api_calls'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-domains___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-domains___-___', $pkg]; $fields = [ 'domains' => $returned['pkg_stats'][$pkg]['domains'], 's0domains' => $returned['pkg_stats'][$pkg]['min.domains'], @@ -597,10 +595,10 @@ 's8domains' => $returned['pkg_stats'][$pkg]['vp.domains'], 's9domains' => $returned['pkg_stats'][$pkg]['sdp.domains'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-signatures_total___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-signatures_total___-___', $pkg]; $fields = [ 'signatures_total' => $returned['pkg_stats'][$pkg]['signatures_total'], 's0signatures_total' => $returned['pkg_stats'][$pkg]['min.signatures_total'], @@ -614,10 +612,10 @@ 's8signatures_total' => $returned['pkg_stats'][$pkg]['vp.signatures_total'], 's9signatures_total' => $returned['pkg_stats'][$pkg]['sdp.signatures_total'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-signatures_alert___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-signatures_alert___-___', $pkg]; $fields = [ 'signatures_alert' => $returned['pkg_stats'][$pkg]['signatures_alert'], 's0signatures_alert' => $returned['pkg_stats'][$pkg]['min.signatures_alert'], @@ -631,10 +629,10 @@ 's8signatures_alert' => $returned['pkg_stats'][$pkg]['vp.signatures_alert'], 's9signatures_alert' => $returned['pkg_stats'][$pkg]['sdp.signatures_alert'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-reg_keys_mod___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-reg_keys_mod___-___', $pkg]; $fields = [ 'reg_keys_mod' => $returned['pkg_stats'][$pkg]['registry_keys_modified'], 's0regkeysmod' => $returned['pkg_stats'][$pkg]['min.registry_keys_modified'], @@ -648,10 +646,10 @@ 's8regkeysmod' => $returned['pkg_stats'][$pkg]['vp.registry_keys_modified'], 's9regkeysmod' => $returned['pkg_stats'][$pkg]['sdp.registry_keys_modified'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-crash_issues___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-crash_issues___-___', $pkg]; $fields = [ 'crash_issues' => $returned['pkg_stats'][$pkg]['crash_issues'], 's0crash_issues' => $returned['pkg_stats'][$pkg]['min.crash_issues'], @@ -665,10 +663,10 @@ 's8crash_issues' => $returned['pkg_stats'][$pkg]['vp.crash_issues'], 's9crash_issues' => $returned['pkg_stats'][$pkg]['sdp.crash_issues'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-anti_issues___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-anti_issues___-___', $pkg]; $fields = [ 'anti_issues' => $returned['pkg_stats'][$pkg]['anti_issues'], 's0anti_issues' => $returned['pkg_stats'][$pkg]['min.anti_issues'], @@ -682,10 +680,10 @@ 's8anti_issues' => $returned['pkg_stats'][$pkg]['vp.anti_issues'], 's9anti_issues' => $returned['pkg_stats'][$pkg]['sdp.anti_issues'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-files_written___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-files_written___-___', $pkg]; $fields = [ 'files_written' => $returned['pkg_stats'][$pkg]['files_written'], 's0files_written' => $returned['pkg_stats'][$pkg]['min.files_written'], @@ -699,10 +697,10 @@ 's8files_written' => $returned['pkg_stats'][$pkg]['vp.files_written'], 's9files_written' => $returned['pkg_stats'][$pkg]['sdp.files_written'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-malscore___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-malscore___-___', $pkg]; $fields = [ 'malscore' => $returned['pkg_stats'][$pkg]['malscore'], 's0malscore' => $returned['pkg_stats'][$pkg]['min.malscore'], @@ -716,10 +714,10 @@ 's8malscore' => $returned['pkg_stats'][$pkg]['vp.malscore'], 's9malscore' => $returned['pkg_stats'][$pkg]['sdp.malscore'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-confidence___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-confidence___-___', $pkg]; $fields = [ 'confidence' => $returned['pkg_stats'][$pkg]['confidence'], 's0confidence' => $returned['pkg_stats'][$pkg]['min.confidence'], @@ -733,10 +731,10 @@ 's8confidence' => $returned['pkg_stats'][$pkg]['vp.confidence'], 's9confidence' => $returned['pkg_stats'][$pkg]['sdp.confidence'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-weight___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-weight___-___', $pkg]; $fields = [ 'weight' => $returned['pkg_stats'][$pkg]['weight'], 's0weight' => $returned['pkg_stats'][$pkg]['min.weight'], @@ -750,7 +748,7 @@ 's8weight' => $returned['pkg_stats'][$pkg]['vp.weight'], 's9weight' => $returned['pkg_stats'][$pkg]['sdp.weight'], ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } @@ -761,7 +759,7 @@ if (! isset($found_packages[$current_package])) { echo $pkg . " not handled, zeroing states for this timeslot\n"; - $rrd_name = ['app', $name, $app_id, 'pkg___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg___-___', $pkg]; $fields = [ 'tasks' => 0, 'pending' => null, @@ -774,10 +772,10 @@ 'failed_analysis' => 0, 'failed_processing' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_pkg, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_pkg, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-dropped_files___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-dropped_files___-___', $pkg]; $fields = [ 'dropped_files' => 0, 's0dropped_files' => 0, @@ -791,10 +789,10 @@ 's8dropped_files' => 0, 's9dropped_files' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_dropped_files, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-running_processes___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-running_processes___-___', $pkg]; $fields = [ 'running_processes' => 0, 's0running_processes' => 0, @@ -808,10 +806,10 @@ 's8running_processes' => 0, 's9running_processes' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_running_processes, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-api_calls___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-api_calls___-___', $pkg]; $fields = [ 'api_calls' => 0, 's0api_calls' => 0, @@ -825,10 +823,10 @@ 's8api_calls' => 0, 's9api_calls' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_api_calls, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-domains___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-domains___-___', $pkg]; $fields = [ 'domains' => 0, 's0domains' => 0, @@ -842,10 +840,10 @@ 's8domains' => 0, 's9domains' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_domains, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-signatures_total___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-signatures_total___-___', $pkg]; $fields = [ 'signatures_total' => 0, 's0signatures_total' => 0, @@ -859,10 +857,10 @@ 's8signatures_total' => 0, 's9signatures_total' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_total, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-signatures_alert___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-signatures_alert___-___', $pkg]; $fields = [ 'signatures_alert' => 0, 's0signatures_alert' => 0, @@ -876,10 +874,10 @@ 's8signatures_alert' => 0, 's9signatures_alert' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_signatures_alert, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-reg_keys_mod___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-reg_keys_mod___-___', $pkg]; $fields = [ 'reg_keys_mod' => 0, 's0regkeysmod' => 0, @@ -893,10 +891,10 @@ 's8regkeysmod' => 0, 's9regkeysmod' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_reg_keys_mod, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-crash_issues___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-crash_issues___-___', $pkg]; $fields = [ 'crash_issues' => 0, 's0crash_issues' => 0, @@ -910,10 +908,10 @@ 's8crash_issues' => 0, 's9crash_issues' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_crash_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-anti_issues___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-anti_issues___-___', $pkg]; $fields = [ 'anti_issues' => 0, 's0anti_issues' => 0, @@ -927,10 +925,10 @@ 's8anti_issues' => 0, 's9anti_issues' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_anti_issues, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-files_written___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-files_written___-___', $pkg]; $fields = [ 'files_written' => 0, 's0files_written' => 0, @@ -944,10 +942,10 @@ 's8files_written' => 0, 's9files_written' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_files_written, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-malscore___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-malscore___-___', $pkg]; $fields = [ 'malscore' => 0, 's0malscore' => 0, @@ -961,10 +959,10 @@ 's8malscore' => 0, 's9malscore' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_malscore, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-confidence___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-confidence___-___', $pkg]; $fields = [ 'confidence' => 0, 's0confidence' => 0, @@ -978,10 +976,10 @@ 's8confidence' => 0, 's9confidence' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_confidence, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $rrd_name = ['app', $name, $app_id, 'pkg-weight___-___', $pkg]; + $rrd_name = ['app', $name, $app->app_id, 'pkg-weight___-___', $pkg]; $fields = [ 'weight' => 0, 's0weight' => 0, @@ -995,7 +993,7 @@ 's8weight' => 0, 's9weight' => 0, ]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def_weight, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } else { echo $pkg . " handled, skipping zeroing this timeslot\n"; diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php index 890aa1aa33c0..48daac3ee38e 100644 --- a/includes/polling/applications/ceph.inc.php +++ b/includes/polling/applications/ceph.inc.php @@ -25,8 +25,6 @@ continue; } [$pool,$ops,$wrbytes,$rbytes] = explode(':', $line); - $rrd_name = ['app', $name, $app->app_id, 'pool', $pool]; - echo "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; $fields = [ 'ops' => $ops, @@ -34,7 +32,13 @@ 'rbytes' => $rbytes, ]; $metrics["pool_$pool"] = $fields; - $tags = compact('name', 'app_id', 'pool', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'pool' => $pool, + 'rrd_name' => ['app', $name, $app->app_id, 'pool', $pool], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); } } elseif ($section == 'osdperformance') { @@ -47,15 +51,19 @@ continue; } [$osd,$apply,$commit] = explode(':', $line); - $rrd_name = ['app', $name, $app->app_id, 'osd', $osd]; - echo "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; $fields = [ 'apply_ms' => $apply, 'commit_ms' => $commit, ]; $metrics["osd_$osd"] = $fields; - $tags = compact('name', 'app_id', 'osd', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'osd' => $osd, + 'rrd_name' => ['app', $name, $app->app_id, 'osd', $osd], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); } } elseif ($section == 'df') { @@ -69,8 +77,6 @@ continue; } [$df,$avail,$used,$objects] = explode(':', $line); - $rrd_name = ['app', $name, $app->app_id, 'df', $df]; - echo "Ceph Pool DF: $df, Avail: $avail, Used: $used, Objects: $objects\n"; $fields = [ 'avail' => $avail, @@ -78,7 +84,13 @@ 'objects' => $objects, ]; $metrics["df_$df"] = $fields; - $tags = compact('name', 'app_id', 'df', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'df' => $df, + 'rrd_name' => ['app', $name, $app->app_id, 'df', $df], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); } } diff --git a/includes/polling/applications/chronyd.inc.php b/includes/polling/applications/chronyd.inc.php index 1e218be685bc..5c6e1b12531a 100644 --- a/includes/polling/applications/chronyd.inc.php +++ b/includes/polling/applications/chronyd.inc.php @@ -41,7 +41,6 @@ 'update_interval' => $chronyd['tracking']['update_interval'], ]; -// $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/exim-stats.inc.php b/includes/polling/applications/exim-stats.inc.php index a38159889703..1691dd5f2738 100644 --- a/includes/polling/applications/exim-stats.inc.php +++ b/includes/polling/applications/exim-stats.inc.php @@ -28,7 +28,6 @@ [$frozen, $queue] = explode("\n", $stats); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('frozen', 'GAUGE', 0) ->addDataset('queue', 'GAUGE', 0); @@ -38,6 +37,11 @@ 'queue' => intval(trim($queue, '"')), ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $stats, $fields); diff --git a/includes/polling/applications/freeradius.inc.php b/includes/polling/applications/freeradius.inc.php index 330295255143..dec2167697e2 100644 --- a/includes/polling/applications/freeradius.inc.php +++ b/includes/polling/applications/freeradius.inc.php @@ -22,7 +22,6 @@ } //FreeRADIUS-Total-Access -$rrd_name = ['app', $name, 'access', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('accepts', 'DERIVE', 0, 125000000000) @@ -35,11 +34,16 @@ 'challenges' => $freeradius['FreeRADIUS-Total-Access-Challenges'], ]; $metrics['access'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'access', + 'rrd_name' => ['app', $name, 'access', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Total-Auth -$rrd_name = ['app', $name, 'auth', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('responses', 'DERIVE', 0, 125000000000) ->addDataset('duplicate_requests', 'DERIVE', 0, 125000000000) @@ -56,11 +60,16 @@ 'unknown_types' => $freeradius['FreeRADIUS-Total-Auth-Unknown-Types'], ]; $metrics['auth'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'auth', + 'rrd_name' => ['app', $name, 'auth', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Total-Acct -$rrd_name = ['app', $name, 'acct', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('responses', 'DERIVE', 0, 125000000000) @@ -79,11 +88,16 @@ 'unknown_types' => $freeradius['FreeRADIUS-Total-Acct-Unknown-Types'], ]; $metrics['acct'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'acct', + 'rrd_name' => ['app', $name, 'acct', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Total-Proxy-Access -$rrd_name = ['app', $name, 'proxy_access', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('accepts', 'DERIVE', 0, 125000000000) @@ -96,11 +110,16 @@ 'challenges' => $freeradius['FreeRADIUS-Total-Proxy-Access-Challenges'], ]; $metrics['proxy_access'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'proxy_access', + 'rrd_name' => ['app', $name, 'proxy_access', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Total-Proxy-Auth -$rrd_name = ['app', $name, 'proxy_auth', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('responses', 'DERIVE', 0, 125000000000) ->addDataset('duplicate_requests', 'DERIVE', 0, 125000000000) @@ -117,11 +136,16 @@ 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Unknown-Types'], ]; $metrics['proxy_auth'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'proxy_auth', + 'rrd_name' => ['app', $name, 'proxy_auth', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Total-Proxy-Acct -$rrd_name = ['app', $name, 'proxy_acct', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('responses', 'DERIVE', 0, 125000000000) @@ -140,7 +164,13 @@ 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Unknown-Types'], ]; $metrics['proxy_acct'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'proxy_acct', + 'rrd_name' => ['app', $name, 'proxy_acct', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //FreeRADIUS-Queue @@ -163,7 +193,13 @@ 'pps_out' => $freeradius['FreeRADIUS-Queue-PPS-Out'], ]; $metrics['queue'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'queue', + 'rrd_name' => ['app', $name, 'queue', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $rawdata, $metrics); diff --git a/includes/polling/applications/freeswitch.inc.php b/includes/polling/applications/freeswitch.inc.php index 272e3e760d5d..65de9d4f133b 100644 --- a/includes/polling/applications/freeswitch.inc.php +++ b/includes/polling/applications/freeswitch.inc.php @@ -20,7 +20,6 @@ $freeswitch[$var] = $value; } // Freeswitch stats -$rrd_name = ['app', $name, 'stats', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('calls', 'GAUGE', 0, 10000) ->addDataset('channels', 'GAUGE', 0, 10000) @@ -38,8 +37,13 @@ 'out_failed' => $freeswitch['OutFailed'], 'out_okay' => $freeswitch['OutTotal'] - $freeswitch['OutFailed'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, 'stats', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $rawdata, $fields); -unset($lines, $freeswitch, $rrd_name, $rrd_def, $fields, $tags); +unset($lines, $freeswitch, $rrd_def, $fields, $tags); diff --git a/includes/polling/applications/gpsd.inc.php b/includes/polling/applications/gpsd.inc.php index 97148ac93cc2..f0fd888eb5eb 100755 --- a/includes/polling/applications/gpsd.inc.php +++ b/includes/polling/applications/gpsd.inc.php @@ -121,7 +121,6 @@ // Generate RRD Def - $rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('mode', 'GAUGE', 0, 4) ->addDataset('hdop', 'GAUGE', 0, 100) @@ -130,7 +129,12 @@ ->addDataset('satellites_used', 'GAUGE', 0, 40); // Update Application - $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); if (! empty($agent_data['app'][$name])) { diff --git a/includes/polling/applications/hv-monitor.inc.php b/includes/polling/applications/hv-monitor.inc.php index 87eb7ac2a788..f5f00736d1c4 100644 --- a/includes/polling/applications/hv-monitor.inc.php +++ b/includes/polling/applications/hv-monitor.inc.php @@ -4,8 +4,6 @@ use LibreNMS\RRD\RrdDefinition; $name = 'hv-monitor'; -$app_id = $app['app_id']; - try { $return_data = json_app_get($device, 'hv-monitor')['data']; } catch (JsonAppException $e) { @@ -139,8 +137,8 @@ 'coll' => $return_data['totals']['coll'], ]; -$rrd_name = ['app', $name, $app_id]; -$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; +$rrd_name = ['app', $name, $app->app_id]; +$tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $totals_fields); // @@ -235,8 +233,8 @@ 'coll' => $vm_info['coll'], ]; - $rrd_name = ['app', $name, $app_id, 'vm', $vm]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $vm_rrd_def, 'rrd_name' => $rrd_name]; + $rrd_name = ['app', $name, $app->app_id, 'vm', $vm]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $vm_rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $vm_fields); } sort($VMs); @@ -278,8 +276,8 @@ 'freqs' => $disk_info['freqs'], ]; - $rrd_name = ['app', $name, $app_id, 'vmdisk', $vm, '__-__', $disk]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $disk_rrd_def, 'rrd_name' => $rrd_name]; + $rrd_name = ['app', $name, $app->app_id, 'vmdisk', $vm, '__-__', $disk]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $disk_rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $disk_fields); } sort($vm_disks); @@ -323,8 +321,8 @@ 'coll' => $if_info['coll'], ]; - $rrd_name = ['app', $name, $app_id, 'vmif', $vm, '__-__', $vm_if]; - $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $if_rrd_def, 'rrd_name' => $rrd_name]; + $rrd_name = ['app', $name, $app->app_id, 'vmif', $vm, '__-__', $vm_if]; + $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $if_rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $if_fields); } diff --git a/includes/polling/applications/icecast.inc.php b/includes/polling/applications/icecast.inc.php index 946c8f5ebc24..2802c148e375 100644 --- a/includes/polling/applications/icecast.inc.php +++ b/includes/polling/applications/icecast.inc.php @@ -26,7 +26,6 @@ unset($lines); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('cpu', 'GAUGE', 0, 100) ->addDataset('kbyte', 'GAUGE', 0, 125000000000) @@ -38,7 +37,12 @@ 'openfiles' => (int) $icecast['Open files'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/linux_softnet_stat.inc.php b/includes/polling/applications/linux_softnet_stat.inc.php index befd85f08b84..5ded00a7519c 100644 --- a/includes/polling/applications/linux_softnet_stat.inc.php +++ b/includes/polling/applications/linux_softnet_stat.inc.php @@ -14,7 +14,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('backlog_length', 'GAUGE') ->addDataset('cpu_collision', 'COUNTER') @@ -38,7 +37,12 @@ 'budget_usecs' => $data['budget_usecs'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); $app->data = ['budget' => $data['budget'], 'budget_usecs' => $data['budget_usecs']]; update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/mailcow-postfix.inc.php b/includes/polling/applications/mailcow-postfix.inc.php index f2b8c474a69f..fcf7b294e2bd 100644 --- a/includes/polling/applications/mailcow-postfix.inc.php +++ b/includes/polling/applications/mailcow-postfix.inc.php @@ -33,8 +33,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; - $rrd_def = RrdDefinition::make() ->addDataset('received', 'GAUGE', 0) ->addDataset('delivered', 'GAUGE', 0) @@ -70,6 +68,11 @@ 'recipienthostsdomains' => $mailcow_postfix['data']['recipienthostsdomains'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/mailscanner.inc.php b/includes/polling/applications/mailscanner.inc.php index cdbb05b1da28..f83f1cc69673 100644 --- a/includes/polling/applications/mailscanner.inc.php +++ b/includes/polling/applications/mailscanner.inc.php @@ -12,7 +12,6 @@ [$msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus] = explode("\n", $mailscanner); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('msg_recv', 'COUNTER', 0, 125000000000) ->addDataset('msg_rejected', 'COUNTER', 0, 12500000000) @@ -32,6 +31,11 @@ 'virus' => $virus, ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $mailscanner, $fields); diff --git a/includes/polling/applications/memcached.inc.php b/includes/polling/applications/memcached.inc.php index 8c3d98c85c5a..02b7dfb61301 100644 --- a/includes/polling/applications/memcached.inc.php +++ b/includes/polling/applications/memcached.inc.php @@ -22,7 +22,6 @@ echo ' memcached(' . $app->app_instance . ')'; $data = $data[$app->app_instance] ?? reset($data); // specified instance or just the first one -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('uptime', 'GAUGE', 0, 125000000000) ->addDataset('threads', 'GAUGE', 0, 125000000000) @@ -64,7 +63,11 @@ 'bytes_written' => $data['bytes_written'] ?? null, ]; -$app_id = $app->app_id; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, empty($data) ? 'ERROR: No Data' : 'OK', $fields); diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index 36cbec8011da..fe03a9976d83 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -100,6 +100,12 @@ $data = explode("\n", $mysql); +if (count($data) < 80) { + echo " Incorrect number of datapoints returned from device, skipping\n"; + + return; +} + $map = []; foreach ($data as $str) { [$key, $value] = explode(':', $str); @@ -195,7 +201,12 @@ ->addDataset('CUMi', 'DERIVE', 0, 125000000000) ->addDataset('SlLa', 'GAUGE', 0, 125000000000); -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); // Process state statistics @@ -218,7 +229,6 @@ 'State_other' => 'dh', ]; -$rrd_name = ['app', $name, $app->app_id, 'status']; $rrd_def = new RrdDefinition(); // because this sends different names for rrd and compared to other datastores, disable $fields name checks $rrd_def->disableNameChecking(); @@ -229,7 +239,12 @@ $rrd_def->addDataset($id, 'GAUGE', 0, 125000000000); } $metrics += $fields; -$status = true; -$tags = compact('name', 'app_id', 'status', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'status' => true, + 'rrd_name' => ['app', $name, $app->app_id, 'status'], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $mysql, $metrics); diff --git a/includes/polling/applications/nfs-stats.inc.php b/includes/polling/applications/nfs-stats.inc.php index 4341430e10c3..21c3c16a3f66 100644 --- a/includes/polling/applications/nfs-stats.inc.php +++ b/includes/polling/applications/nfs-stats.inc.php @@ -7,7 +7,6 @@ $nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB'); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('total', 'GAUGE', 0) ->addDataset('null', 'GAUGE', 0) @@ -44,8 +43,13 @@ 'fsstat' => $data[14], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $nfsstats, $fields); -unset($nfsstats, $rrd_name, $rrd_def, $data, $fields, $tags); +unset($nfsstats, $rrd_def, $data, $fields, $tags); diff --git a/includes/polling/applications/nfs-v3-stats.inc.php b/includes/polling/applications/nfs-v3-stats.inc.php index fcbc7f880794..ac7e3724f6d1 100644 --- a/includes/polling/applications/nfs-v3-stats.inc.php +++ b/includes/polling/applications/nfs-v3-stats.inc.php @@ -7,7 +7,6 @@ $nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB'); -$rrd_name = ['app', 'nfs-stats', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('rc_hits', 'GAUGE', 0) ->addDataset('rc_misses', 'GAUGE', 0) @@ -120,8 +119,13 @@ 'proc3_commit' => $data[52], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', 'nfs-stats', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $nfsstats, $fields); -unset($nfsstats, $rrd_name, $rrd_def, $data, $fields, $tags); +unset($nfsstats, $rrd_def, $data, $fields, $tags); diff --git a/includes/polling/applications/nginx.inc.php b/includes/polling/applications/nginx.inc.php index 0012b96b24ca..c675e8bf7f7c 100644 --- a/includes/polling/applications/nginx.inc.php +++ b/includes/polling/applications/nginx.inc.php @@ -10,12 +10,16 @@ // Polls nginx statistics from script via SNMP $nginx = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.3.1.2.5.110.103.105.110.120', '-Ovq'); } -$nginx = trim($nginx, '"'); +$nginx_data = array_map('rtrim', explode("\n", trim($nginx, '"'))); +if (count($nginx_data) !== 5) { + echo " Incorrect number of datapoints returned from device, skipping\n"; -[$active, $reading, $writing, $waiting, $req] = array_map('rtrim', explode("\n", $nginx)); + return; +} + +[$active, $reading, $writing, $waiting, $req] = $nginx_data; d_echo("active: $active reading: $reading writing: $writing waiting: $waiting Requests: $req\n"); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('Requests', 'DERIVE', 0, 125000000000) ->addDataset('Active', 'GAUGE', 0, 125000000000) @@ -31,9 +35,14 @@ 'Waiting' => $waiting, ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); -update_application($app, $nginx, $fields); +update_application($app, trim($nginx, '"'), $fields); // Unset the variables we set here -unset($nginx, $active, $reading, $writing, $waiting, $req, $rrd_name, $rrd_def, $tags); +unset($nginx, $active, $reading, $writing, $waiting, $req, $rrd_def, $tags); diff --git a/includes/polling/applications/ntp-client.inc.php b/includes/polling/applications/ntp-client.inc.php index 764ac6b19f1d..e67598dd6dc8 100644 --- a/includes/polling/applications/ntp-client.inc.php +++ b/includes/polling/applications/ntp-client.inc.php @@ -24,7 +24,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('offset', 'GAUGE', -1000, 1000) ->addDataset('frequency', 'GAUGE', -1000, 1000) @@ -40,6 +39,11 @@ 'stability' => $ntp['data']['clk_wander'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/ntp-server.inc.php b/includes/polling/applications/ntp-server.inc.php index e2ab4f9d849a..809b35d8da15 100644 --- a/includes/polling/applications/ntp-server.inc.php +++ b/includes/polling/applications/ntp-server.inc.php @@ -27,7 +27,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('stratum', 'GAUGE', 0, 1000) ->addDataset('offset', 'GAUGE', -1000, 1000) @@ -61,6 +60,11 @@ 'packets_sent' => $ntp['data']['packets_sent'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/opengridscheduler.inc.php b/includes/polling/applications/opengridscheduler.inc.php index 79195a60cecf..e85e70c643f3 100644 --- a/includes/polling/applications/opengridscheduler.inc.php +++ b/includes/polling/applications/opengridscheduler.inc.php @@ -24,7 +24,6 @@ $ogs_data = snmp_get($device, $oid, '-Oqv'); // define the rrd -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('running_jobs', 'GAUGE', 0) ->addDataset('pending_jobs', 'GAUGE', 0) @@ -41,9 +40,14 @@ ]; // push the data in an array and into the rrd -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $ogs_data, $fields); // cleanup -unset($ogs_data, $rrd_name, $rrd_def, $data, $fields, $tags); +unset($ogs_data, $rrd_def, $data, $fields, $tags); diff --git a/includes/polling/applications/opensips.inc.php b/includes/polling/applications/opensips.inc.php index 13f11ebaf1be..69052bb2a6cf 100644 --- a/includes/polling/applications/opensips.inc.php +++ b/includes/polling/applications/opensips.inc.php @@ -26,8 +26,6 @@ unset($lines); -$rrd_name = ['app', $name, $app->app_id]; - $rrd_def = RrdDefinition::make() ->addDataset('load', 'GAUGE', 0, 100) ->addDataset('total_memory', 'GAUGE', 0, 125000000000) @@ -43,7 +41,12 @@ 'openfiles' => (int) $opensips['Open files'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/powerdns-recursor.inc.php b/includes/polling/applications/powerdns-recursor.inc.php index e5f1a8e4c804..032a99535aae 100644 --- a/includes/polling/applications/powerdns-recursor.inc.php +++ b/includes/polling/applications/powerdns-recursor.inc.php @@ -112,7 +112,8 @@ //decode and flatten the data $stats = []; - foreach (json_decode($data, true) as $stat) { + [$json_data] = explode("\n", $data, 2); + foreach (json_decode($json_data, true) as $stat) { $stats[$stat['name']] = $stat['value']; } d_echo($stats); @@ -130,10 +131,14 @@ } } - $rrd_name = ['app', 'powerdns', 'recursor', $app->app_id]; - $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', 'powerdns', 'recursor', $app->app_id], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); update_application($app, $data, $fields); } -unset($data, $stats, $rrd_def, $rrd_name, $rrd_keys, $tags, $fields); +unset($data, $stats, $rrd_def, $rrd_keys, $tags, $fields); diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php index 525bc20d1c89..0ba4e1a2f4d5 100644 --- a/includes/polling/applications/powerdns.inc.php +++ b/includes/polling/applications/powerdns.inc.php @@ -85,7 +85,6 @@ d_echo($powerdns); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make(); $fields = []; foreach ($powerdns_metrics as $ds => $metric) { @@ -93,6 +92,11 @@ $fields[$ds] = isset($powerdns[$metric]) ? $powerdns[$metric] : 'U'; } -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, json_encode($powerdns), $fields); diff --git a/includes/polling/applications/powermon.inc.php b/includes/polling/applications/powermon.inc.php index 59c2e79b0a75..163d45fe6bd7 100644 --- a/includes/polling/applications/powermon.inc.php +++ b/includes/polling/applications/powermon.inc.php @@ -34,7 +34,6 @@ // should be doing something with error codes/messages returned in the snmp // result or will they be caught above? -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('watts-gauge', 'GAUGE', 0) ->addDataset('watts-abs', 'ABSOLUTE', 0) @@ -53,6 +52,11 @@ ); */ -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php index 0f046bd1d819..020adbb818b1 100644 --- a/includes/polling/applications/proxmox.inc.php +++ b/includes/polling/applications/proxmox.inc.php @@ -76,11 +76,6 @@ function proxmox_vm_exists($i, $c, &$pmxcache) [$vmid, $vmport, $vmpin, $vmpout, $vmdesc] = explode('/', $vm, 5); echo "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n"; - $rrd_proxmox_name = [ - 'pmxcluster' => $pmxcluster, - 'vmid' => $vmid, - 'vmport' => $vmport, - ]; $rrd_def = RrdDefinition::make() ->addDataset('INOCTETS', 'DERIVE', 0, 12500000000) ->addDataset('OUTOCTETS', 'DERIVE', 0, 12500000000); @@ -91,7 +86,19 @@ function proxmox_vm_exists($i, $c, &$pmxcache) $proxmox_metric_prefix = "pmxcluster{$pmxcluster}_vmid{$vmid}_vmport$vmport"; $metrics[$proxmox_metric_prefix] = $fields; - $tags = compact('name', 'app_id', 'pmxcluster', 'vmid', 'vmport', 'rrd_proxmox_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'pmxcluster' => $pmxcluster, + 'vmid' => $vmid, + 'vmport' => $vmport, + 'rrd_proxmox_name' => [ + 'pmxcluster' => $pmxcluster, + 'vmid' => $vmid, + 'vmport' => $vmport, + ], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) { diff --git a/includes/polling/applications/rrdcached.inc.php b/includes/polling/applications/rrdcached.inc.php index f5d07697ec77..ea995a37f47c 100644 --- a/includes/polling/applications/rrdcached.inc.php +++ b/includes/polling/applications/rrdcached.inc.php @@ -73,7 +73,6 @@ } } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('queue_length', 'GAUGE', 0) ->addDataset('updates_received', 'COUNTER', 0) @@ -94,8 +93,13 @@ } } -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $data, $fields); -unset($data, $rrd_name, $rrd_def, $fields, $tags); +unset($data, $rrd_def, $fields, $tags); diff --git a/includes/polling/applications/shoutcast.inc.php b/includes/polling/applications/shoutcast.inc.php index a2892af123af..7190c3f44f25 100644 --- a/includes/polling/applications/shoutcast.inc.php +++ b/includes/polling/applications/shoutcast.inc.php @@ -20,7 +20,6 @@ $data = explode(';', $server); [$host, $port] = explode(':', $data['0'], 2); - $rrd_name = ['app', $name, $app->app_id, $host . '_' . $port]; $rrd_def = RrdDefinition::make() ->addDataset('bitrate', 'GAUGE', 0, 125000000000) ->addDataset('traf_in', 'GAUGE', 0, 125000000000) @@ -43,7 +42,14 @@ ]; $metrics[$server] = $fields; - $tags = compact('name', 'app_id', 'host', 'port', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'host' => $host, + 'port' => $port, + 'rrd_name' => ['app', $name, $app->app_id, $host . '_' . $port], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); }//end if }//end foreach diff --git a/includes/polling/applications/ss.inc.php b/includes/polling/applications/ss.inc.php index 0861f7ab4d85..7a67ee196be2 100644 --- a/includes/polling/applications/ss.inc.php +++ b/includes/polling/applications/ss.inc.php @@ -12,35 +12,38 @@ $metrics = []; -/** - * Performs a data update and returns the updated metrics. - * - * @param string $app_id - * @param class $device - * @param array $fields - * @param array $metrics - * @param string $name - * @param string $polling_type - * @param class $rrd_def - * @param string $gen_type - * @return $metrics - */ -function ss_data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $gen_type) -{ - global $device; - - $rrd_name = [$polling_type, $name, $app_id, $gen_type]; - $metrics[$gen_type] = $fields; - $tags = [ - 'name' => $name, - 'app_id' => $app_id, - 'type' => $gen_type, - 'rrd_def' => $rrd_def, - 'rrd_name' => $rrd_name, - ]; - data_update($device, $polling_type, $tags, $fields); - - return $metrics; +// FIXME sigh +if (! function_exists('ss_data_update_helper')) { + /** + * Performs a data update and returns the updated metrics. + * + * @param string $app_id + * @param class $device + * @param array $fields + * @param array $metrics + * @param string $name + * @param string $polling_type + * @param class $rrd_def + * @param string $gen_type + * @return $metrics + */ + function ss_data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $gen_type) + { + global $device; + + $rrd_name = [$polling_type, $name, $app_id, $gen_type]; + $metrics[$gen_type] = $fields; + $tags = [ + 'name' => $name, + 'app_id' => $app_id, + 'type' => $gen_type, + 'rrd_def' => $rrd_def, + 'rrd_name' => $rrd_name, + ]; + data_update($device, $polling_type, $tags, $fields); + + return $metrics; + } } try { diff --git a/includes/polling/applications/suricata_extract.inc.php b/includes/polling/applications/suricata_extract.inc.php index 13f9bed649f9..5fa89c852ae4 100644 --- a/includes/polling/applications/suricata_extract.inc.php +++ b/includes/polling/applications/suricata_extract.inc.php @@ -14,7 +14,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('errors', 'GAUGE', 0) ->addDataset('ignored_host', 'GAUGE', 0) @@ -52,6 +51,11 @@ log_event('suricata_extract_submit errors found: ' . json_encode($data['last_errors']), $device, 'application', 5); } -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/systemd.inc.php b/includes/polling/applications/systemd.inc.php index 3f148f6975f2..6fad530fd3fa 100644 --- a/includes/polling/applications/systemd.inc.php +++ b/includes/polling/applications/systemd.inc.php @@ -12,35 +12,38 @@ $metrics = []; -/** - * Performs a data update and returns the updated metrics. - * - * @param string $app_id - * @param class $device - * @param array $fields - * @param array $metrics - * @param string $name - * @param string $polling_type - * @param class $rrd_def - * @param string $state_type - * @return $metrics - */ -function data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $state_type) -{ - global $device; - - $rrd_name = [$polling_type, $name, $app_id, $state_type]; - $metrics[$state_type] = $fields; - $tags = [ - 'name' => $name, - 'app_id' => $app_id, - 'type' => $state_type, - 'rrd_def' => $rrd_def, - 'rrd_name' => $rrd_name, - ]; - data_update($device, $polling_type, $tags, $fields); - - return $metrics; +// FIXME sigh +if (! function_exists('systemd_data_update_helper')) { + /** + * Performs a data update and returns the updated metrics. + * + * @param string $app_id + * @param class $device + * @param array $fields + * @param array $metrics + * @param string $name + * @param string $polling_type + * @param class $rrd_def + * @param string $state_type + * @return $metrics + */ + function systemd_data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $state_type) + { + global $device; + + $rrd_name = [$polling_type, $name, $app_id, $state_type]; + $metrics[$state_type] = $fields; + $tags = [ + 'name' => $name, + 'app_id' => $app_id, + 'type' => $state_type, + 'rrd_def' => $rrd_def, + 'rrd_name' => $rrd_name, + ]; + data_update($device, $polling_type, $tags, $fields); + + return $metrics; + } } // Grab systemd json data. @@ -82,7 +85,7 @@ function data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $r } $rrd_def->addDataset($field_name, 'GAUGE', 0); } - $metrics = data_update_helper($app->app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $state_type); + $metrics = systemd_data_update_helper($app->app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $state_type); } else { // Process systemd states that have three // levels of depth (sub) @@ -111,7 +114,7 @@ function data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $r $rrd_def->addDataset($field_name, 'GAUGE', 0); } $flat_type = $state_type . '_' . $sub_state_type; - $metrics = data_update_helper($app->app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $flat_type); + $metrics = systemd_data_update_helper($app->app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $flat_type); } } } diff --git a/includes/polling/applications/tinydns.inc.php b/includes/polling/applications/tinydns.inc.php index a0117e8d15f5..6002297bb78c 100644 --- a/includes/polling/applications/tinydns.inc.php +++ b/includes/polling/applications/tinydns.inc.php @@ -30,7 +30,6 @@ if (! empty($agent_data['app'][$name]) && $app->app_id > 0) { echo ' tinydns'; - $rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('a', 'COUNTER', 0, 125000000000) ->addDataset('ns', 'COUNTER', 0, 125000000000) @@ -81,7 +80,12 @@ 'noquery' => $noquery, ]; - $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); + $tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, + ]; data_update($device, 'app', $tags, $fields); update_application($app, $name, $fields); }//end if diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php index 477d3470ff70..422198f3e50d 100644 --- a/includes/polling/applications/unbound.inc.php +++ b/includes/polling/applications/unbound.inc.php @@ -20,7 +20,6 @@ $unbound[strtolower($var)] = $value; } //Unbound Queries -$rrd_name = ['app', $name, 'queries', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('type0', 'DERIVE', 0, 125000000000) ->addDataset('A', 'DERIVE', 0, 125000000000) @@ -61,10 +60,15 @@ 'other' => $unbound['num.query.type.other'], ]; $metrics['queries'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'queries', + 'rrd_name' => ['app', $name, 'queries', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //Unbound Cache -$rrd_name = ['app', $name, 'cache', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('queries', 'DERIVE', 0, 125000000000) ->addDataset('hits', 'DERIVE', 0, 125000000000) @@ -75,10 +79,15 @@ 'misses' => $unbound['total.num.cachemiss'], ]; $metrics['cache'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'cache', + 'rrd_name' => ['app', $name, 'cache', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //Unbound Operations - Total opcodes and three valuable return codes -$rrd_name = ['app', $name, 'operations', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('opcodeQuery', 'DERIVE', 0, 125000000000) ->addDataset('rcodeNOERROR', 'DERIVE', 0, 125000000000) @@ -91,11 +100,16 @@ 'rcodeNodata' => $unbound['num.answer.rcode.nodata'], ]; $metrics['operations'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'operations', + 'rrd_name' => ['app', $name, 'operations', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //Unbound requestlist -$rrd_name = ['app', $name, 'requestlist', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('max', 'DERIVE', 0, 125000000000) ->addDataset('overwritten', 'DERIVE', 0, 125000000000) @@ -106,11 +120,16 @@ 'exceeded' => $unbound['total.requestlist.exceeded'], ]; $metrics['requestlist'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'requestlist', + 'rrd_name' => ['app', $name, 'requestlist', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); //Unbound recursiontime -$rrd_name = ['app', $name, 'recursiontime', $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('avg', 'GAUGE', 0, 125000000000) ->addDataset('median', 'GAUGE', 0, 125000000000); @@ -119,9 +138,15 @@ 'median' => $unbound['total.recursion.time.median'], ]; $metrics['recursiontime'] = $fields; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'type' => 'recursiontime', + 'rrd_name' => ['app', $name, 'recursiontime', $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $rawdata, $metrics); -unset($lines, $unbound, $rrd_name, $rrd_def, $fields, $tags); +unset($lines, $unbound, $rrd_def, $fields, $tags); diff --git a/includes/polling/applications/ups-apcups.inc.php b/includes/polling/applications/ups-apcups.inc.php index a5cde0756ba4..cd81d8c48784 100644 --- a/includes/polling/applications/ups-apcups.inc.php +++ b/includes/polling/applications/ups-apcups.inc.php @@ -52,7 +52,6 @@ return; } -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('charge', 'GAUGE', 0, 100) ->addDataset('time_remaining', 'GAUGE', 0) @@ -72,6 +71,11 @@ 'load' => $json_return['data']['load'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index 8f44e775e5fd..a79ee2795002 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -66,7 +66,6 @@ $UPSAlarm ] = array_pad(explode("\n", $ups_nut), 23, 0); -$rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make() ->addDataset('charge', 'GAUGE', 0, 100) ->addDataset('battery_low', 'GAUGE', 0, 100) @@ -111,6 +110,11 @@ $fields[$sensor['state_name']] = $sensor['value']; } -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); update_application($app, $ups_nut, $fields); diff --git a/includes/polling/applications/voip-monitor.inc.php b/includes/polling/applications/voip-monitor.inc.php index e7b952edc982..aabeb201c1f3 100644 --- a/includes/polling/applications/voip-monitor.inc.php +++ b/includes/polling/applications/voip-monitor.inc.php @@ -26,8 +26,6 @@ unset($lines); -$rrd_name = ['app', $name, $app->app_id]; - $rrd_def = RrdDefinition::make() ->addDataset('cpu', 'GAUGE', 0, 100) ->addDataset('kbyte', 'GAUGE', 0, 125000000000) @@ -39,7 +37,12 @@ 'openfiles' => (int) $voip['Open files'], ]; -$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = [ + 'name' => $name, + 'app_id' => $app->app_id, + 'rrd_name' => ['app', $name, $app->app_id], + 'rrd_def' => $rrd_def, +]; data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/wireguard.inc.php b/includes/polling/applications/wireguard.inc.php index e88db7e2b5f4..6c6b1ea4f6bf 100644 --- a/includes/polling/applications/wireguard.inc.php +++ b/includes/polling/applications/wireguard.inc.php @@ -59,8 +59,6 @@ ? $client_data['minutes_since_last_handshake'] : null; - $rrd_name = [$polling_type, $name, $app->app_id, $finterface, $fclient]; - $fields = [ 'bytes_rcvd' => $bytes_rcvd, 'bytes_sent' => $bytes_sent, @@ -73,7 +71,7 @@ 'name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, - 'rrd_name' => $rrd_name, + 'rrd_name' => [$polling_type, $name, $app->app_id, $finterface, $fclient], ]; data_update($device, $polling_type, $tags, $fields); } diff --git a/misc/config_definitions.json b/misc/config_definitions.json index d30a9f24533b..79d0aa615842 100644 --- a/misc/config_definitions.json +++ b/misc/config_definitions.json @@ -4712,13 +4712,6 @@ "plugin_dir": { "type": "directory" }, - "poller_modules.core": { - "default": true, - "type": "boolean", - "validate": { - "value": "boolean|accepted" - } - }, "poller_modules.unix-agent": { "order": 420, "group": "poller", @@ -4726,6 +4719,13 @@ "default": false, "type": "boolean" }, + "poller_modules.core": { + "default": true, + "type": "boolean", + "validate": { + "value": "boolean|accepted" + } + }, "poller_modules.os": { "order": 320, "group": "poller", From 884fd3ee394407291756337a38a66f2836a34883 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 16 Oct 2023 06:23:29 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- includes/polling/applications/ss.inc.php | 16 ++++++++-------- includes/polling/applications/systemd.inc.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/includes/polling/applications/ss.inc.php b/includes/polling/applications/ss.inc.php index 7a67ee196be2..cdc9a3b414ae 100644 --- a/includes/polling/applications/ss.inc.php +++ b/includes/polling/applications/ss.inc.php @@ -17,14 +17,14 @@ /** * Performs a data update and returns the updated metrics. * - * @param string $app_id - * @param class $device - * @param array $fields - * @param array $metrics - * @param string $name - * @param string $polling_type - * @param class $rrd_def - * @param string $gen_type + * @param string $app_id + * @param class $device + * @param array $fields + * @param array $metrics + * @param string $name + * @param string $polling_type + * @param class $rrd_def + * @param string $gen_type * @return $metrics */ function ss_data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $gen_type) diff --git a/includes/polling/applications/systemd.inc.php b/includes/polling/applications/systemd.inc.php index 6fad530fd3fa..150d1667648f 100644 --- a/includes/polling/applications/systemd.inc.php +++ b/includes/polling/applications/systemd.inc.php @@ -17,14 +17,14 @@ /** * Performs a data update and returns the updated metrics. * - * @param string $app_id - * @param class $device - * @param array $fields - * @param array $metrics - * @param string $name - * @param string $polling_type - * @param class $rrd_def - * @param string $state_type + * @param string $app_id + * @param class $device + * @param array $fields + * @param array $metrics + * @param string $name + * @param string $polling_type + * @param class $rrd_def + * @param string $state_type * @return $metrics */ function systemd_data_update_helper($app_id, $fields, $metrics, $name, $polling_type, $rrd_def, $state_type)