Ad Widget

Collapse

Stop and start Windows service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lazareus
    Member
    • Sep 2015
    • 39

    #1

    Stop and start Windows service

    Hello,


    I have a problem doing an action to stop and start a Windows service.

    I'm looking for an action to do this :

    net stop "servicename"
    net start "servicename"

    So i created my action but i don't want to use a trigger as condition but a time.

    For example, i want to do my action at 5pm every day. And every day at 5pm, my action should stop and start my service.


    Someone can help me to find a solution please?

    Thanks in advance.
  • GPegel
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2015
    • 113

    #2
    this depends on which version of Zabbix you are using. Version 3 is capable of doing this by scheduling an item. https://www.zabbix.com/documentation...stom_intervals

    Comment

    • Sugarman
      Junior Member
      • Oct 2014
      • 22

      #3
      Originally posted by Lazareus
      For example, i want to do my action at 5pm every day. And every day at 5pm, my action should stop and start my service.
      But wouldn't it be much easier to just use the Scheduled Task function in Windows itself? You could still - if neccessary go check the logs with Zabbix afterwards. I usually just check if Zabbix reported the server being offline in a certain timeframe...

      Cheers,
      Timo

      Comment

      • Lazareus
        Member
        • Sep 2015
        • 39

        #4
        Thanks for your answers.


        @GPegel: My Zabbix version is 2.2 and i don't think this solution is included in my version but thanks for the info.

        @Sugarman: Yes i can use the scheduled task from Windows but the goal of this is to log those service restart in a Zabbix action for Available statistics.

        Comment

        • Sugarman
          Junior Member
          • Oct 2014
          • 22

          #5
          If you want to monitor the availability of the Windows service, why not monitor its available state with Zabbix and restart it via Windows task scheduler? While it's restarting you'll get a "not available" (if its actually taking that kind of time to stop/restart) state in Zabbix which you can nicely use for any kind of statistics...

          Comment

          • Lazareus
            Member
            • Sep 2015
            • 39

            #6
            That sounds good.

            But as i have actions configured to send notifications by email and send me a text message when i restart my service, i don't know if a trigger of the availability state is enough ... Because if the service crash or is restart for another reason out of my range time, i'll receive wrong notifications.

            I don't know if what i say is clear enough for you to understand all the problem.

            Thanks for your help.

            Comment

            • sergio.cricca
              Member
              • Mar 2008
              • 43

              #7
              I use this kind of "timing" very often.
              Take this example of trigger:
              Code:
              {Template_restart_service:item_checked_each_60seconds.time()}>170000 and {Template_restart_service:item_checked_each_60seconds.time()}<170200
              This trigger just checks only if time is > 17:00:00 (written without ":") and < 17:02:00.
              Trigger gets on for 2 minutes and you could attach any kind of action to it.

              Check time() condition in triggers.
              Bye

              Comment

              • Lazareus
                Member
                • Sep 2015
                • 39

                #8
                @sergio.cricca: Thank you very much. This is exactely what i was looking for.

                Thanks to Sugarman and GPegel too for your help.


                Bye.

                Comment

                Working...