Add postfix monitoring setup

This commit is contained in:
moeny-matt 2025-05-16 15:04:56 -04:00
parent 80112021f6
commit 94aa036f2e
4 changed files with 59 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

View File

@ -1,2 +1,60 @@
# zabbix
## Setting Up Monitoring for a Postfix Service
### On the Mail Server
1. Edit the Zabbix agent configuration file:
`vim /etc/zabbix/zabbix_agent2.d/postfix.conf`
2. Add the following line:
`UserParameter=postfix.running,script /tmp/postfix-script-zabbix.log -qc 'sudo postfix status' | grep -c 'PID'`
3. Ensure your Zabbix agent is configured for active checks by checking these parameters in your `/etc/zabbix/zabbix_agent2.conf`:
```
ServerActive=your_zabbix_server_ip
HostnameItem=system.hostname
```
4. Restart the Zabbix agent:
`systemctl restart zabbix-agent2`
5. Check the status of the Zabbix agent:
`systemctl status zabbix-agent2`
The mail server's Zabbix agent will now collect the Postfix status using a script command and report that data back to the Zabbix server. The Zabbix server must then be configured to processes this information and handle alerting.
### In the Zabbix web interface:
1. Create a new item for your host
`Data collection -> Hosts -> Items (column next to the desired host) -> Create item (at top right)`
2. Set the following parameters:
- Name: `Monitor postfix service`
- Type: `Zabbix agent (active)`
- Key: `postfix.running`
- Type of information: `Text`
- Description (optional): `Monitor postfix service.`
![sample-config-item](sample-config/postfix.running-zabbix-item.png)
3. Click "Add" to save the item
4. Create a trigger based on the return value
`Data collection -> Hosts -> Triggers (column next to the desired host) -> Create trigger (at top right)`
5. Set the following parameters (Replace instances of `mail_server_hostname` with your actual host name in Zabbix):
- Name: `Postfix service is not running on {HOST.NAME}`
- Severity: `High`
- Problem expression: `last(/mail_server_hostname/postfix.running)=0`
- OK event generation: `Recovery expression`
- Recovery expression: `last(/mail_server_hostname/postfix.running)>0`
- PROBLEM event generation mode: `Single`
- OK event closes: `All problems`
- Description (optional): `Postfix has stopped running.`
![sample-config-trigger](sample-config/postfix.running-zabbix-trigger.png)
6. Click "Add" to save the trigger
This trigger will fire when the Postfix check returns 0 (not running) and will automatically resolve when the check returns a value greater than 0 (running).

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB