Ad Widget

Collapse

Help with Actions.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikechamb
    Junior Member
    • Feb 2017
    • 2

    #1

    Help with Actions.

    I am very new to zabbix and need a bit of assistance with creating actions.

    What I would like to do is if a service e.g. lets say a windows service stops, it could be any one of the discovered services on my windows host. I would like to restart that service and send an email to the zabbix administrator when the service has restarted successfully.

    So I have created an action that if Trigger severity = high, to send an email to the admin. This works fine!!

    The problem I am having is I want to restart the failed service and send an acknowledgement email on successful restart of that failed service.
    The problem is I don't know what to put in the operation details.
    I was thinking of using remote commands, I have enabled remote commands on my windows host.

    Operation type = remote command
    Target list = current host
    Type = custom script
    Execute on Zabbix agent

    Commands - I don't know what to put here?? I am using SC commands here. So I would enter:
    sc start "servicename"
    So if the Spooler service stopped, I would put:-
    sc start "Spooler"

    This works fine, if I know what service has stopped and enter the servicename. What happens when I don't know what service has stopped? Zabbix will have a trigger to say a particular service has stopped and the severity has gone to high for that service.
    Are there some commands I can enter here that say, find the stopped service and restart it then send an email on success?

    Any assistance would be much appreciated.
  • Jvlavl
    Member
    • Sep 2015
    • 37

    #2
    This is very easy to do.

    here is how to do it

    Click on Configuration > Actions > click Create action (top right corner) > Enter Action name and leave rest as default

    Click on Conditions tab > Leave condition label (A) > remove any other conditions

    Conditions tab > add a new Trigger condition (Like so: Trigger = select the trigger created for the service (by clicking select)) > click Add to add the new condition

    Click on Operations tab > Change Operation type to “Remote command” > Enter new Target as current host >

    Type equals ‘Custom script’ > Execute equals ‘Zabbix agent’ > enter Command “sc \\{HOST.NAME} start ServiceName” > click Add to add the new reactive action and save the configuration

    Rgds,

    John

    Comment

    • mikechamb
      Junior Member
      • Feb 2017
      • 2

      #3
      Help with actions.

      Hello John,
      Thanks for the very prompt reply. Zabbix community seems nice and active.

      Apologies for sounding such a zabbix newbie.

      I understand how to create a specific action for example when a specific service stops on a specific host and the trigger for that service executes. So I create an action on local host to execute a run command.
      I execute a custom script on zabbix agent to restart that specific service. So for example if the Spooler service stops, I enter the following command:-
      sc start "Spooler"

      What I would like to do is create an action based on "if any service stops", to run a custom script to restart the service that has stopped! On my Windows servers for example there are 50 different services. Maybe 5-10 of those services are critical and if they stop I would like zabbix to attempt to restart them and inform me, firstly that it has stopped and secondly that the service has been restarted ok.

      You mentioned to execute “sc \\{HOST.NAME} start ServiceName” but what do I put for "ServiceName" if it could be any of the stopped services?
      I was hoping I could put an expression here, something like
      sc \\{HOST.NAME} start service.info[{#SERVICE.NAME},state].min(#3)}=6
      as the value 6 is the stopped state?

      Maybe this example is better to be a global script with an expression like this?


      Rgds,
      Mike

      Comment

      • Hernandes Martins
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Apr 2011
        • 900

        #4
        Hi Mike,

        See new option in version 3.2, tags:
        It is new concept in Zabbix 3.2, one item, one trigger for all services!


        __

        Att.
        Hernandes Martins - Zabbix Trainer

        Zabbix Brazil Partner - www.luniobr.com

        Zabbix Brazil Community - www.zabbixbrasil.org

        Blog: hernandesmartins.blogspot.com.br

        Skype: hernandss
        Telegram: @MrHernandes

        Español
        Facebook: facebook.com/groups/zabbixlatam
        Telegram: https://t.me/ZabbixEspañol

        Português
        Facebook: facebook.com/groups/zabbixbrasil/
        Telegram: https://t.me/ZabbixBrasil

        Comment

        • diddimus
          Junior Member
          • Jun 2017
          • 2

          #5
          I'm looking for an answer to this too. Can you explain in a bit more detail how you would do this?

          I want one "restart service" action that knows which service to restart.

          Thanks

          Comment

          • Hernandes Martins
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Apr 2011
            • 900

            #6
            Hi Mike,

            Please, send print action
            __

            Att.
            Hernandes Martins - Zabbix Trainer

            Zabbix Brazil Partner - www.luniobr.com

            Zabbix Brazil Community - www.zabbixbrasil.org

            Blog: hernandesmartins.blogspot.com.br

            Skype: hernandss
            Telegram: @MrHernandes

            Español
            Facebook: facebook.com/groups/zabbixlatam
            Telegram: https://t.me/ZabbixEspañol

            Português
            Facebook: facebook.com/groups/zabbixbrasil/
            Telegram: https://t.me/ZabbixBrasil

            Comment

            Working...