Kaseya Community

looking for reboot script that increases checkin time notifications

  • I need to reboot servers through a script but want to increase the checkin time to about 15 minutes so we don't all get notifications just for a reboot. Then I would like to decrease it back to about 5 minutes. Does anybody have this script written already?

    Legacy Forum Name: looking for reboot script that increases checkin time notifications,
    Legacy Posted By Username: droland@teksinc.com
  • WHen the agent goes offline for x(5?) minutes, run a script. The script pauses for x minutes and then checks to see if the agent is back online. If so send email it is online, else trigger an alert that the server is down.

    We have something like this setup on half of our servers right now. This way we get alerted when server goes down during the day almost immediately, but it must be down for over 30 minutes before we get alerted at night.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • Thanks Jon, that looks like the best known solution, however I'm still trying to do something a little different. Scheduled reboots should be able to go through without ever notifying our emergency line therefore I want to disable/delay the agentOffline notifications while the server reboots via kscript, but I still want to know if it goes down within a couple of minutes of an unscheduled reboot.

    What I really want is a script for rebooting servers that does the following, or any means of achieving the following:
    1. UPDATE dbo.alertAgentOffline SET secondsOffline = '900' WHERE agentGUID = @agentGUID
    2. Reboot the server
    3. UPDATE dbo.alertAgentOffline SET secondsOffline = '180' WHERE agentGUID = @agentGUID

    I’ve attempted the following to achieve this
    1. Attempted to run sql code directly from Kaseya scripts – unsuccessful running any sql code
    2. Attempted to exec or call stored procedure, even tried naming it with a “v” in the beginning of the name wondering if you guys filtered sql commands by name – unsuccessful
    3. Attempted to run command local on kserver that fires “sqlcmd -d ksubscribers –Q “exec vPreServerReboot ‘#agentGUID’” – unsuccessful because once I run a script on a device, the script commands appear to run on that device and I can’t figure out how to make it run local on the kserver instead of on the client device.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: droland@teksinc.com
  • Getting into SQl is a bit much for me still. One other idea and I'll step back and let someone else try to help you:

    Configure your alerts to notify you as quickly as needed a server is down. For nightly reboots, get in a habit of either globally or by client rebooting between a set time period ONLY. During this time period, 30 minutes to an hour, suspend the agent offline alert.

    If reboot at 3:00am, suspend untill 4:00. If server is still offline, it will then alert you.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • JonJohnston
    WHen the agent goes offline for x(5?) minutes, run a script. The script pauses for x minutes and then checks to see if the agent is back online. If so send email it is online, else trigger an alert that the server is down.

    We have something like this setup on half of our servers right now. This way we get alerted when server goes down during the day almost immediately, but it must be down for over 30 minutes before we get alerted at night.


    Hi Jon. We desperately want this ability. Can you explain your script in more detail (if you don't mind sharing). I know how to execute a script on agent down, but how do you have this script check to see if the machine is online? Also, how do you make this immediate during the day but delayed at night?

    I am eagerly awaiting your reply. This has been our biggest gripe with the Kaseya system for the past 3 years.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: far182
  • Sorry, haven't been online in a couple of days. No I do not mind sharing. I have borrowed numerous scripts from others on here so giving up some of mine is fine by me.
    Here is some basic info on our setup:

    When agent is offline for 1 minute, we recieve an email alert. A script is also scheduled to run when the agent is offline. This script runs from our kserver. Since this runs from the kserver and is triggered by a monitor, some of the variables are different then what is in a normal script. First step is a pause (30 minutes for us). This way we get an email that the agent is offline, but it is 30 minutes before our pager or anything else goes off.

    I am attaching the scripts. There are 3 total, the first one calls upon 2nd calls upon 3rd.

    Script1
    Script Name: Connection Check
    Script Description: Pings to Google to check connection.

    IF True
    THEN
    Pause Script
    Parameter 1 : 1800
    OS Type : 0
    Execute Shell Command
    Parameter 1 : ping client_IP >>C:\utility\offline\#id#ping.txt
    Parameter 2 : 0
    OS Type : 0
    Execute Script
    Parameter 1 : Test Agent Online (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0
    ELSE



    Script2: This checks if the agent has checked in since the alert was thrown. If so, agent is online and no need to alert.
    Script Name: Test Agent Online
    Script Description: Test if machine is online, if so sends email saying is online or else triggers alert.

    IF Check Variable
    Parameter 1 : #qt#
    >= :#at#
    THEN
    Send Email
    Parameter 1 : support@domain.com
    Parameter 2 : #id# is online
    Parameter 3 : #id# is online at #qt#.
    OS Type : 0
    ELSE
    Execute Script
    Parameter 1 : Alert to Email/Pager (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0



    Script3. At this time it has been approx. 33 minutes since the agent checked in. We are going to bump this up to an hour (change pause in the very first step of first script).
    Script Name: Alert to Email/Pager
    Script Description:

    IF Test File
    Parameter 1 : C:\utility\offline\#id#ping.txt
    Contains :bytes=
    THEN
    Send Email
    Parameter 1 : support@domain.com, pageralert@wireless.net
    Parameter 2 : Server offline #id#
    Parameter 3 : The client gateway is pinging but #id# is offline. This needs checked immediately. The last check in was at #qt#.
    OS Type : 0
    ELSE
    Send Email
    Parameter 1 : support@get-covered.com
    Parameter 2 : #id# offline and no ping
    Parameter 3 : #id# is offline, and the gateway is unreachable. This is probably an internet down situation or a power outage but still needs checked into. The last check in was at #qt#.
    OS Type : 0



    In the first script, enter the live IP of your client. Will need to make sure that you can ping their firewall. What we do is check to see if we can ping the firewall. If so, internet is up but the server is showing offline. Otherwise, internet or power is down.

    This way we get an email within 3 minutes that the agent is offline and can check into it during the day before the client even calls. At night, it is 30 minutes to an hour before we get alerted.

    With the new release of Kaseya, we should have even more flexible scheduling capabilities. If you need more explaination with the above setup let me know.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • Thanks for the post...

    One question though.
    How do you specify the client_IP to ping in script 1.

    Do you have a separate script for each site.
    Do you use some sort of variable to calculate the gateway IP and (if so) would you mind sharing how you lookup the gateway IP.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: garry
  • garry
    Thanks for the post...

    One question though.
    How do you specify the client_IP to ping in script 1.

    Do you have a separate script for each site.
    Do you use some sort of variable to calculate the gateway IP and (if so) would you mind sharing how you lookup the gateway IP.


    Unfortunately I had to use a seperate script for each client. I did my best to find a variable that would pull the gateway, but could not get it to work properly. Only the first script must be different, the other two are the same globally.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • John, thanks again for the scripts. One question, and please forgive my ignorance. How do the variables #id# #qt# and #at# work? I would think the #id# would be the machine the script is running on.

    when i implemented it here, the e-mails wouldn't actually go out if I used the script with the variables in it. Once I took them out it was OK.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rbjsea
  • rbjsea
    John, thanks again for the scripts. One question, and please forgive my ignorance. How do the variables #id# #qt# and #at# work? I would think the #id# would be the machine the script is running on.

    when i implemented it here, the e-mails wouldn't actually go out if I used the script with the variables in it. Once I took them out it was OK.


    It took me forever to find those variable. In the help file of Kaseya, I was going through the index and there is a vMonitorAlarmAlert which can be used for variables. However, the ones I used came from Alerts-Agent Status inside of the help index.

    They have worked for us in testing and production. The #id# is used for the machine that triggers the alert, #at# is alert time, and #qt# is the last check-in.

    Now because the variables are for an alert, they do not run in a regular script. Also, are you running the script from the Kserver as that will make a difference from what I have seen.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston