Code Monkey home page Code Monkey logo

zabbix-postfix's People

Contributors

abruening-iwt avatar joepadmiraal avatar krauthosting avatar lucarnosky avatar misterbenj34 avatar rafael747 avatar redreinard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

zabbix-postfix's Issues

rights problem on Ubuntu 22.04 for /tmp/zabbix-postfix-passive-statsfile.dat

Hello,

Thanks for your plugin, work nice after a modification for a rights problem with passive script with the file /tmp/zabbix-postfix-passive-statsfile.dat on Ubuntu 22.04.
Same problem when I let the zabbix-server, or execute by zabbix_agentd -t postfix[deferred] or directly with sudo /usr/local/sbin/zabbix_postfix_passive.sh deferred.

image
image

I need to change the owner to root for working. And work like a charm. And something weird , when reapply owner and gorup to zabbix, it's continue to work... Until reboot and tmp files deleted of course.
image

In my case, no need to have zabbix as owner, it can be root like for /tmp/zabbix-postfix-passive-offset.dat, as we execute the script as root with the sudoers. I don't know why needed theses lines and I comment them.

I don't send a pull request, because maybe it's needed for something for someone ? But on Debian based I think not.

if [ ! -w "${PFSTATSFILE}" ]; then
        touch "${PFSTATSFILE}" && chown zabbix:zabbix "${PFSTATSFILE}" > /dev/null 2>&1

        if [ ! $? -eq 0 ]; then
                result_text="ERROR: wrong exit code returned while creating file ${PFSTATSFILE} and setting its owner to zaabbix:zabbix"
                result_code="1"
                write_result "${result_code}" "${result_text}"
        fi
fi

Have a nice day

Problema: Template Postfix Services: Postfix queue

Template Postfix Services:

Chave:
zabbix

Postfix queue consta como "Não suportado" "

Unsupported item key."

Todas as configurações, automáticas por scritpt e manual foram realizadas.

Zabbix 4.0.0. - centos 7.

Error message: ZBX_NOTSUPPORTED: Unsupported item key

Hello,
your template looks interesting.
Here is one typo (at least on ubuntu 18.04 and Debian 9 as well) on installation script (install_postfix_template_zabbix.sh) on line 38 must be :
cd /etc/zabbix/zabbix_agentd.d/
not: cd /etc/zabbix/zabbix_agentd.conf.d/

However, I installed it via your script and imported template, but from all existing items, only one that returns data is Postfix queue - the key: pf.mailq

I'm using zabbix-proxy and for any other requests I got answer - not existing key:

$ zabbix_get -s postfix_hostname -p 10050 -k pf.delivered
ZBX_NOTSUPPORTED: Unsupported item key.

Same response or any keys: pf.deferred, pf.discarded, pf.rejected and so on.
Only one that responds with number of mails in the queue is: pf.mailq
(ok, probably the most important one :-)

I have zabbix-server version 4.4.7, zabbix_proxy (Zabbix) 4.4.7
Postfix version: 3.3.0
Python 2.7.17 (however also 3.6.9)

I can't find anything related in zabbix logs (agent or proxy).
All the best,
Franko

Held Messages are not correctly displayed

"Held Messages" are not displayed correclty:

image

Console Output from your script (check the failures in the end of the line)

DATA="$(${LOGTAIL} -o ${FPOS} ${MAILLOG} | ${PFLOGSUMM} -h 0 -u 0 --bounce_detail=0 --deferral_detail=0 --reject_detail=0 --no_no_msg_size --smtpd_warning_detail=0)"
echo -e $DATA
Grand Totals ------------ messages 0 received 0 delivered 0 forwarded 0 deferred 0 bounced 0 rejected (0%) 0 reject warnings 0 held 0 discarded (0%) 0 bytes received 0 bytes delivered 0 senders 0 sending hosts/domains 0 recipients 0 recipient hosts/domains Per-Hour Traffic Summary ------------------------ time received delivered deferred bounced rejected -------------------------------------------------------------------- 0000-0100 0 0 0 0 0 0100-0200 0 0 0 0 0 0200-0300 0 0 0 0 0 0300-0400 0 0 0 0 0 0400-0500 0 0 0 0 0 0500-0600 0 0 0 0 0 0600-0700 0 0 0 0 0 0700-0800 0 0 0 0 0 0800-0900 0 0 0 0 0 0900-1000 0 0 0 0 0 1000-1100 0 0 0 0 0 1100-1200 0 0 0 0 0 1200-1300 0 0 0 0 0 1300-1400 0 0 0 0 0 1400-1500 0 0 0 0 0 1500-1600 0 0 0 0 0 1600-1700 0 0 0 0 0 1700-1800 0 0 0 0 0 1800-1900 0 0 0 0 0 1900-2000 0 0 0 0 0 2000-2100 0 0 0 0 0 2100-2200 0 0 0 0 0 2200-2300 0 0 0 0 0 2300-2400 0 0 0 0 0 smtp delivery failures: none Fatal Errors: none Panics: none Master daemon messages: none

Output from other check command

root@server:~# mailq -hq
-Queue ID-  --Size-- ----Arrival Time---- -Sender/Recipient-------
791XX12XXX    5037 Thu Jun 30 08:49:45  [email protected]
        (connect to maksed.foo.bar[xxx.xxx.xxx.xxx]:25: Connection timed out)
                                         [email protected]

-- 4 Kbytes in 1 Request.

Centos 6

In case anyone wanna do this on centos 6 (probably also 7)

Edit the zabbix_postfix.sh file:

#!/bin/bash

# DEPS: /usr/sbin/pflogsumm
# DEPS: pygtail.py
# DEPS: bc

MAILLOG=/var/log/maillog
FPOS=/tmp/zabbix-postfix-offset.dat
PFLOGSUMM=/usr/sbin/pflogsumm
LOGTAIL=/usr/local/sbin/pygtail.py
ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf

function zsend {
  /usr/bin/zabbix_sender -c $ZABBIX_CONF -k $1 -o $2
}

DATA="$(${LOGTAIL} -o ${FPOS} ${MAILLOG} | ${PFLOGSUMM} -h 0 -u 0 --no_bounce_detail --no_deferral_detail --no_reject_detail --no_no_msg_size --no_smtpd_warnings)"

zsend pf.received $(echo -e "${DATA}" | grep -m 1 received | cut -f1 -d"r")
zsend pf.delivered $(echo -e "${DATA}" | grep -m 1 delivered | cut -f1 -d"d")
zsend pf.forwarded $(echo -e "${DATA}" | grep -m 1 forwarded | cut -f1 -d"f")
zsend pf.deferred $(echo -e "${DATA}" | grep -m 1 deferred | cut -f1 -d"d")
zsend pf.bounced $(echo -e "${DATA}" | grep -m 1 bounced | cut -f1 -d"b")
zsend pf.rejected $(echo -e "${DATA}" | grep -m 1 rejected | cut -f1 -d"r")
zsend pf.rejectwarnings $(echo -e "${DATA}" | grep -m 1 "reject warnings" | cut -f1 -d"r")
zsend pf.held $(echo -e "${DATA}" | grep -m 1 held | cut -f1 -d"h")
zsend pf.discarded $(echo -e "${DATA}" | grep -m 1 discarded | cut -f1 -d"d")
zsend pf.bytesreceived $(echo -e "${DATA}" | grep -m 1 "bytes received" | cut -f1 -d"b"|sed -e 's/k/\*1024/g' -e 's/m/\*1048576/g' -e 's/g/\*1073741824/g' |bc)
zsend pf.bytesdelivered $(echo -e "${DATA}" | grep -m 1 "bytes delivered" | cut -f1 -d"b"|sed -e 's/k/\*1024/g' -e 's/m/\*1048576/g' -e 's/g/\*1073741824/g' |bc)

Run these commands instead (replace the zabbix version with the one your using):

yum install postfix-perl-scripts bc

