Hi there!
First of all, this prove of concept is a very poor implementation and inspired by ZBXNEXT-3039.
ZBXNEXT-3039 would allow full control from Zabbix fronted/server side. Here, since being based on Zabbix trapper resp. Zabbix sender, only fixed item variations are used and proper items of type Zabbix trapper have to exist.
How does it work?
The Python script makes use of inbox.py and py-zabbix.
Before being started the script smtpToZbxTrap.py has to be edited to configure the following parameters:
The BIND_* variables define where the script should listen for incoming Emails.
The ZABBIX_* variables define where the script should send values to via Zabbix trapper protocol.
Once started the script sends a bulk of item values for each received Email.
The host in Zabbix to send the values to is derived from the recipient addresses. So a recipient address like:
[email protected]
would cause the values to be send to a host 'foobar' in Zabbix.
An Email:
Will feed these items of type Zabbix trapper, if existent:
Because I preferred the logging library used by py-zabbix I replaced the one used in inbox.py accordantly (see inbox.py-logging.patch)
First of all, this prove of concept is a very poor implementation and inspired by ZBXNEXT-3039.
ZBXNEXT-3039 would allow full control from Zabbix fronted/server side. Here, since being based on Zabbix trapper resp. Zabbix sender, only fixed item variations are used and proper items of type Zabbix trapper have to exist.
How does it work?
The Python script makes use of inbox.py and py-zabbix.
Before being started the script smtpToZbxTrap.py has to be edited to configure the following parameters:
Code:
BIND_TO_ADDR = '93.184.216.34' BIND_TO_PORT = 25 ZABBIX_SERVER_ADDR = '127.0.0.1' ZABBIX_SERVER_PORT = 10051
The ZABBIX_* variables define where the script should send values to via Zabbix trapper protocol.
Once started the script sends a bulk of item values for each received Email.
The host in Zabbix to send the values to is derived from the recipient addresses. So a recipient address like:
[email protected]
would cause the values to be send to a host 'foobar' in Zabbix.
An Email:
Code:
From: [email protected] To: [email protected] Subject: Something happened Message: This is the email body
Code:
smtp.trap[subject,[email protected]] "Something happened" smtp.trap[message,[email protected]] "This is the email body" smtp.trap[sender] "[email protected]" smtp.trap[subject] "Something happened" smtp.trap[message] "This is the email body"
Comment