[mrtg] Re: Windows 2000 Uptime
Eric Brander
Eric_Mailing_List at rednarb.com
Thu Dec 4 22:55:30 MET 2003
----- Original Message -----
From: "C Baker" <craigbaker at blueyonder.co.uk>
To: <mrtg at list.ee.ethz.ch>
Sent: Thursday, December 04, 2003 2:41 PM
Subject: [mrtg] Windows 2000 Uptime
I am attempting to graph the uptime of a Win2k Server.
~snip~
My MRTG box is Win2k and I use an external script that uses the Uptime
program supplied in one of the windows resource kits, and a .bat file as
well to help out. If you are using anything other than windows, then
this won't work for you of course.
Here's my script (Warning, its VBscript!):
On Error Resume Next
Const ForReading = 1
Set objArgs = WScript.Arguments
Server = UCase(objArgs(0))
'Wscript.Echo Server
Set WshShell = WScript.CreateObject("WScript.Shell")
return = WshShell.Run("\mrtg\bin\uptime\up.bat " & Server, 1, True)
FullText = GetText(Server)
MyArray0 = Split(FullText, ": ")
TextUptime = MyArray0(1)
MyArray1 = Split(FullText, " ")
days = MyArray1(5)
hours = MyArray1(7)
minutes = MyArray1(9)
seconds = MyArray1(11)
TTSeconds = (days * 86400) + (hours * 3600) + (minutes * 60) + seconds
TTMinutes = (days * 1440) + (hours * 60) + minutes
wscript.echo TTMinutes
wscript.echo TTMinutes
wscript.echo TextUptime
wscript.echo Server
Function GetText(Server)
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("\mrtg\bin\uptime\" & Server & ".tmp",
ForReading)
GetText = MyFile.ReadLine
End Function
Here's up.bat:
/mrtg/bin/uptime/uptime %1 > /mrtg/bin/uptime/%1.tmp
Here's my CFG:
### Global Config Options
HtmlDir: \mrtg\www
ImageDir: \mrtg\images
IconDir: \mrtg\images
LogDir: \mrtg\log
ThreshDir: \mrtg\thresh
### Global Defaults
Background[_]: #FFFFE8
ThreshProgI[_]: \mrtg\bin\NotifyPingError.Bat
ThreshProgOKI[_]: \mrtg\bin\NotifyPingOK.Bat
ThreshProgO[_]: \mrtg\bin\NotifyPingError.Bat
ThreshProgOKO[_]: \mrtg\bin\NotifyPingOK.Bat
########################################
Directory[_]: Uptime
Options[_]: growright, nolegend, nobanner, gauge, noo, unknaszero
MaxBytes[_]: 262974
AbsMax[_]: 1000000000
YLegend[_]: Minutes
LegendI[_]: Minutes
LegendO[_]:
ShortLegend[_]: Minutes
Unscaled[_]: DWMY
kMG[_]:
Target[^]: `cscript //nologo \mrtg\bin\Uptime\ServerUpTime.vbs
Title[^]: Uptime for
PageTop[^]: <H1>Uptime for
########################################
Target[Server1]: Server1`
Title[Server1]: Server1
PageTop[Server1]: Server1</H1>
Target[Server2]: Server2`
Title[Server2]: Server2
PageTop[Server2]: Server2</H1>
Target[Server3]: Server3`
Title[Server3]: Server3
PageTop[Server3]: Server3</H1>
...etc...
Its a hack but it works!
Eric Brander
Eric_Mailing_List at rednarb dot com
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list