Hello all,
I'm attempting a proof of concept for sending email notifications with Zabbix. Thus far we've never had it working.
I've read many forum posts, official documentation and third party guides - which broadly agree on the configuration necessary to make this work. Namely, configuring users, media types, triggers and actions.
However, despite all attempts, I never receive any emails. I want to outline what I've tried and open this up to suggestions. In particular I'm curious if there are particular logs I can interrogate, and where these might be located.
Environment
Zabbix 4.0.20
Aim is to send an email to myself when a PowerShell script on a host returns a 0 instead of a 1.
PowerShell script is stored on the host in C:\Program Files\Zabbix Agent
zabbix_agentd.conf modified to use a custom user parameter that calls 'Check.PrimaryStatus' key to invoke the script.
UserParameter=Check.PrimaryStatus,powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\Check.PrimaryStatus.ps1"
Normally, the 0 and 1 values in the script are reversed - I've set them as above so that 0 is the standard output. Because during the PoC, I want this to be the value that triggers the alert.
This all feeds the script value back into the Zabbix front-end console. This part is working fine, and if I check Monitoring > Latest Data > History for my host, filtered by the 'Item' in question, I get a value of 0 every 30 seconds.
That's great; theoretically, I should now be able create a trigger for an action so long as the condition '0' is met on this host. Which is what I've configured below.
Configuration
Under Administration > Media Types, I created a new media type called 'Email Alerts'.
Configured it as below.
Under Administration > Users, I selected my own user account, confirmed it had read-write permission over all hosts, and had been set up with a Media Type 'Email Alerts', with a 'Send to' address matching my own.
Under Configuration > Hosts > (Hostname) > Items, I created a new item called 'Check Whether Primary or Secondary' as below. The key matches up to the key in the zabbix_agentd.config UserParameter line.

Under Configuration > Hosts > (Hostname) > Triggers, I created a new trigger and configured as below.

Under Configuration > Actions, I created an action as below. Gave it a name, said A and B must be true, set the conditions to "Trigger severity equals Warning' and 'Trigger equals <trigger name>'
Under Operations tab, I configured the below. Default message recurring every 60 seconds, sending a message to my own user account, using the media type 'Email Alerts'.
If I examine the Triggers for this host, my custom trigger exists and is reporting as a Warning with a PROBLEM value. As expected.
I'm attempting a proof of concept for sending email notifications with Zabbix. Thus far we've never had it working.
I've read many forum posts, official documentation and third party guides - which broadly agree on the configuration necessary to make this work. Namely, configuring users, media types, triggers and actions.
However, despite all attempts, I never receive any emails. I want to outline what I've tried and open this up to suggestions. In particular I'm curious if there are particular logs I can interrogate, and where these might be located.
Environment
Zabbix 4.0.20
Aim is to send an email to myself when a PowerShell script on a host returns a 0 instead of a 1.
PowerShell script is stored on the host in C:\Program Files\Zabbix Agent
zabbix_agentd.conf modified to use a custom user parameter that calls 'Check.PrimaryStatus' key to invoke the script.
UserParameter=Check.PrimaryStatus,powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\Check.PrimaryStatus.ps1"
Normally, the 0 and 1 values in the script are reversed - I've set them as above so that 0 is the standard output. Because during the PoC, I want this to be the value that triggers the alert.
This all feeds the script value back into the Zabbix front-end console. This part is working fine, and if I check Monitoring > Latest Data > History for my host, filtered by the 'Item' in question, I get a value of 0 every 30 seconds.
That's great; theoretically, I should now be able create a trigger for an action so long as the condition '0' is met on this host. Which is what I've configured below.
Configuration
Under Administration > Media Types, I created a new media type called 'Email Alerts'.
Configured it as below.
- SMTP server: Tried my mail server. (On-prem Exchange)
- SMTP Port: 25
- SMTP helo: Have made this the same as the SMTP server.
- SMTP email: This is just the address the email will be coming from, can effectively be anything.
- Authentication: Tried this with and without. With, using my admin creds which I know have authority to log onto the mail server.
Under Administration > Users, I selected my own user account, confirmed it had read-write permission over all hosts, and had been set up with a Media Type 'Email Alerts', with a 'Send to' address matching my own.
Under Configuration > Hosts > (Hostname) > Items, I created a new item called 'Check Whether Primary or Secondary' as below. The key matches up to the key in the zabbix_agentd.config UserParameter line.
Under Configuration > Hosts > (Hostname) > Triggers, I created a new trigger and configured as below.
Under Configuration > Actions, I created an action as below. Gave it a name, said A and B must be true, set the conditions to "Trigger severity equals Warning' and 'Trigger equals <trigger name>'
Under Operations tab, I configured the below. Default message recurring every 60 seconds, sending a message to my own user account, using the media type 'Email Alerts'.
If I examine the Triggers for this host, my custom trigger exists and is reporting as a Warning with a PROBLEM value. As expected.
Comment