fix: Add consistent output of name and app_id to Poller for all Applications (fixes #13641) (#13648)

* Add echo of name and app_id to all Applications

* Make echo not application specifc

* Fix echo

* Do spaces make StyleCI happy?

* Not spaces, but the type of quotes makes StyleCI happy
This commit is contained in:
Mark Westerterp
2022-01-06 12:08:52 +01:00
committed by GitHub
parent 8611d4074f
commit 8a6f158ab8
44 changed files with 21 additions and 82 deletions
+2 -1
View File
@@ -4,11 +4,12 @@ $app_rows = dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ?', [
if (count($app_rows) > 0) {
foreach ($app_rows as $app) {
echo 'Application: ' . $app['app_type'] . ', app_id=' . $app['app_id'];
$app_include = \LibreNMS\Config::get('install_dir') . '/includes/polling/applications/' . $app['app_type'] . '.inc.php';
if (is_file($app_include)) {
include $app_include;
} else {
echo $app['app_type'] . ' include missing! ';
echo 'ERROR: ' . $app_include . ' include file missing!';
}
}
echo "\n";
+1 -2
View File
@@ -5,6 +5,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'apache';
$app_id = $app['app_id'];
if (! empty($agent_data['app'][$name])) {
$apache = $agent_data['app'][$name];
} else {
@@ -13,8 +14,6 @@ if (! empty($agent_data['app'][$name])) {
$apache = snmp_get($device, $oid, $options);
}
echo ' apache';
[$total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec,
$bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start,
$score_reading, $score_writing, $score_keepalive, $score_dns,
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'asterisk';
$app_id = $app['app_id'];
echo "$name, app_id=$app_id ";
if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'bind';
$app_id = $app['app_id'];
echo " $name";
if (! empty($agent_data['app'][$name])) {
$bind = $agent_data['app'][$name];
} else {
+2 -1
View File
@@ -3,9 +3,10 @@
use LibreNMS\RRD\RrdDefinition;
$name = 'ceph';
$app_id = $app['app_id'];
if (! empty($agent_data['app'][$name])) {
$ceph_data = $agent_data['app'][$name];
$app_id = $app['app_id'];
$metrics = [];
foreach (explode('<', $ceph_data) as $section) {
@@ -6,8 +6,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'chronyd';
$app_id = $app['app_id'];
echo $name;
try {
$chronyd = json_app_get($device, $name, 1)['data'];
} catch (JsonAppException $e) {
+1 -1
View File
@@ -3,8 +3,8 @@
use LibreNMS\RRD\RrdDefinition;
$name = 'drbd';
$app_instance = $app['app_instance'];
$app_id = $app['app_id'];
$app_instance = $app['app_instance'];
$drbd_data = $agent_data['app'][$name][$app_instance];
foreach (explode('|', $drbd_data) as $part) {
[$stat, $val] = explode('=', $part);
@@ -27,8 +27,6 @@ $app_id = $app['app_id'];
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.101.120.105.109.45.115.116.97.116.115';
$stats = snmp_get($device, $oid, '-Oqv');
echo ' ' . $name;
[$frozen, $queue] = explode("\n", $stats);
$rrd_name = ['app', $name, $app_id];
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'fail2ban';
$app_id = $app['app_id'];
echo $name;
try {
$f2b = json_app_get($device, $name);
} catch (JsonAppParsingFailedException $e) {
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'fbsd-nfs-client';
$app_id = $app['app_id'];
echo $name;
try {
$nfs = json_app_get($device, 'fbsdnfsclient', 0);
} catch (JsonAppParsingFailedException $e) {
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'fbsd-nfs-server';
$app_id = $app['app_id'];
echo $name;
try {
$nfs = json_app_get($device, 'fbsdnfsserver');
} catch (JsonAppParsingFailedException $e) {
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'freeradius';
$app_id = $app['app_id'];
echo " $name";
if (! empty($agent_data['app'][$name])) {
$rawdata = $agent_data['app'][$name];
} else {
@@ -4,6 +4,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'freeswitch';
$app_id = $app['app_id'];
if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
@@ -59,8 +59,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'gpsd';
$app_id = $app['app_id'];
echo " $name\n";
if ($app_id > 0) {
if (! empty($agent_data['app'][$name])) {
$gpsd = $agent_data['app'][$name];
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'icecast';
$app_id = $app['app_id'];
echo "$name, app_id=$app_id ";
if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
@@ -25,8 +25,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'mailcow-postfix';
$app_id = $app['app_id'];
d_echo($name);
try {
$mailcow_postfix = json_app_get($device, $name);
} catch (JsonAppException $e) {
@@ -4,17 +4,15 @@
use LibreNMS\RRD\RrdDefinition;
$name = 'mailscannerV2';
$app_id = $app['app_id'];
$options = '-Oqv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.11.109.97.105.108.115.99.97.110.110.101.114';
$mailscanner = snmp_get($device, $oid, $options);
echo ' mailscanner';
[$msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus] = explode("\n", $mailscanner);
$name = 'mailscannerV2';
$app_id = $app['app_id'];
$rrd_name = ['app', $name, $app_id];
$rrd_def = RrdDefinition::make()
->addDataset('msg_recv', 'COUNTER', 0, 125000000000)
@@ -4,6 +4,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'memcached';
$app_id = $app['app_id'];
if (! empty($agent_data['app']['memcached'])) {
$data = $agent_data['app']['memcached'][$app['app_instance']];
} else {
@@ -12,7 +12,6 @@ if (! empty($agent_data['app'][$name])) {
$mysql = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.3.1.2.5.109.121.115.113.108', '-Ovq');
}
echo ' mysql';
$metrics = [];
// General Stats
@@ -16,14 +16,11 @@
use LibreNMS\RRD\RrdDefinition;
$name = 'nfs-server';
$app_id = $app['app_id'];
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.110.102.115.45.115.101.114.118.101.114';
echo ' ' . $name;
$nfsstats = snmp_get($device, $oid, '-Oqv');
$app_id = $app['app_id'];
// rrd names
$rrd_name = [];
$rrd_name['default'] = ['app', 'nfs-server-default', $app_id];
@@ -6,8 +6,6 @@ $name = 'nfsstat';
$app_id = $app['app_id'];
$oid = '.1.3.6.1.4.1.8072.1.3.2.4';
echo ' ' . $name;
$nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB');
$rrd_name = ['app', $name, $app_id];
@@ -6,8 +6,6 @@ $name = 'nfs-v3-stats';
$app_id = $app['app_id'];
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.110.102.115.115.116.97.116';
echo ' ' . $name;
$nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB');
$rrd_name = ['app', 'nfs-stats', $app_id];
+1 -2
View File
@@ -4,6 +4,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'nginx';
$app_id = $app['app_id'];
if (! empty($agent_data['app'][$name])) {
$nginx = $agent_data['app'][$name];
} else {
@@ -12,8 +13,6 @@ if (! empty($agent_data['app'][$name])) {
}
$nginx = trim($nginx, '"');
echo ' nginx';
[$active, $reading, $writing, $waiting, $req] = array_map('rtrim', explode("\n", $nginx));
d_echo("active: $active reading: $reading writing: $writing waiting: $waiting Requests: $req\n");
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'ntp-client';
$app_id = $app['app_id'];
echo $name;
try {
$ntp = json_app_get($device, $name);
} catch (JsonAppParsingFailedException $e) {
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'ntp-server';
$app_id = $app['app_id'];
echo $name;
try {
$ntp = json_app_get($device, $name);
} catch (JsonAppParsingFailedException $e) {
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'opensips';
$app_id = $app['app_id'];
echo "$name, app_id=$app_id ";
if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
@@ -6,8 +6,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'portactivity';
$app_id = $app['app_id'];
echo $name;
try {
$returned = json_app_get($device, 'portactivity', 1);
} catch (JsonAppException $e) { // Only doing the generic one as this has no non-JSON return
@@ -1,10 +1,10 @@
<?php
use LibreNMS\RRD\RrdDefinition;
$name = 'postfix';
$app_id = $app['app_id'];
use LibreNMS\RRD\RrdDefinition;
$options = '-Oqv';
$queueOID = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.5.109.97.105.108.113';
$detailOID = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.15.112.111.115.116.102.105.120.100.101.116.97.105.108.101.100';
@@ -1,11 +1,9 @@
<?php
$name = 'postgres';
$app_id = $app['app_id'];
use LibreNMS\RRD\RrdDefinition;
echo 'postgres';
$name = 'postgres';
$app_id = $app['app_id'];
$options = '-Oqv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.8.112.111.115.116.103.114.101.115';
@@ -27,8 +27,6 @@ $options = '-Oqv';
//NET-SNMP-EXTEND-MIB::nsExtendOutputFull."powerdns-dnsdist"
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.16.112.111.119.101.114.100.110.115.45.100.110.115.100.105.115.116';
d_echo($name);
$powerdns_dnsdist = snmp_walk($device, $oid, $options);
if (is_string($powerdns_dnsdist)) {
@@ -31,8 +31,6 @@ $data = '';
$name = 'powerdns-recursor';
$app_id = $app['app_id'];
echo ' ' . $name;
if ($agent_data['app'][$name]) {
$data = $agent_data['app'][$name];
} elseif (Config::has('apps.powerdns-recursor.api-key')) {
@@ -9,7 +9,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'powerdns';
$app_id = $app['app_id'];
$powerdns = [];
echo " $name";
// unused metrics:
// deferred-packetcache-inserts, deferred-packetcache-lookup, dnsupdate-answers, dnsupdate-changes, dnsupdate-queries, dnsupdate-refused, incoming-notifications
@@ -22,8 +22,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'powermon';
$app_id = $app['app_id'];
echo $name;
try {
$result = json_app_get($device, $name);
} catch (JsonAppException $e) {
@@ -2,6 +2,9 @@
use LibreNMS\RRD\RrdDefinition;
$name = 'proxmox';
$app_id = $app['app_id'];
if (! function_exists('proxmox_port_exists')) {
/**
* Check if a port on a Proxmox VM exists
@@ -45,9 +48,6 @@ if (! function_exists('proxmox_vm_exists')) {
}
}
$name = 'proxmox';
$app_id = $app['app_id'];
if (\LibreNMS\Config::get('enable_proxmox') && ! empty($agent_data['app'][$name])) {
$proxmox = $agent_data['app'][$name];
} elseif (\LibreNMS\Config::get('enable_proxmox')) {
@@ -27,8 +27,6 @@
use LibreNMS\RRD\RrdDefinition;
echo ' rrdcached';
$data = '';
$name = 'rrdcached';
$app_id = $app['app_id'];
@@ -26,8 +26,6 @@ $app_id = $app['app_id'];
$options = '-Oqv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.8.115.100.102.115.105.110.102.111';
d_echo($name);
$sdfsinfo = snmp_walk($device, $oid, $options);
if (is_string($sdfsinfo)) {
@@ -11,8 +11,6 @@ $options = '-Oqv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.115.104.111.117.116.99.97.115.116';
$shoutcast = snmp_get($device, $oid, $options);
echo ' shoutcast';
$servers = explode("\n", $shoutcast);
$metrics = [];
@@ -2,8 +2,6 @@
use LibreNMS\RRD\RrdDefinition;
echo 'SMART';
$name = 'smart';
$app_id = $app['app_id'];
@@ -28,6 +28,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'tinydns';
$app_id = $app['app_id'];
if (! empty($agent_data['app'][$name]) && $app_id > 0) {
echo ' tinydns';
$rrd_name = ['app', $name, $app_id];
@@ -4,6 +4,7 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'unbound';
$app_id = $app['app_id'];
if (! empty($agent_data['app'][$name])) {
$rawdata = $agent_data['app'][$name];
} else {
@@ -27,8 +27,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'ups-apcups';
$app_id = $app['app_id'];
echo ' ' . $name;
try {
$json_return = json_app_get($device, $name);
} catch (JsonAppParsingFailedException $e) {
@@ -40,8 +40,6 @@ if (! $ups_nut) {
}
//print_r(array_values(explode("\n", $ups_nut)));
echo ' ' . $name;
// (2020-05-13, Jon.W) Added ups status data and updated ups-nut.sh script.
[
$charge,
@@ -5,8 +5,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'voip-monitor';
$app_id = $app['app_id'];
echo "$name, app_id=$app_id ";
if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
@@ -7,8 +7,6 @@ use LibreNMS\RRD\RrdDefinition;
$name = 'zfs';
$app_id = $app['app_id'];
echo $name;
// Is set to false later if missing keys are found.
$not_legacy = 1;