2

I am trying to restart flanneld service running on one VM from my zabbix server UI using triggers and action. I followed the zabbix-docs. zabbix user has sudo permissions ( verified this by logging as zabbix user and running command sudo yum update ). Command used to start flanneld is sudo /usr/bin/flanneld. Does anyone know the cause ?
Configuration done :
Action is created on trigger "flanneld service not running" as-

Conditions :-
Trigger = my Zabbix server: flanneld service not running
Host = my Zabbix server
Operations :-
Target list : Host: my Zabbix server Execute on Zabbix agent
Commands : sudo /usr/bin/flanneld

thanks in advance.

Yogesh Jilhawar
  • 5,605
  • 8
  • 44
  • 59
  • How did you detect that the remote command did not run? Are there any error messages in Zabbix frontend ("Reports" -> "Action log") or Zabbix server logs? – asaveljevs Aug 23 '16 at 13:17
  • And if the command is run but fails, could it be that interactive use of sudo is required ? Check that `requiretty` in sudoers is disabled for the zabbix user. – Richlv Aug 23 '16 at 13:47
  • @asaveljevs status for action in "reports" -> "Action log" is "executed" . However, I am not able to see flanneld process started. – Yogesh Jilhawar Aug 24 '16 at 09:09
  • @Richlv Line from my sudoers file is "#Defaults requiretty". How to check that this line is specific for the zabbix user ? – Yogesh Jilhawar Aug 24 '16 at 09:16
  • That line is commented out already. Redirect stdout and stderr from your command to a file, inspect it afterwards. – Richlv Aug 24 '16 at 13:58
  • @Richlv @asaveljevs Problem solved. That was because of SELinux which was in enforcing mode. I changed that to permissive mode by using command `setenforce 0`. – Yogesh Jilhawar Aug 29 '16 at 09:56

1 Answers1

1

I would firstly append sudo within your script to the relevant sections so you do not need to worry about that and simply add the location to your script within Zabbix.

You will then need to ensure that you have enabled "EnableRemoteCommands" as by default running a remote command is disabled on a Zabbix agent.

You can do this by simply adding the following line in your zabbix_agent.conf file.

EnableRemoteCommands=1
Kyle Steenkamp
  • 131
  • 1
  • 4