feature: Added support Postfix application

This commit is contained in:
VVelox
2017-03-01 12:34:22 -06:00
committed by Neil Lathwood
parent b21758d456
commit 002f4157b6
10 changed files with 513 additions and 0 deletions

View File

@@ -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.

View File

@@ -0,0 +1,36 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Bytes';
$unitlen = 5;
$bigdescrlen = 7;
$smalldescrlen = 7;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -0,0 +1,36 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Deferals';
$unitlen = 13;
$bigdescrlen = 13;
$smalldescrlen = 13;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -0,0 +1,72 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Messages';
$unitlen = 8;
$bigdescrlen = 9;
$smalldescrlen = 9;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -0,0 +1,48 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = '';
$unitlen = 10;
$bigdescrlen = 9;
$smalldescrlen = 9;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -0,0 +1,108 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Rejects';
$unitlen = 1;
$bigdescrlen = 17;
$smalldescrlen = 17;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -0,0 +1,48 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Messages';
$unitlen = 11;
$bigdescrlen = 11;
$smalldescrlen = 11;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
if (is_file($rrd_filename)) {
$rrd_list = array(
array(
'filename' => $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';

View File

@@ -33,6 +33,15 @@ $graphs['nginx'] = array(
'req',
);
$graphs['postfix'] = array(
'messages',
'qstats',
'bytes',
'sr',
'deferral',
'rejects',
);
$graphs['powerdns-recursor'] = array(
'questions',
'answers',

View File

@@ -0,0 +1,32 @@
<?php
global $config;
$graphs = array(
'postfix_qstats' => '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 '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$text.'</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}

View File

@@ -0,0 +1,97 @@
<?php
$name = 'postfix';
$app_id = $app['app_id'];
use LibreNMS\RRD\RrdDefinition;
$options = '-O qv';
$mib = 'NET-SNMP-EXTEND-MIB';
$queueOID = 'nsExtendOutputFull.5.109.97.105.108.113';
$detailOID = 'nsExtendOutputFull.15.112.111.115.116.102.105.120.100.101.116.97.105.108.101.100';
$mailq = snmp_walk($device, $queueOID, $options, $mib);
$detail= snmp_walk($device, $detailOID, $options, $mib);
list($incomingq, $activeq, $deferredq, $holdq) = explode("\n", $mailq);
list($received, $delivered, $forwarded, $deferred, $bounced, $rejected, $rejectw, $held, $discarded, $bytesr,
$bytesd, $senders, $sendinghd, $recipients, $recipienthd, $deferralcr, $deferralhid, $chr, $hcrnfqh, $sardnf,
$sarnobu, $bu, $raruu, $hcrin, $sarnfqa, $rardnf, $rarnfqa, $iuscp, $sce, $scp, $urr) = explode("\n", $detail);
$rrd_name = array('app', $name, $app_id);
$rrd_def = RrdDefinition::make()
->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);