Files
librenms-librenms/includes/polling/applications/mailscanner.inc.php
Mark Westerterp 8a6f158ab8 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
2022-01-06 12:08:52 +01:00

39 lines
1.3 KiB
PHP

<?php
// Polls MailScanner statistics from script via SNMP
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);
[$msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus] = explode("\n", $mailscanner);
$rrd_name = ['app', $name, $app_id];
$rrd_def = RrdDefinition::make()
->addDataset('msg_recv', 'COUNTER', 0, 125000000000)
->addDataset('msg_rejected', 'COUNTER', 0, 12500000000)
->addDataset('msg_relay', 'COUNTER', 0, 125000000000)
->addDataset('msg_sent', 'COUNTER', 0, 125000000000)
->addDataset('msg_waiting', 'COUNTER', 0, 125000000000)
->addDataset('spam', 'COUNTER', 0, 125000000000)
->addDataset('virus', 'COUNTER', 0, 125000000000);
$fields = [
'msg_recv' => $msg_recv,
'msg_rejected' => $msg_rejected,
'msg_relay' => $msg_relay,
'msg_sent' => $msg_sent,
'msg_waiting' => $msg_waiting,
'spam' => $spam,
'virus' => $virus,
];
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
data_update($device, 'app', $tags, $fields);
update_application($app, $mailscanner, $fields);