Postfix monitoring with David Schweikert's Mailgraph?

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
Enforcer
Posts: 10
Joined: Thu Apr 08, 2004 1:06 pm

Post by Enforcer »

Well i did some small changes after i posted also. But the big work that sucks is in the templates *G*

I changed the Data Source Type to ABSOLUTE because i dont saw that
before.

The OID is a problem but not if you install it stricly like it was said in the manual and put the exec for them on top of the snmpd.

Greetings
Enforcer
PS: my first work with cacti and i would also not make one datasource for each input anymore - well it works *G*
User avatar
_pre[PL]
Posts: 12
Joined: Mon Dec 29, 2003 5:25 pm
Location: Poland, Gdynia
Contact:

Post by _pre[PL] »

what version do you have ?
Mine is 0.8.4 and cannot use your template.... :(

Just do an import, and nothing happens. Could not find 'Postfix Stats'...
oharel
Cacti User
Posts: 84
Joined: Wed Jan 07, 2004 11:16 am

Post by oharel »

hi there,

i installed the template "cacti_graph_template_postfix_stats.xml", but the graph generates NaN.
Data Source Debug shows:

/usr/local/bin/rrdtool create \
/var/www/htdocs/cacti-0.8.5a/rra/office_postfixstats_recv_952.rrd \
--step 300 \
DS:recv:GAUGE:600:0:1000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
RRA:LAST:0.5:1:600 \
RRA:LAST:0.5:6:700 \
RRA:LAST:0.5:24:775 \
RRA:LAST:0.5:288:797 \

i see, on the machine the postfix is installed on, snmprequests for the oids of the sent, recv, bounce, etc. btu it seems as if no data is returned, or that the postfix does not have these mibs - is that possible?
also, where does the mailgraph.pl script comes into play here?

--harel
oxy
Posts: 18
Joined: Wed Sep 01, 2004 3:58 am

Post by oxy »

Hi,

i have 2 questions:

I import the xml template and unzipzd the mailgraph.pl.gz script in the cacti/scripts/ directory.

1. Now i'd like to know if i need to add in the DATA INPUT METHODS the following line :

perl <cacti path> /scripts/mailgraph.pl ??


2. what's more, do this scripts allow me to get postifx information of a remote linux machine or only from the localhost (which run cacti and this perl sciprt) ??

thanks a lot
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

Ok, having an issue with this... Had to change the snmpd.conf, since I already have things responding on those oids.. so my snmpd.conf looks like:

Code: Select all

exec 1.3.6.1.4.1.2021.8.2.101.1 mailcount_sent /bin/cat /var/tmp/mailsent
exec 1.3.6.1.4.1.2021.8.2.101.2 mailcount_recv /bin/cat /var/tmp/mailrecv
exec 1.3.6.1.4.1.2021.8.2.101.3 mailcount_reject /bin/cat /var/tmp/mailrejected
exec 1.3.6.1.4.1.2021.8.2.101.4 mailcount_bounced /bin/cat /var/tmp/mailbounced
exec 1.3.6.1.4.1.2021.8.2.101.5 mailcount_spam /bin/cat /var/tmp/mailspam
exec 1.3.6.1.4.1.2021.8.2.101.6 mailcount_virus /bin/cat /var/tmp/mailvirus
I changed the data templates to match...

sent oid is: .1.3.6.1.4.1.2021.8.2.101.1
etc...

I can snmpwalk the oids, and I get:
# snmpwalk -v 2c -c xxxxx mail01 1.3.6.1.4.1.2021.8.2.101.1
UCD-SNMP-MIB::extTable.2.101.1.1.1 = INTEGER: 1
UCD-SNMP-MIB::extTable.2.101.1.2.1 = STRING: "mailcount_sent"
UCD-SNMP-MIB::extTable.2.101.1.3.1 = STRING: "/bin/cat /var/tmp/mailsent"
UCD-SNMP-MIB::extTable.2.101.1.100.1 = INTEGER: 0
UCD-SNMP-MIB::extTable.2.101.1.101.1 = STRING: "16"
UCD-SNMP-MIB::extTable.2.101.1.102.1 = INTEGER: 0


Which looks right... But cacti's not graphing anything.

in the logs I get:
01/28/2005 05:46:18 PM - CMDPHP: Poller[0] Host[47] SNMP: v2: mail00.avantgo.com, dsname: send, oid: .1.3.6.1.4.1.2021.8.2.101.1, output: U

Any ideas?
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
User avatar
gninja
Cacti User
Posts: 371
Joined: Tue Aug 24, 2004 5:02 pm
Location: San Francisco, CA
Contact:

Post by gninja »

Ok, fixed it. was a premissions issue for the cron job.
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
nduda78
Cacti User
Posts: 111
Joined: Tue Mar 01, 2005 11:26 am

Post by nduda78 »

> That templates are working if you have the exec stuff in the snmpd at > the top or the postfix stats entry’s are the only one.

Can you explain what i need to add to my snmpd.conf file for this to work. I've imported the templates already.

- Nick
boran11
Posts: 27
Joined: Mon Mar 21, 2005 8:52 am

Post by boran11 »

I'd be very interesting in tying in postfix into my (new) Cacti setup, I was wondering whwere I could get the latest versions of
- the XML file
- the perl script
- snmp.conf
and a few tips on setting it up?
I was also wondering about using snmp to get the stuff. For my environment it would probalby have been just as easy to create the rrd file on the postfix box, and copy via ssh to the Cacti box, from where it would be imported into cacti & displayed. Has anyone tried an alternative like this?
Finally I was wondering if anyone has integrated postgrey log analysis?

Regards,
Sean
ManuelW
Posts: 2
Joined: Wed Apr 06, 2005 1:57 pm

Post by ManuelW »

Hi, i think i have a little Problem with the script.

With starting i get a failure:
Use of uninitialized value in numeric eq (==) at ... line 588
Use of uninitialized value in numeric lt (<) at ... line 589

and the counters for send, recived and spam in the textfiles are not set back to 0, so the
graph shows always a line climbing up.
Attachments
the original graph goes to 0 if no mail comes in
the original graph goes to 0 if no mail comes in
mailgraph.cgi.png (5.58 KiB) Viewed 34012 times
the cacti imported goes not back to 0
the cacti imported goes not back to 0
graph_image.php.png (6 KiB) Viewed 34012 times
Rübenrotze
Posts: 6
Joined: Mon May 02, 2005 7:18 pm

Post by Rübenrotze »

1. failure when starting mailgraph:
solution: modify the latest version of mailgraph.

2. graph not set back to 0:
solution: after polling set /var/tmp/mail... to 0.
i have done this by adding some "/bin/echo > 0 /var/tmp/mail..." to the cacti cron.

i attached all changed files.
also includes a init script for fedora core.

dirk
Attachments
Mailgraph.zip
modified mailgraph
mailgraph init script
snmpd.conf change
modified cacti cron
cacti_graph_template_postfix_stats.xml
little install howto
(12.11 KiB) Downloaded 3764 times
jpingle
Posts: 37
Joined: Mon May 09, 2005 4:08 pm

Slight Change...

Post by jpingle »

I stumbled upon this thread while looking for ways to monitor my mail systems with Cacti, and I had a suggestion.

I am running Cacti on a different host than the Postfix install I want to monitor, so the crontab entry included in that zip wasn't going to work in my setup.

A more elegant solution for zeroing out the message counts is to make the SNMP daemon exec a script that returns the count and zeros the counter in one step. I made a script that is called like so: catstat.sh sent - it will return the contents of /var/tmp/mailsent and then replace it with a 0.

Of course this may raise other issues I have yet to discover, but it works for now!

Getting the whole altered mailgraph setup to run on FreeBSD required some other changes, all minor -- paths to binaries and scripts are different -- but it was overall fairly easy.

Now if I could just figure out why cacti goes haywire on my ifDescr indexed ATM interfaces on a Cisco router every time the router reboots, I'd be really happy :) (It's not fun seeing pages of NaN's after a long power outage...) But that's a story for another thread.
dgman
Posts: 19
Joined: Wed Nov 12, 2003 12:30 pm

Post by dgman »

yes i agree. the script in the zip does not zero the values. i am by nomeans able to fix the scirpt to do it. but any help would be nice.

--j
jpingle
Posts: 37
Joined: Mon May 09, 2005 4:08 pm

Post by jpingle »

Here is the script that I am using to return the value from the mail counter files and zero them out.

Code: Select all

#!/bin/sh

if [ "$1" = "sent" ] || [ "$1" = "recv" ]  || [ "$1" = "rejected" ] || [ "$1" = "bounced" ] || [ "$1" = "spam" ] || [ "$1" = "virus" ]

then 
  /bin/cat /var/tmp/mail$1
  /bin/echo 0 > /var/tmp/mail$1
fi
I reference this from snmpd.conf on the server running postfix as follows:

Code: Select all

exec   mailcount_sent           /path/to/script/catstat.sh sent
exec   mailcount_recv           /path/to/script/catstat.sh recv
exec   mailcount_reject         /path/to/script/catstat.sh rejected
exec   mailcount_bounced        /path/to/script/catstat.sh bounced
exec   mailcount_spam           /path/to/script/catstat.sh spam
exec   mailcount_virus          /path/to/script/catstat.sh virus
I have the script check for the names as a simple measure against shooting ones self in the foot by passing an invalid parameter (i.e. ../../etc/passwd) and having the wrong file overwritten.

I also have altered the graph template to make the Current/Maximum values use the "Exact Numbers" GPRINT type, and use 0 for the unit exponent value. This allows me to get whole number message counts without being converted to other formats. i.e. 2421 messages instead of 2.4k messages, or 24 instead of 24.94 (which is erroneous anyway...)

The postfix server is a spam filter/relay, so it has no local recipients. As such my graph is heavily skewed toward rejected messages and the received & sent are pretty much the same all the time. I had to re-order the values so rejects were on the top otherwise I couldn't see half the other graph values :)

Hope this helps...
jpingle
Posts: 37
Joined: Mon May 09, 2005 4:08 pm

Big problem...

Post by jpingle »

While getting this to work I thought the numbers were a little low. The mail server I'm monitoring typically processes about 150,000-200,000 incoming messages per day (70% of which are rejected by RBLs...)

So I went just looking at the code and output trying to determine just exactly what the numbers in the graph were trying to tell me. I thought "Are they messages per second, minute, or 5 minutes?" So I watched the counter files, and they were replaced once per minute, the old values completely ignored. Whichever file happend to be in place when the poller ran was recorded.

In short, anyone using this script is only getting 1 minute out of 5 graphed, and the other values are completely ignored. I modified a version of the already-modified mailgraph script to read in the old numbers and add to them, rather than overwriting them.

Alternately, you could probably change the rrdstep variable to 60*5 instead of 60, but I didn't know if the timing would be off then.

This also means that the value being graphed should be "Messages per 5 minutes" - I suppose one could divide the number in the file by 5 to get a per minute average, or divide it up however you'd like.

Right now I have a dirty hack done to the script to fix this, I'd like a more elegant solution but that will take time. If I get a chance to fix it I'll post a corrected version.

Comments are welcome...
jpingle
Posts: 37
Joined: Mon May 09, 2005 4:08 pm

Alternate version of Mailgraph for Cacti

Post by jpingle »

Here is my version of the Postfix Processing stats graph and associated files. It's similar to the other version posted here, but operates differently.

Main differences:
  • Works with postfix running on a different host than cacti
    Properly gathers all data for a 5-minute period
    Uses a single data source instead of 6 separate ones
    Collects data via SNMP using a script
    Various alterations of the graph template including ordering of the items as well as using exact numbers for last/max items
Everything should be included in the zip, including install instructions (Though my instructions are geared toward FreeBSD, they should easily adapt to Linux.) All of the templates and items required by cacti should be in the included XML file. You will at least have to check paths in the scripts to make sure they properly point to items such as perl, bash, and snmpwalk.

I named the templates differently so that they would not conflict with the templates from the old version. However, the OID may conflict with the old version.

Some other changes that you can make on your own might be to have Cacti average the data so that it is messages per minute instead of per 5 minutes, and maybe graph type changes such as changing from AREA to LINE types.

Be sure that if you are starting with this version to touch the mail counter files in /var/tmp before starting mailgraph or it will not update. You should execute the following commands:

Code: Select all

      touch /var/tmp/mailreceived
      touch /var/tmp/mailsent
      touch /var/tmp/mailrejected
      touch /var/tmp/mailbounced
      touch /var/tmp/mailspam
      touch /var/tmp/mailvirus
Edited on 5/16 - Updated files to fix some errors.
Attachments
mailgraph-jjp.zip
Alternate Mailgraph for Cacti implementation.
Read INSTALL for FreeBSD instructions
(13.41 KiB) Downloaded 3833 times
Last edited by jpingle on Mon May 16, 2005 10:31 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests