librenms / librenms-agent

LibreNMS Agent & Scripts
GNU General Public License v2.0
116 stars 187 forks source link

Mailcow dockerized postfix #448

Open adendrag opened 1 year ago

adendrag commented 1 year ago

Hi,

I am having an issue with the mailcow-dockerized postfix extension. Application status gets changed to OK on polling, however graphs are not created and never appear. Pflogsumm is installed. When running poller.php, the following is seen:

#### Load poller module applications #### Application: mailcow-postfix, app_id=6 mailcow-postfix:-3:Invalid JSON

Also, when looking into the graphs file missing: /opt/librenms/rrd/my.example.net/app-mailcow-postfix-6.rrd

Any ideas?

calvinthefreak commented 8 months ago

I've the Same Problem. It seems to be an issue where the SNMP Daemon gets trash served. Debugged the snmp/mailcow-dockerized-postfix file and did run the command directly thats run by the Script: docker logs d3fa551bd928 | pflogsumm --smtpd-stats There is a lot of junk thats written in front, because pflogsumm messes something up:

image

I'll let you know, when I find a solution.

calvinthefreak commented 8 months ago

First of, I made sure, that my pflogsumm is up to date (Downloaded the Beta: https://jimsun.linxnet.com/postfix_contrib.html) and then I modified the snmp extend script a bit, so that it doesn't spit out errors: I added on Line 50 in snmp/mailcow-dockerized-postfix: + "| pflogsumm --smtpd-stats 2>&1 | grep -v 'Use of uninitialized value'"

So that suppresses the Perl/Bash errors. Then I made sure, that the snmp-user had the right to execute Docker Commands, since that was the error seen when I snmpwalked my Mailserver.

librenms@ubuntu:~$ snmpwalk -v 2c -c private mailserver.local iso.3.6.1.4.1.8072.1.3
iso.3.6.1.4.1.8072.1.3.2.4.1.2.15.109.97.105.108.99.111.119.45.112.111.115.116.102.105.120.1 = STRING: "permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?filters=%7B%22name%22%3A%7B%22postfix-mailcow%22%3Atrue%7D%7D\": dial unix /var/run/docker.sock: connect: permission denied"

Now it seems to be working... at least the Graphs are painted, and a Mail Send from my self to another account displayed as email send and received.

calvinthefreak commented 8 months ago

I guess the Problem will be solved with this. @librenms maybe add this step to your documentation on https://docs.librenms.org/Extensions/Applications/#mailcow-dockerized-postfix that the user should verify that the user snmp (or what ever it is on your distro, mine was Debian-snmp) is added to the docker group so that snmp can run the command on snmp walk request.

and for you @adendrag please to remember, to restart the snmp daemon after you added it to the docker group.

calvinthefreak commented 8 months ago

Did a PR on this. Please Merge: https://github.com/librenms/librenms-agent/pull/494