Primary Navigation
Advanced device maintenance mode
| Description: | Advanced device maintenance mode - Suspend device monitoring with automatic release after ended duration (drop down with multiple choices) - Resume device monitoring to manually end advanced mainteance mode - Edit comments set on a device in advanced maintenance mode - View comments set on a device on maintenance mode Functionality listed in the features.doc document How to implement is listed in the Setup.doc document Prereq: - Only works on single devices - Only works on the console - Internet explorer must be installed - Sysadmin access to the database - Local admin access to the file system If you decide to use this set of scripts, please keep me as the author. Thanks & Enjoy, Daniel |
| Language: | VB Script/JScript |
- 1,585 views
- $obj.VersionIndex versions
- 22 replies
- 4 followers
Script, Script Library, Tools, User Interface, v14.4, WhatsUp Gold, Windows Server
- Post Date:
- August 10, 2011
- Posted By:
- Daniel Badstue
About this forum
- 21,991 views
- 19 topics
- 4 followers
Page Options
22 Replies
By the way, the script only manipulates the Device attribute section and updates the device table, so it should be version generic. It has been tested on v14.1-v14.4
I have tried your script and think that it is a good improvement of WUG. It improves the maintenance functionality, until IpSwitch improves the maintenance function itself (I hope that this will happen soon).
Daniel,
Is there a way to run your script against a TXT for CSV?
We're an ISP that runs maintenance on 10 to 20 clients a day, I would love to have a file that lists all the clients and runs your script to place them into maintenance.
Tested on 15.0.1 - Working fine.
Had to create a SQL account as we use our AD accouts to log onto WUG server, and only Administrator gor sysadmin rights.
Thanks for having your script so structured/commented, made it easy finding out how to change logonaccount :)
Edit: seems like there is a problem taking devices out of maintenance mode. The icon gets light green ( Up less than 5 mins) and "force this device into maintenance mode now" box gets unchecked, but it's still in maintenance mode according to device group its under and device status on website. Lookng into it
Edit 2: Found javascript that sends an "change event" to the device, getting WUG to properly recognize state change. I've changed the javascript into VBscript to fit in your script, but it doesnt work so well for me outside of WUG (Can use script in active monitor for testing, but running it through IE in your script causes "ActiveX component can't create object". The object im trying to create is "coreasp.eventhelper". Still working on a solution
Edit 3: Solution found! Now its working 100% for us :) Will update solution soon as I've cleaned up alittle.
Michael: Yes, it's possible. You can subtract the "subs" in the script which you need, load your file into an array and loop though the array. I'm not 100% sure how you do that, but with some trial and error you should get it working :)
//Robin
Hi Robin,
Sorry for the slow response, i've been off on paternity leave for 2½ months :-)
Let me know if you still need som assistance
Cheers
Daniel
Michael: Yes it.s possible and not too hard to do. I will see if i can find some time to add the feature.
Hello Daniel!
I wouldnt mind having the possibility to add a server into maintenence mode based on a text file... (somewhat similar to michaels request). I've already modified your script to allow a custom start time (I can insert "now" or "yyyy-mm-dd hh:mm")
I dont know if you've had problem with device not properly going into maintenance mode when you run the script, but I had to send a "changevent" to the WUG server to force the change.
How I do it: Script calls for this sub:
Sub ChangeEvent (ByVal deviceID)
iexplore = Chr(34) & "C:\Program Files (x86)\Internet Explorer\iexplore.exe" & Chr(34)
oUserName.run iexplore & "file:///c:/customscripts/Changeevent.html?var1=" & deviceID, 2, true
End Sub
As you can see, it just opens a local html file with a parameter consisting of the deviceID.
The HTML contains a javascript that calls for an asp file in the whatsup folder (didnt know how to use the file, so had to go through HTML to run it in the local iis which was aware of the ASP).
Also, to let the html run script automaticlly (so it could be used in schedule task) I had to weaken the security on scripts from local html files. This is not good tho.. So if your able to change the javascript code into VBscript and use this code below, it would be more amazing:
"var oEventHelper = new ActiveXObject("CoreAsp.EventHelper");
oEventHelper.SendChangeEvent(2, deviceID, 1);"
Content of the HTML:
<html>
<!-- saved from url=(0016)http://localhost -->
<body>
Body text;
<SCRIPT type="text/javascript">
if(window.name!='prime'){
window.name='prime';
window.open(window.location.href, 'prime')
}
var params = {};
if (location.search) {
var parts = location.search.substring(1).split('&');
for (var i = 0; i < parts.length; i++) {
var nv = parts[i].split('=');
if (!nv[0]) continue;
params[nv[0]] = nv[1] || true;
}
}
var var1 = params.var1;
document.write("javascript<br><br>");
document.write(var1);
var oEventHelper = new ActiveXObject("CoreAsp.EventHelper");
oEventHelper.SendChangeEvent(2, var1, 1);
function Func1()
{
window.close();
}
function Func1Delay()
{
setTimeout("Func1()", 3000);
}
Func1Delay();
</SCRIPT>
</body>
</html>
Hi Robin,
I don't have the time to fully implement your requested feature yet, but i had a quick look at your jscript code for asp.
jscript:
"var oEventHelper = new ActiveXObject("CoreAsp.EventHelper");
oEventHelper.SendChangeEvent(2, deviceID, 1);"
Here's the vbscript version:
set oEventHelper = Createobject("CoreAsp.EventHelper")
oEventHelper.SendChangeEvent(2, deviceID, 1)
I havent really had any issues with this as most of my work is from the console . There's no update issues here as the console looks directly in the database. But to be honest i didnt actaully test it with the webinterface
the CoreASP object is a ddl located in the WhatsUp installation directory, so you should be able to send the change event without having to do it through a webbrowser.
Hmm.. I'm using the console mostly aswell, but when using the script to set the device into maintenenace mode, it doesn't properly gets changed (device group does not update etc). If I manually do a change (attribute, monitor or anything else) on the device it gets the changed state.
Changed the part im my script to use the VB version:
Sub ChangeEvent (ByVal deviceID)
set oEventHelper = Createobject("CoreAsp.EventHelper")
oEventHelper.SendChangeEvent(2, deviceID, 1)
End Sub
Error message: Cannot use parentheses when calling a Sub
Line 370 (this line: oEventHelper.SendChangeEvent(2, deviceID, 1) )
Char 46 (the ","?)
How I call the sub:
ChangeEvent getDeviceID(displayname)
I hate that error message. I've gotten it before and I dont really know it/scripting well enough to understand it :(
Also: Yeah, the coreasp file is in the install folder of whatsup gold. I toguht it should be able to use it without browser aswell, but I havent gotten it to weok :(
This sub works when it was like this. calling it the same way:
Sub ChangeEvent (ByVal deviceID)
iexplore = Chr(34) & "C:\Program Files (x86)\Internet Explorer\iexplore.exe" & Chr(34)
oUserName.run iexplore & "file:///c:/customscripts/Changeevent.html?var1=" & deviceID, 2, true
End Sub
getDeviceID is a fuction right? if so then the way you call the sub is ok.
But could try chaning the sub to this
Sub ChangeEvent (ByVal deviceID)
set oEventHelper = Createobject("CoreAsp.EventHelper")
oEventHelper.SendChangeEvent 2, deviceID, 1
End Sub
and yes the IE way is correct and works well, but alot of "extra" work for the script each time its executed. script optimization hehe and yes there's loads of placed these scripts can be optimized, but my time to rewrite scripts are a bit limited
Allrighty. I changed the sub to this:
Sub ChangeEvent (ByVal deviceID)
set oEventHelper = Createobject("CoreAsp.EventHelper")
oEventHelper.SendChangeEvent "2", deviceID, "1"
End Sub
now I got the error message that stopped me and made me go browser:
ActiveX component can't create object:
'CoreAsp.eEventHelper'
Code: 800A01AD
Line 369: set oEventHelper = Createobject("CoreAsp.EventHelper")
Alright figured out whats wrong (guessign you're on a 64bit OS)...
It needs to be executed by the 64bit version of either cscript or vscript...
Try running the script from c:\windows\sysWOW64\<wscript.exe or cscript.exe> <path to script>
This works on my server (win2k8r2 64bit)
Just put the small sub you created into the original script and call it everytime you update a device in the database (or once before you exit the script).
Then setup the script to be executed with the 64bit version of wscript.exe, you must edit the attached device types as follows(Only if its attached as a menu item):
Display Name: Whatever you want to call it (i call it Advanced maintenance)
"C:\Windows\SysWOW64\wscript.exe"
Arguments:
"<DriveLetter>:\<Path>\<scriptname>.vbs" %Device.DisplayName
That seemed to really do the trick!
Saves me from opening all scripts from running without any restrictions from HTML files on our server.
How did you know/find out it had to be done in the 64bit version of wscript?
I found an article about registering .dll's, and with regasm, but CoreASP is not a .net assembly, but the link was executing with the 64 bit version of cscript, so as our previos version of WUG was a 32bit version and all my menu items are executed as .vbs directly, i just wondered. :-)
But its a really good little sub that im going to incorporate into ALL my scripts here as it forces the update, so thanks alot for opening my eyes :-D
Nice find/thinking! It works great with my custom start time inputbox, using the scheduled task vbscript to set into maintenance mode.
If you got any other good scripts around I'd be happy if you shared some.. :)
Uhh where to start :-)
Got a few background scripts running inventory and update jobs like:
- Server inventory (for HP servers) all kinds of server related info attached to all physical servers as attributes.
- Hyper-V environment inventory script that attaches/updates a Host owner and cluster owner on all virtual devices every 10 mins. This is then used in a set of dynamic views that gives us a close to "live" view of our virtual environment. Its also excellent for making group specific reports for specific hosts and/or specific clusters
- Update devices status script which runs in the backgroup and checks for status updates of incidents/cases attached to devices from our service management system . it is used in conjunction with a menu item script that creates incidents/cases (with all info from down monitors etc) directly in our service management system (Cloud based service-now) using SOAP protocols and vbscript, and attaching the incident/case no. to the device, who logged it, when it was logged, a history of logged incidents/cases. This is also used to create specific views and reports for our main monitoring page so we have a view of devices with "software monitors down", "hardware monitors down" , "completely down" and "devices with attached incidents". Gives a really good overview for our monitoring personal, so we know what to focus on.
For menu items I also have a script that checks HP server warranty instantly (requires the HP server inventory script).
Server restart/reboots, Generic service restarts scripts like IISadmin, backup agents, inventory agents etc.
Direct links to ILO interfaces and so on...
I keep adding new "features" when i get annoyed with missing functionality :-)
Sounds like good scripts :) Although most of em are mostly stuff we have in another system (inventory/CRM system) or specific to your work envirement.
WUG is good in that way it allows for such customization to work/integrate with other applications/systems in a way that fits us. Although it requires custom scripting etc, it still allows it :)
Thanks for listing em scripts!
I'd list some I'd have if I had any.Its the drive-independent threshhold disk monitor posted under active monitor scripts I got.. Else we just got different stuff specific to specific servers or integration into our CRM system..
Would you like to comment?
You must be a member. Sign In if you are already a member.