Kaseya Community

Reboot Based Upon Last Reboot Time

This question is answered

I need a procedure that will allow me to select machines based upon the last reboot time and reboot them. Background-I want to reboot any servers that have not been rebooted in the last 30 days. I can sort by last reboot time and do it manually, but I am sure someone has a procedure already written to do this.

Thanks for your help.

Scott

 

Verified Answer
  • I would just make a view for that. Click Edit view button and, under Machine Status, there is an option to only show machines which have not rebooted in X days.

  • If you specifically need a procedure to do this;

    Create an SQL view, something like this

    SELECT     dbo.vMachine.Machine_GroupID, ISNULL(DATEDIFF(Day, dbo.lastReboot.rebootTime, { fn NOW() }), - 1) AS lastreboot

    FROM         dbo.vMachine LEFT OUTER JOIN

                         dbo.lastReboot ON dbo.vMachine.agentGuid = dbo.lastReboot.agentGuid

    Then in your procedure use GetVariable() --> SQL View Data --> dbo.YourViewName/lastreboot

    This will return the number of days since reboot.

    Then use if statements for the rest

    If #lastreboot# greater than 30

    Reboot()

    * -1 will show as the value of this variable if the machine hasn't rebooted since the agent was installed.

    --Chris

All Replies
  • I would just make a view for that. Click Edit view button and, under Machine Status, there is an option to only show machines which have not rebooted in X days.

  • You can also use the System Uptime counter in a monitor set and have it create an Alarm/Ticket if the system has been up for more than 'x' amount of time.

    The Alarm could just perform the reboot automatically , but probably better to have it create a Ticket or email you letting you know a reboot is required

  • If you specifically need a procedure to do this;

    Create an SQL view, something like this

    SELECT     dbo.vMachine.Machine_GroupID, ISNULL(DATEDIFF(Day, dbo.lastReboot.rebootTime, { fn NOW() }), - 1) AS lastreboot

    FROM         dbo.vMachine LEFT OUTER JOIN

                         dbo.lastReboot ON dbo.vMachine.agentGuid = dbo.lastReboot.agentGuid

    Then in your procedure use GetVariable() --> SQL View Data --> dbo.YourViewName/lastreboot

    This will return the number of days since reboot.

    Then use if statements for the rest

    If #lastreboot# greater than 30

    Reboot()

    * -1 will show as the value of this variable if the machine hasn't rebooted since the agent was installed.

    --Chris