PDA

View Full Version : [1.4.1]Help : syntax for 2 triggers in 1 action


SebD
14-08-2007, 10:41
Hello,

I've got 2 triggers. They are ok and running :
- "Apache is not running" from the item "check apache"(Zabbix Agent)
- "Service Apache Restart" from the item "check service apache" (Zabbix trapper setting by an own php page)

I d'like to have an action with this 2 triggers.
In fact when the 2 triggers are true, the action have to be run and so Apache must be restart by a script.

I've tested my shell script and it's running.

Here is the description of the action :
Name : Action Apache Restart
Event source : Triggers
Type of calculation : AND
Conditions : (A and B) and (C)
(A) Trigger = "Apache is not running"
(B) Trigger = "Service Apache Restart"
(C) Trigger value = "TRUE"

Operations Run remote commands
(Edit : ServerName:./opt/zabbix/start_apache)

Status : Enabled

Do you think that the conditions are ok?

In fact, I have to put this condition : (A and C) and (B and C)

Thanks!

Sébastien

SebD
14-08-2007, 17:12
Hello!

I've solved my problem by putting 2 items ("check apache" and "start apache" or "stop apache") by trigger. The action (start or stop apache) is running when the trigger triggered.

Here is the items :
- check.apache : zabbix agent who return the status of Apache (1 or 0)
- start.apache : zabbix trapper who switch on/off the start of apache (1 or 0)
- stop.apache : zabbix trapper who switch on/off the stop of apache (1 or 0)

Here is the 2 triggers :
- start apache : ({ServerName:check.apache.last(0)}#1)&({ServerName:start.apache.last(0)}#0)
- stop apache : ({ServerName:check.apache.last(0)}#0)&({ServerName:stop.apache.last(0)}#0)

Here is the 2 actions :
Name : Action Apache Start
Event source : Triggers
Type of calculation : AND
Conditions : (A) and (B)
(A) Trigger = "start apache"
(B) Trigger value = "TRUE"
Operations Run remote commands
(Edit : ServerName:./opt/zabbix/start_apache) => my own shell script to start apache
Status : Enabled

Name : Action Apache Stop
Event source : Triggers
Type of calculation : AND
Conditions : (A) and (B)
(A) Trigger = "stop apache"
(B) Trigger value = "TRUE"
Operations Run remote commands
(Edit : ServerName:./opt/zabbix/stop_apache) => my own shell script to stop apache
Status : Enabled


To simplify this to simple users, I've return the status of Apache in a php page and add 2 buttons (ON and OFF) using zabbix_sender :
echo exec('zabbix_sender -z ZabbixServer -p 10051 -s Host -k start.apache -o 1');
echo exec('zabbix_sender -z ZabbixServer -p 10051 -s Host -k start.apache -o 0'); // not necessary, just to reset the value of the start.apache item to 0
OR
echo exec('zabbix_sender -z ZabbixServer -p 10051 -s Host -k stop.apache -o 1');
echo exec('zabbix_sender -z ZabbixServer -p 10051 -s Host -k stop.apache -o 0');not necessary, just to reset the value of the stop.apache item to 0

Now I'm going to do the same thing with others services!

Sébastien