Hi all!
We are still loving Zabbix for our monitoring solution. We are currently running 4.0.4 in production, with proxies and additional servers in the regions so the admins there can monitor their own hosts, but we at HQ can monitor everything.
Everything works well out-of-the-box for standard checks, but now we are being asked to have the Zabbix server call custom health/check scripts on the hosts so an admin can be alerted if an application isn't working as expected. In an effort to reduce the workload (and required expertise with respect to custom applications we provide servers for, but have no actual hands-on experience with ourselves) we've asked the admins and developers to create their own scripts to check the health of their apps. After all, they are the experts on those apps, unlike the rest of us in the infrastructure team.
I am hoping someone can assist me in figuring out how to have the Zabbix server call a custom script as such, and alert if needed based on the output. What is the "Best Practice" and the required steps to configure the Zabbix server to run a script and alert if there are errors found? For example, the team responsible for an app we have on Windows wrote a simple PowerShell script:
# Pseudocode for C:\Scripts\check.ps1
if port available
echo "No issues found"
exit (0)
else
echo "Not responding"
exit (1)
With that in place on the host, here's what I tried to do on the Zabbix server under Administration > Scripts > "Create script" :
Name: Test Windows Check
Type: Script
Execute on: Zabbix agent
Commands: C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -ExecutionPolicy Bypass C:\Scripts\check.ps1 -RunType $True -Patch C:\
...
Questions:
1. Is Administration > Scripts > "Create script" the correct place to configure it?
2. Do I need to create a host group for each server in order to have different scripts on the hosts?
3. How do I schedule this to run every 15 minutes? (Do I need to create a corresponding item for the script? Do I need to use the UserParameter= line in the zabbix_agentd.conf on the host?)
4. How do I send an alert if it exited with a non-zero (hopefully in more complicated ones I can create let's say an email if exit=1, an SMS if exit=2, and so on). Would this be done via triggers or events?
I'm feeling a bit lost despite having a good grasp of the basics for Zabbix installation and maintenance. I noticed in https://www.zabbix.com/forum/zabbix-...rom-a-cron-job that someone is using zabbix_sender, but even that doesn't seem to be as straight-forward as I thought at first, and that isn't part of the agent package but a separate install. I think the -k is for a key, and he still created an item for it. Where does one define the key? In the UserParameter= line of the zabbix_agentd.conf on the host? Or on the Zabbix server somewhere? I think I need a full rundown, as the wiki has left me with more questions than when I first started trying to get these working!
Thanks in advance for any assistance you can provide, and as always, keep up the amazing work.
We are still loving Zabbix for our monitoring solution. We are currently running 4.0.4 in production, with proxies and additional servers in the regions so the admins there can monitor their own hosts, but we at HQ can monitor everything.
Everything works well out-of-the-box for standard checks, but now we are being asked to have the Zabbix server call custom health/check scripts on the hosts so an admin can be alerted if an application isn't working as expected. In an effort to reduce the workload (and required expertise with respect to custom applications we provide servers for, but have no actual hands-on experience with ourselves) we've asked the admins and developers to create their own scripts to check the health of their apps. After all, they are the experts on those apps, unlike the rest of us in the infrastructure team.
I am hoping someone can assist me in figuring out how to have the Zabbix server call a custom script as such, and alert if needed based on the output. What is the "Best Practice" and the required steps to configure the Zabbix server to run a script and alert if there are errors found? For example, the team responsible for an app we have on Windows wrote a simple PowerShell script:
# Pseudocode for C:\Scripts\check.ps1
if port available
echo "No issues found"
exit (0)
else
echo "Not responding"
exit (1)
With that in place on the host, here's what I tried to do on the Zabbix server under Administration > Scripts > "Create script" :
Name: Test Windows Check
Type: Script
Execute on: Zabbix agent
Commands: C:\Windows\System32\WindowsPowerShell\v1.0\powersh ell.exe -ExecutionPolicy Bypass C:\Scripts\check.ps1 -RunType $True -Patch C:\
...
Questions:
1. Is Administration > Scripts > "Create script" the correct place to configure it?
2. Do I need to create a host group for each server in order to have different scripts on the hosts?
3. How do I schedule this to run every 15 minutes? (Do I need to create a corresponding item for the script? Do I need to use the UserParameter= line in the zabbix_agentd.conf on the host?)
4. How do I send an alert if it exited with a non-zero (hopefully in more complicated ones I can create let's say an email if exit=1, an SMS if exit=2, and so on). Would this be done via triggers or events?
I'm feeling a bit lost despite having a good grasp of the basics for Zabbix installation and maintenance. I noticed in https://www.zabbix.com/forum/zabbix-...rom-a-cron-job that someone is using zabbix_sender, but even that doesn't seem to be as straight-forward as I thought at first, and that isn't part of the agent package but a separate install. I think the -k is for a key, and he still created an item for it. Where does one define the key? In the UserParameter= line of the zabbix_agentd.conf on the host? Or on the Zabbix server somewhere? I think I need a full rundown, as the wiki has left me with more questions than when I first started trying to get these working!
Thanks in advance for any assistance you can provide, and as always, keep up the amazing work.
Comment