cp zabbix_postfix.sh /usr/local/sbin/
cp pygtail.py /usr/local/sbin/
chmod +x /usr/local/sbin/pygtail.py
chmod +x /usr/local/sbin/zabbix_postfix.sh

cp zabbix_postfix /etc/sudoers.d/
chmod 440 /etc/sudoers.d/zabbix_postfix
yum install https://repo.zabbix.com/zabbix/4.2/rhel/6/x86_64/zabbix-release-4.2-1.el6.noarch.rpm
yum install zabbix-agent zabbix-sender

cp zabbix_postfix.conf /etc/zabbix/zabbix_agentd.d/

service zabbix-agent restart

Instruction updates for zabbix-agent2, and for the crontab entry

At first I thought the reason the cron entry wasn't working was because I had put it in the zabbix user's crontab instead of root. But even after switching that, it didn't work. Eventually I figured out that it was because it was looking for /etc/zabbix/zabbix_agentd.conf instead of /etc/zabbix/zabbix_agent2.conf.

Various Issues Installing Template on Alma 8

Hi

I've after quite a bit of wrestling managed to get this working on an Alma 8 (essentially Red Hat/Centos 8) system. I suspect the problems I encountered would be more or less identical on RHEL 9/Alma 9/Rocky 9/Centos Stream. I'm feeding back some info in the event it's helpful for either making some tweaks to the script, or for anybody else reading who may have encountering these issues:

  1. The main problem I had was with SELinux, and I had to scan the logs and manually enable policies for a number of things - some of them several times over, which I've never seen before. The various criteria I used to check the audit log and run through audit2allow were as follows:
grep zabbix_agent /var/log/audit/audit.log | audit2allow -M zabbix_agent
grep execute_no_trans /var/log/audit/audit.log | audit2allow -M execute_no_trans
grep unix_dgram_socket /var/log/audit/audit.log | audit2allow -M zabbix-postfix-unix_dgram_socket
grep showq /var/log/audit/audit.log | audit2allow -M zabbix-postfix-showq

It was basically a case of repeat tailing the audit log for zabbix/postfix related "denied" entries, then pushing them through Audit2allow and activating the resultant policy files. Which isn't ideal in the grand scheme of things, but I think the only other option I'm aware of would be fore them to be more precisely specified/written into an installer or install script.

  1. On this distro sudo rights are not required to run the mailq command, so I removed sudo from the UserParameter argument in zabbix_postfix.conf as this was causing additional SELinux gripes:

UserParameter=pf.mailq,/usr/bin/mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]'

This also meant that sudo file/entry in /etc/sudoers.d for the zabbix user was no longer needed.

  1. My Agents use UnsafeUserParameters=0 as default, so I had to specify an AllowKey for the modified UserAgent Parameter:

AllowKey=system.run["/usr/bin/mailq | grep -v 'Mail queue is empty' | grep -c '^[0-9A-Z]'"]

  1. Finally, I had to repoint the python interpreter used on my system in pygtail.py to /bin/python3 to allow the cron job to pull data through and transmit it.

I hope this is helpful either the the maintainer or to other users, if I can supply any further info please let me know.

Active-Passive

Hi Rafael, your template for Postfix, works with passive agent? Thanks.

last apostrophe unnecessary

Add crontab entry

Zabbix check

*/5 * * * * /usr/local/sbin/zabbix_postfix.sh 1>/dev/null 2>/dev/null'

correct
*/5 * * * * /usr/local/sbin/zabbix_postfix.sh 1>/dev/null 2>/dev/null

Feature Request: Trigger for held messages

What do you think about to create / discover a tigger for item "held messages"? So when more then 1 messages are held for more then 10 Minutes, there comes up a alert?

Template will not import into Zabbix 7.0.0alpha1

I opted to set up the new Zabbix alpha version from scratch.

This template will not import into 7.0.0alpha1. "Unexpected Server Error" is shown. There is nothing useful in the apache logs. I am importing the standard template, not the passive template.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.