stdevPavelmc / mail2influx

A simple mail log parser to get the live data and inject it to a influxdb server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mail2Influx

A simple mail log data parser and influx data injector. It can parse any log generated by postfix & dovecot, even from giants as Proxmox Mail Gateway and Zimbra.

Motivation

Telegraf and other solutions do not fill my needs of mail monitoring, so I put python3 and some regex rules to make this parser, it's given as a GPL 3.0 software, so no warranty in you use case; but you can modify it to fit your needs.

Installation

You need to install python-influxdb support, search it on the repository or use pip for that.

And no, you don't need to create the influxdb database in advance, mail2influx take care of that too, just be sure to name it as your wish in the user variables in the header of the script.

  1. Clone this repository to somewhere in you PC git clone https://github.com/stdevPavelmc/mail2influx && cd mail2influx
  2. Copy the "mail2influx.py" script to /usr/local/bin/
  3. Make it executable chmod +x /usr/local/bin/mail2influx.py
  4. Edit the /usr/local/bin/mail2influx.py file and change:
    • The variable named influxhost to your influxdb server ip/name.
    • The variable named influxdb if you want to name the influxdb with other name.
  5. Copy "mail2influx.service" file to the systemd folder cp mail2influx.service /lib/systemd/system/
  6. Activate and start the service.
    • systemctl daemon-reload
    • systemctl enable mail2influx
    • systemctl start mail2influx
  7. Go to Grafana and create a new dashboard and import the data from one of the files in this repository:
    • The influx-grafana_dashboard.json file is tailored to a postfix + dovecot server, and it has a default datasource named InfluxDB-mail, you may need to update the influxdb source in grafana to make it work.
    • The influx-grafana_dashboard-PMG.json file is tailored for a Proxmox Mail Gateway, and it has a default datasource named InfluxDB-mailgw, you may need to update the influxdb source in grafana to make it work.

Known issues

  • No authentication against the influxdb, no need on my env
  • No ssl/tls against the influxdb, no need on my env
  • May contain bugs (code is a work in progress)
  • May not be 100% optimized

About the author

This is free software, see stdevPavelmc

About

A simple mail log parser to get the live data and inject it to a influxdb server

License:GNU General Public License v3.0


Languages

Language:Python 100.0%