5

I have zabbix monitoring multiple servers (Linux and Windows). Is it possible to have zabbix automate services that they are down to automatically restart?

1
  • Hi @John can you help how did you monitor Linux services i have done with windows but i need to do for linux can you help with what zabbix keys you used to monitor services status, CPU an RAM – Dexter Oct 8 '18 at 9:27
6

It is possible. First thing you will have to do is enable remote actions on zabbix agents, by setting the following in zabbix_agentd.conf:

EnableRemoteCommands=1

You will also need to grant sudo privileges to your zabbix user, so create a file /etc/sudoers.d/zabbix_nopasswd with the following content:

zabbix ALL=NOPASSWD: ALL

For better security concerns, you'd better only allow zabbix to run specific shell commands, e,g:

# allows 'zabbix' user to restart apache without password.
zabbix ALL=NOPASSWD: /etc/init.d/apache restart

After that, restart zabbix agent(s).

Now, on the Zabbix server, log in as an user that has admin privileges to Zabbix web gui, and create new action: Configuration -> Actions -> New Action. Name the new action someething like 'Restart Apache'.

Set Action Type to "Remote Command". Set Remote Command to:

{HOSTNAME}:/usr/bin/sudo service apache2 restart

After that, create a Trigger on an item that counts number of apache processes running, in a way that if the number is 0 that the action "Restart Apache" is run, and that's it.

1
  • Keep in mind that SELinux can prevent running "unapproved" task on agent – osterik Aug 22 '19 at 11:10
-1

we must I create a Trigger on an item that counts number of apache processes running, in a way that if the number is 0 that the action "Restart Apache" is run, and that's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.