Ad Widget

Collapse

Execute Remote Command just Once a Day

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ThiagoAmorim
    Junior Member
    • Dec 2021
    • 1

    #1

    Execute Remote Command just Once a Day

    Hello,
    I'm beginner in Zabbix and some days I have been looking in the forums the solution or a tip for my problem.

    Explain:
    I have a Action to execute a Remote Command to restart a service in windows for example Spooler, but I want to avoid the restart the service more than once in a day or 24 hours... Currently every time that service is down is restarted...

    I created a Item like -> service.info[spooler, state];
    After I created 2 triggers for this Item... One Trigger just alarm and other to alarm and fired remote command (restart service)... I tried use count...but no success.

    Triggers:

    {HOST1:service.info[spooler, state].last()}<>0

    {HOST1:service.info[spooler, state].last()}<>0 and {HOST1:service.info[spooler, state].count(1,2,gt,86400)}>1


    I need a trigger that show the first Failure of de Service on day and execute remote command to restart service, and if the service goes down again less of 24 hours, just show de failure without execute remote command.

    Could someone help me please...

    Thanks....
    Last edited by ThiagoAmorim; 02-12-2021, 19:39.
  • riBoon
    Junior Member
    • May 2017
    • 25

    #2
    You didn't tell us the zabbix version but
    {HOST1:service.info[spooler, state].count(1d,2)}=1
    Maybe that could it be. It triggers when in the last day (24 hours) it gets the value 2 (if the value is different then you have to correct this) but only one value matches. Its untested.
    Or {HOST1:service.info[spooler, state].count(1d,0,gt)}=1
    Tthis triggers if in the last 24 hours you get values greater than 0 but only if one value matches

    If you really need the first time a day then your service start script have to handle this or you need a script between zabbix and your server start script.
    Last edited by riBoon; 07-12-2021, 13:09.

    Comment

    • rahulnakade
      Junior Member
      • Jan 2023
      • 5

      #3
      Hello all,
      I am using zabbix version Zabbix 6.2.4 and on client side it is zabbix-agent2
      I have created the Action on the trigger.
      item --> get information process is running or not.

      system.run["ps -aux | grep -i 'proces' | grep -v 'grep' | wc -l"]

      trigger --> When process is down that time trigger id generated.

      last(/Monitor process/system.run["ps -aux | grep -i 'proces' | grep -v 'grep' | wc -l"])<1
      0 indicate --> Through the alert in zabbix
      1 indicate --> do not do anything.

      Action --> When trigger is present in the zabbix Action execute the service start script.

      Up to this point all function is working fine.

      But i want this action should done once in a day. Like whenever day's 1st alert is present in the zabbix that time Action will restart the service/process.

      Can you guide me on this.
      It will help me a lot.

      Thanks in advance.

      Comment

      • rahulnakade
        Junior Member
        • Jan 2023
        • 5

        #4
        can anyone help me in this?

        Comment

        Working...