no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:winuptime [2009/11/23 06:13] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Windows Uptime ====== | ||
+ | |||
+ | ^ Author | [[ craig.boyce@rodney.govt.nz | Craig Boyce ]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | Windows, BBWin | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2007-07-16 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | A .vbs script that works with bbwin that you can use to alert when a client exceeds a specified number of days without a restart. | ||
+ | |||
+ | ===== Installation ===== | ||
+ | === Client side === | ||
+ | - Copy the script to the bbwin\ext directory or any sub directory you would prefer. | ||
+ | - Update the bbwin\etc\bbwin.cfg externals section to include the script as per below making sure the path is correct.< | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <load value=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | The script allows the changing of the test column name and uptime duration before alerting by changing the following lines in the script. | ||
+ | |||
+ | | strTestName = " | ||
+ | | strUpTime = " | ||
+ | |||
+ | === Server side === | ||
+ | * None | ||
+ | |||
+ | ===== Source ===== | ||
+ | ==== Uptime.vbs ==== | ||
+ | <hidden onHidden=" | ||
+ | <code vb> | ||
+ | ' | ||
+ | ' NAME: Uptime.vbs | ||
+ | ' COMMENT: Check Uptime of server and report if greater than 30 days | ||
+ | ' AUTHOR: Craig Boyce, Rodney District Council | ||
+ | ' EMAIL: craig.boyce@rodney.govt.nz | ||
+ | ' DATE : 30/10/2006 | ||
+ | ' VERSION : 2.00 | ||
+ | ' | ||
+ | |||
+ | On Error Resume Next | ||
+ | |||
+ | Dim objShell, objWMIService, | ||
+ | Dim ServerName, strTestName, | ||
+ | Dim logmessage, logfile, fso, f | ||
+ | |||
+ | ' Set Variables | ||
+ | |||
+ | Set objShell = WScript.CreateObject(" | ||
+ | Set WSHNetwork = WScript.CreateObject(" | ||
+ | |||
+ | ServerName = objShell.ExpandEnvironmentStrings(" | ||
+ | |||
+ | strTestName = " | ||
+ | strUpTime = 30 ' Change this to the length of time required before alerting a reboot is required. | ||
+ | |||
+ | strAlarmState = " | ||
+ | strOutput | ||
+ | |||
+ | ' Check to see If used with BBWin or Big Brother client and set extPath. | ||
+ | extPath = objShell.RegRead(" | ||
+ | If extPath = "" | ||
+ | extPath = objShell.RegRead(" | ||
+ | End If | ||
+ | |||
+ | ' ======================================== | ||
+ | ' Main Code Starts Here | ||
+ | |||
+ | strComputer = " | ||
+ | |||
+ | On Error Resume Next | ||
+ | Set objWMIService = GetObject(" | ||
+ | |||
+ | If Err.Number = 0 Then | ||
+ | On Error Goto 0 | ||
+ | | ||
+ | Set colObjects = objWMIService.ExecQuery(strQuery) | ||
+ | |||
+ | |||
+ | For Each objWmiObject In colObjects | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | | ||
+ | | ||
+ | ' | ||
+ | | ||
+ | | ||
+ | If CInt(Left(sUptime, | ||
+ | strOutput = strOutput & " | ||
+ | strAlarmState = " | ||
+ | Else | ||
+ | strOutput = strOutput & " | ||
+ | strAlarmState = " | ||
+ | End If | ||
+ | |||
+ | End If | ||
+ | |||
+ | ' Write the file for BB | ||
+ | WriteFile extPath, strTestName, | ||
+ | |||
+ | ' | ||
+ | ' FUNCTIONS and SUBS start here | ||
+ | |||
+ | ' This SUB is used for outputting the file to the external' | ||
+ | |||
+ | SUB WriteFile(strExtPath, | ||
+ | Set fso = CreateObject(" | ||
+ | strOutput = strAlarmState & " " & Date & " " & Time & vbcrlf & vbcrlf & strOutput & vbcrlf | ||
+ | Set f = fso.OpenTextFile(strExtPath & " | ||
+ | f.Write strOutput | ||
+ | f.Close | ||
+ | Set fso = Nothing | ||
+ | END Sub | ||
+ | |||
+ | Function ConvertTime(seconds) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | End Function | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | * None | ||
+ | |||
+ | ===== To Do ===== | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2007-07-16** | ||
+ | * Initial release | ||