From 002f4157b6ba3249ded9952544aa17591b1d54ef Mon Sep 17 00:00:00 2001 From: VVelox Date: Wed, 1 Mar 2017 12:34:22 -0600 Subject: [PATCH] feature: Added support Postfix application --- doc/Extensions/Applications.md | 27 +++++ .../graphs/application/postfix_bytes.inc.php | 36 ++++++ .../application/postfix_deferral.inc.php | 36 ++++++ .../application/postfix_messages.inc.php | 72 ++++++++++++ .../graphs/application/postfix_qstats.inc.php | 48 ++++++++ .../application/postfix_rejects.inc.php | 108 ++++++++++++++++++ .../graphs/application/postfix_sr.inc.php | 48 ++++++++ html/pages/apps.inc.php | 9 ++ html/pages/device/apps/postfix.inc.php | 32 ++++++ includes/polling/applications/postfix.inc.php | 97 ++++++++++++++++ 10 files changed, 513 insertions(+) create mode 100644 html/includes/graphs/application/postfix_bytes.inc.php create mode 100644 html/includes/graphs/application/postfix_deferral.inc.php create mode 100644 html/includes/graphs/application/postfix_messages.inc.php create mode 100644 html/includes/graphs/application/postfix_qstats.inc.php create mode 100644 html/includes/graphs/application/postfix_rejects.inc.php create mode 100644 html/includes/graphs/application/postfix_sr.inc.php create mode 100644 html/pages/device/apps/postfix.inc.php create mode 100644 includes/polling/applications/postfix.inc.php diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 4d8e57b79e..309b155f04 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -29,6 +29,7 @@ Different applications support a variety of ways collect data: by direct connect 1. [Munin](#munin) - Agent 1. [PHP-FPM](#php-fpm) - SNMP extend 1. [Fail2ban](#fail2ban) - SNMP extend +1. [Postfix](#postfix) - SNMP extend ### Apache Either use SNMP extend or use the agent. @@ -518,3 +519,29 @@ extend fail2ban /etc/snmp/fail2ban In regards to the totals graphed there are two variables banned and firewalled. Firewalled is a count of banned entries the firewall for fail2ban and banned is the currently banned total from fail2ban-client. Both are graphed as the total will diverge with some configurations when fail2ban fails to see if a IP is in more than one jail when unbanning it. This is most likely to happen when the recidive is in use. If you have more than a few jails configured, you may need to use caching as each jail needs to be polled and fail2ban-client can't do so in a timely manner for than a few. This can result in failure of other SNMP information being polled. + +#### Postfix + +##### SNMP Extend + +1: Copy the shell script, postfix-queues, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/postfix-queues -O /etc/snmp/postfix-queues) + +1: Copy the Perl script, postfix-queues, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/postfixdetailed -O /etc/snmp/postfixdetailed) + +2: Make the scripts executable (chmod +x /etc/snmp/postfixdetailed /etc/snmp/postfix-queues) + +3: Edit your snmpd.conf file and add: +``` +extend mailq /etc/snmp/postfix-queues +extend postfixdetailed /etc/snmp/postfixdetailed +``` + +4: Restart snmpd. + +5: Install pflogsumm for your OS. + +6: Make sure the cache file in /etc/snmp/postfixdetailed is some place that snmpd can write too. This file is used for tracking changes between various values between each time it is called by snmpd. Also make sure the path for pflogsumm is correct. + +7: On the device page in Librenms, edit your host and check `Postfix` under the Applications tab. Before doing this, run /etc/snmp/postfixdetailed to create the initial cache file so you don't end up with some crazy initial starting value. + +Please note that each time /etc/snmp/postfixdetailed is ran, the cache file is updated, so if this happens in between LibreNMS doing it then the values will be thrown off for that polling period. diff --git a/html/includes/graphs/application/postfix_bytes.inc.php b/html/includes/graphs/application/postfix_bytes.inc.php new file mode 100644 index 0000000000..59a5f8b136 --- /dev/null +++ b/html/includes/graphs/application/postfix_bytes.inc.php @@ -0,0 +1,36 @@ + $rrd_filename, + 'descr' => 'Received', + 'ds' => 'bytesr', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Delivered', + 'ds' => 'bytesd', + 'colour' => '88CC88' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/postfix_deferral.inc.php b/html/includes/graphs/application/postfix_deferral.inc.php new file mode 100644 index 0000000000..2e1988b32c --- /dev/null +++ b/html/includes/graphs/application/postfix_deferral.inc.php @@ -0,0 +1,36 @@ + $rrd_filename, + 'descr' => 'Conn. Refused', + 'ds' => 'deferralcr', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Host Is Down', + 'ds' => 'deferralhid', + 'colour' => '88CC88' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/postfix_messages.inc.php b/html/includes/graphs/application/postfix_messages.inc.php new file mode 100644 index 0000000000..d53bc73de1 --- /dev/null +++ b/html/includes/graphs/application/postfix_messages.inc.php @@ -0,0 +1,72 @@ + $rrd_filename, + 'descr' => 'Received', + 'ds' => 'received', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Delivered', + 'ds' => 'delivered', + 'colour' => '28774F' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Deferred', + 'ds' => 'deferred', + 'colour' => 'AA6C39' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Bounced', + 'ds' => 'bounced', + 'colour' => '88CC88' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Rejected', + 'ds' => 'rejected', + 'colour' => 'D46A6A' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Reject Warnings', + 'ds' => 'rejectw', + 'colour' => 'FFD1AA' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Held', + 'ds' => 'held', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Discarded', + 'ds' => 'discarded', + 'colour' => 'AA5439' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/postfix_qstats.inc.php b/html/includes/graphs/application/postfix_qstats.inc.php new file mode 100644 index 0000000000..3549302e77 --- /dev/null +++ b/html/includes/graphs/application/postfix_qstats.inc.php @@ -0,0 +1,48 @@ + $rrd_filename, + 'descr' => 'Incoming', + 'ds' => 'incomingq', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Active', + 'ds' => 'activeq', + 'colour' => '28774F' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Deferred', + 'ds' => 'deferredq', + 'colour' => '88CC88' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Hold', + 'ds' => 'holdq', + 'colour' => 'D46A6A' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/postfix_rejects.inc.php b/html/includes/graphs/application/postfix_rejects.inc.php new file mode 100644 index 0000000000..726ea414e3 --- /dev/null +++ b/html/includes/graphs/application/postfix_rejects.inc.php @@ -0,0 +1,108 @@ + $rrd_filename, + 'descr' => 'Clnt Hst Rej', + 'ds' => 'chr', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Helo needs FQN', + 'ds' => 'hcrnfqh', + 'colour' => '28774F' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Sndr Dmn Not Fnd', + 'ds' => 'sardnf', + 'colour' => 'AA6C39' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Not Owned By User', + 'ds' => 'sarnobu', + 'colour' => '88CC88' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'RBL', + 'ds' => 'bu', + 'colour' => 'D46A6A' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Unknown Recpt', + 'ds' => 'raruu', + 'colour' => 'FFD1AA' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Inv. Helo Name', + 'ds' => 'hcrin', + 'colour' => '582A00' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Sender Needs FQA', + 'ds' => 'sarnfqa', + 'colour' => '005439' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Recp DNF', + 'ds' => 'rardnf', + 'colour' => '28006C' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Recp Needs FQA', + 'ds' => 'rarnfqa', + 'colour' => '00536C' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Imp. Pipelining', + 'ds' => 'iuscp', + 'colour' => '853A6C' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Config Error', + 'ds' => 'sce', + 'colour' => '005300' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Config Problem', + 'ds' => 'scp', + 'colour' => '28006C' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Unknown', + 'ds' => 'urr', + 'colour' => '280090' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/includes/graphs/application/postfix_sr.inc.php b/html/includes/graphs/application/postfix_sr.inc.php new file mode 100644 index 0000000000..3ba7d66615 --- /dev/null +++ b/html/includes/graphs/application/postfix_sr.inc.php @@ -0,0 +1,48 @@ + $rrd_filename, + 'descr' => 'Senders', + 'ds' => 'senders', + 'colour' => '582A72' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Sending H/D', + 'ds' => 'sendinghd', + 'colour' => '28774F' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Recipients', + 'ds' => 'recipients', + 'colour' => '88CC88' + ), + array( + 'filename' => $rrd_filename, + 'descr' => 'Recip H/D', + 'ds' => 'recipienthd', + 'colour' => 'D46A6A' + ) + ); +} else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_multi_line_exact_numbers.inc.php'; diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index e95acfd533..1766918adc 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -33,6 +33,15 @@ $graphs['nginx'] = array( 'req', ); +$graphs['postfix'] = array( + 'messages', + 'qstats', + 'bytes', + 'sr', + 'deferral', + 'rejects', +); + $graphs['powerdns-recursor'] = array( 'questions', 'answers', diff --git a/html/pages/device/apps/postfix.inc.php b/html/pages/device/apps/postfix.inc.php new file mode 100644 index 0000000000..c5b714b04d --- /dev/null +++ b/html/pages/device/apps/postfix.inc.php @@ -0,0 +1,32 @@ + 'Queue', + 'postfix_messages' => 'Messages', + 'postfix_bytes' => 'Bytes', + 'postfix_sr' => 'Sender & Recipients', + 'postfix_deferral' => 'Deferals', + 'postfix_rejects' => 'Rejects', +); + +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + + echo '
+
+

'.$text.'

+
+
+
'; + include 'includes/print-graphrow.inc.php'; + echo '
'; + echo '
'; + echo '
'; +} diff --git a/includes/polling/applications/postfix.inc.php b/includes/polling/applications/postfix.inc.php new file mode 100644 index 0000000000..56fc824c9f --- /dev/null +++ b/includes/polling/applications/postfix.inc.php @@ -0,0 +1,97 @@ +addDataset('incomingq', 'GAUGE', 0) + ->addDataset('activeq', 'GAUGE', 0) + ->addDataset('deferredq', 'GAUGE', 0) + ->addDataset('holdq', 'GAUGE', 0) + ->addDataset('received', 'GAUGE', 0) + ->addDataset('delivered', 'GAUGE', 0) + ->addDataset('forwarded', 'GAUGE', 0) + ->addDataset('deferred', 'GAUGE', 0) + ->addDataset('bounced', 'GAUGE', 0) + ->addDataset('rejected', 'GAUGE', 0) + ->addDataset('rejectw', 'GAUGE', 0) + ->addDataset('held', 'GAUGE', 0) + ->addDataset('discarded', 'GAUGE', 0) + ->addDataset('bytesr', 'GAUGE', 0) + ->addDataset('bytesd', 'GAUGE', 0) + ->addDataset('senders', 'GAUGE', 0) + ->addDataset('sendinghd', 'GAUGE', 0) + ->addDataset('recipients', 'GAUGE', 0) + ->addDataset('recipienthd', 'GAUGE', 0) + ->addDataset('deferralcr', 'GAUGE', 0) + ->addDataset('deferralhid', 'GAUGE', 0) + ->addDataset('chr', 'GAUGE', 0) + ->addDataset('hcrnfqh', 'GAUGE', 0) + ->addDataset('sardnf', 'GAUGE', 0) + ->addDataset('sarnobu', 'GAUGE', 0) + ->addDataset('bu', 'GAUGE', 0) + ->addDataset('raruu', 'GAUGE', 0) + ->addDataset('hcrin', 'GAUGE', 0) + ->addDataset('sarnfqa', 'GAUGE', 0) + ->addDataset('rardnf', 'GAUGE', 0) + ->addDataset('rarnfqa', 'GAUGE', 0) + ->addDataset('iuscp', 'GAUGE', 0) + ->addDataset('sce', 'GAUGE', 0) + ->addDataset('scp', 'GAUGE', 0) + ->addDataset('urr', 'GAUGE', 0); + +$fields = array( + 'incomingq' => $incomingq, + 'activeq' => $activeq, + 'deferredq' => $deferredq, + 'holdq' => $holdq, + 'received' => $received, + 'delivered' => $delivered, + 'forwarded' => $forwarded, + 'deferred' => $deferred, + 'bounced' => $bounced, + 'rejected' => $rejected, + 'rejectw' => $rejectw, + 'held' => $held, + 'discarded' => $discarded, + 'bytesr' => $bytesr, + 'bytesd' => $bytesd, + 'senders' => $senders, + 'sendinghd' => $sendinghd, + 'recipients' => $recipients, + 'recipienthd'=> $recipienthd, + 'deferralcr' => $deferralcr, + 'deferralhid' => $deferralhid, + 'chr' => $chr, + 'hcrnfqh' => $hcrnfqh, + 'sardnf' => $sardnf, + 'sarnobu' => $sarnobu, + 'bu' => $bu, + 'raruu' => $raruu, + 'hcrin' => $hcrin, + 'sarnfqa' => $sarnfqa, + 'rardnf' => $rardnf, + 'rarnfqa' => $rarnfqa, + 'iuscp' => $iuscp, + 'sce' => $sce, + 'scp' => $scp, + 'urr' => $urr +); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields);