Jump to content

How to: Reboot target and get completion notification


Recommended Posts

The first thing you'll want to do is change the email address target (unless you really are homer@simpsonsVille.net) Hit the 'Globals and Parameters' tab and update the @targetEmailAddy variable to point it to the email box you want to receive the notification.

 

This script send the reboot command to the target, then watches the LT database for that computer to start reporting back in. Once it sees that, it'll send you a note to let you know your target has been rebooted and is now back up.

 

You may want to consider adding loop management to this so that if the target computer doesn't come back up, you'll be notified of that event too.

lt.script.bounce.and.notify.zip

Link to post
Share on other sites

Very nice... I changed the parameters to prompt for the Email Address that way I can have any one of my techs run it.

 

I suppose it could be scripted to just grab the email for whoever the tech is that is running it............ hmmmmmmm

Link to post
Share on other sites

Does this require a certain version of LabTech?

I tried importing it to check it out, but it won't import. There aren't any errors or anything, it just doesn't import so I was thinking maybe it required a different version of LT.

(And I know it isn't hiding in some folder, I'm manually checking the tables in the database for the script and it's not there)

We are on LT 2012.1

I noticed if I look at this script file in notepad, the version shows "60.239" where if I export any script, or look at other scripts I have found online, the version usually shows just "1".

Thanks

Link to post
Share on other sites
Does this require a certain version of LabTech?

I tried importing it to check it out, but it won't import. There aren't any errors or anything, it just doesn't import so I was thinking maybe it required a different version of LT.

(And I know it isn't hiding in some folder, I'm manually checking the tables in the database for the script and it's not there)

We are on LT 2012.1

I noticed if I look at this script file in notepad, the version shows "60.239" where if I export any script, or look at other scripts I have found online, the version usually shows just "1".

Thanks

 

If the version is showing 60.239, then the script was exported from LT 2013. You will not be able to import the script without modifications. I'll see if I can modify it and re-upload for you.

 

-jeff

Link to post
Share on other sites

Okay, I figured it was something like that.

Not sure when our company will get the 2013 as it's a staggered rollout or something.

I can write scripts to deploy and run utilities and stuff, and to reboot you can use the LT Command for Reboot.

I am curious about the section for monitoring when it's back up and then send an email. Interesting.

Thanks

Link to post
Share on other sites

Thanks for the script Rob! I made some modifications and wanted to give back by sharing!

 

It seems none of our machines check back in within the 30 second window in the original script so the sql line always moved on to sending the success email even if the machine didn't come back up, so I increased this to 600 seconds to make it more reliable for us.

 

Then I took cgauss' idea to add in the @tech_email@ so that it emails the tech running the script.

 

I also added a loop with the script math function and a fail condition so it actually will email the tech whether it fails or succeeds (may be able to save some time reading emails by disabling the success emails and only get notified of failures). This was my first time trying to work out how to loop in labtech and Im not a programmer so it may not be the best way to do it.

 

Also added some logging that could be disabled (I prefer chatty scripts for troubleshooting and just so I know whats going on in general). This is exported from 2012.1 so it shouldn't have issues importing.

 

I'm sure someone else could make it prettier but it seems very reliable for us.

 

- Ryan

 

*edit* removed file, download latest on next page

Edited by Guest
Link to post
Share on other sites

Hi Guy's, Love the idea of this script but cannot seem to get it working. from the looks of it the SQL statement "select timeStampDiff(second, STR_TO_DATE('@startreboottime@', '%m/%e/%Y %r' '%m/%e/%Y %r'), STR_TO_DATE('@strlastcontact@', '%m/%e/%Y %r' '%m/%e/%Y %r'))"

 

is not working my log of the variable %sqlresult% just displays the text "%sqlresult%" where id expect to see a number for the compare statement?

 

any idea's

Link to post
Share on other sites

figured it out it was a issue with the reading of the date. I'm from Australia so had to switch %m/%e around so it looks like this

 

 

select timeStampDiff(second, STR_TO_DATE('@startreboottime@', '%e/%m/%Y %r' '%e/%m/%Y %r'), STR_TO_DATE('@strlastcontact@', '%e/%m/%Y %r' '%e/%m/%Y %r'))

Link to post
Share on other sites
  • 5 months later...
  • 2 weeks later...

@SamRau,

 

I tried importing the "lt.script.bounce.and.notify" script, and it seems to crash my labtech client, I believe because as this thread shows it's an LT2012 script, so that's why the 'Bounce and Notify' was created.

I tried importing the "Bounce and Notify" script on LT 2013, it created the "-MSP-" > "Reboot" folders, but the script itself went in the Root Scripts location (no folder).

The "Reboot script with notification" script, seemed to create the "SNC2" > "Power" folders, but the script seemed to go to my "_System Automation" > "ModernOffice Suite" folder.

I was able to determine this by looking in the mysql database in the "lt_scripts" table, ordering by script id descending. It then showed me the Folder Id that it was located, which I matched up looking in the "scriptfolders" table.

 

Looking forward to trying these out, as it could be really handy. Thanks. :)

Link to post
Share on other sites

Here is a new version exported from our now 2013 setup. I moved it to the "Actions" folder before exporting so hopefully it will wind up there. I also changed the lt version to 1 as I don't know if everyone is on 60.262 yet.

 

The only change to the script itself since i posted it last was to enable a 60 second wait before starting the timer, and you may have to play with that to get it right for your system. Occasionally it was looking in the database and seeing the last checkin time from before it went down and reporting success even though it hadn't come back up yet, due to a checkin happening between when the script started running and before it actually went down. I haven't had any issues with it after making that change though.

 

*edit* removed file, download latest on next page

Edited by Guest
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...