diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 6e1a941..54be772 100644 --- a/README.md +++ b/README.md @@ -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). \ No newline at end of file diff --git a/sample-config/postfix.running-zabbix-item.png b/sample-config/postfix.running-zabbix-item.png new file mode 100644 index 0000000..72a73a3 Binary files /dev/null and b/sample-config/postfix.running-zabbix-item.png differ diff --git a/sample-config/postfix.running-zabbix-trigger.png b/sample-config/postfix.running-zabbix-trigger.png new file mode 100644 index 0000000..b5b2951 Binary files /dev/null and b/sample-config/postfix.running-zabbix-trigger.png differ