[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Windows update check monitor added to the Shire
- To: "'hobbit (at) hswn.dk'" <hobbit (at) hswn.dk>
- Subject: RE: Windows update check monitor added to the Shire
- From: "Storer, Raymond" <storerr (at) nibco.com>
- Date: Fri, 26 Jun 2009 12:39:51 -0400
- Accept-language: en-US
- Acceptlanguage: en-US
- References: <4A402BA0.1000802 (at) doublesparks.net> <4A42C7E9.7050205 (at) doublesparks.net> <BAY138-W2568A108E29C32B23619D39F340 (at) phx.gbl> <997a524e0906242116x51d5c01dv505af407a306c909 (at) mail.gmail.com> <BAY138-W141D730F864B0995D5B2BA9F340 (at) phx.gbl> <4A43AC27.5060904 (at) doublesparks.net> <BBA15439DC467648BBAB71E6BA4D990038F2BE8B5F (at) MERCMBX12.na.sas.com> <961092e10906251020v3da3b977t558301572970129c (at) mail.gmail.com> <BBA15439DC467648BBAB71E6BA4D990038F2BE8BD6 (at) MERCMBX12.na.sas.com> <961092e10906251040i349d99e4rb1ee045236e11f97 (at) mail.gmail.com> <997a524e0906251059m58a928b1ybe32df5e565de7c7 (at) mail.gmail.com> <9F4B8A70C3E2D142AF209DB53DBC1D5107DFCB1F (at) MUN2WSP05011.global.pioneer.com>
- Thread-index: Acn1vw2ilApcgvL5RSWvM+uQDshgJwAc1NIgABJDGSA=
- Thread-topic: Windows update check monitor added to the Shire
Here is a vbscript I use to test for needed updates. I did not put any checks in for the existence of bbwin. I run my script from a Windows task and so I don't use the file system object to write the file-I just redirect stdout to a file in my bbwin's tmp directory. Feel free to modify as you see fit.
Ray
'code begins here
'Change these to match your environment
Const AlarmRedLevel = 10
Const AlarmYellowLevel = 5
Const AlarmRed = "red"
Const AlarmYellow = "yellow"
Const AlarmGreen = "green"
Dim oSearcher, oResults, oUpdates, oShell
Set oSearcher = CreateObject("Microsoft.Update.Searcher")
Set oResults = oSearcher.Search("Type='Software'")
Set oUpdates = oResults.Updates
Set oShell = WScript.CreateObject("WScript.Shell")
Dim strOut, IsInstalled, strKBs, strURL, IsEven, iUpdates, iUpdatesNeeded, strClass, strAlarm, strSvrName
iUpdates = oUpdates.Count
strSvrName = LCase(oShell.ExpandEnvironmentStrings("%COMPUTERNAME%"))
iUpdatesNeeded = 0
For i = 0 to iUpdates - 1
IsInstalled = oUpdates.Item(i).IsInstalled
If (IsInstalled = False) Then
iUpdatesNeeded = iUpdatesNeeded + 1
End If
Next
If (iUpdatesNeeded > AlarmRedLevel) Then
strAlarm = AlarmRed & " " & Date & " " & LCase(Time) & " " & strSvrName & VbCrLf
Else
If (iUpdatesNeeded > AlarmYellowLevel) Then
strAlarm = AlarmYellow & " " & Date & " " & LCase(Time) & " " & strSvrName & VbCrLf
Else
strAlarm = AlarmGreen & " " & Date & " " & LCase(Time) & " " & strSvrName & VbCrLf
End If
End If
WScript.Echo strAlarm & VbCrLf
strOut = "<style type=""text/css"">" & VbCrLf & _
"table.updates { border-width: 3px; border-spacing: 0px; border-style: solid; border-color: black; border-collapse: separate; background-color: white; }" & VbCrLf & _
"table.updates th { background-color: white; }" & VbCrLf & _
"table.updates td.even { border-width: 1px; padding: 3px; border-style: solid; border-color: gray; background-color: #FCF6CF; }" & VbCrLf & _
"table.updates td.odd { border-width: 1px; padding: 3px; border-style: solid; border-color: gray; background-color: #FEFEF2; }" & VbCrLf & _
"</style>" & VbCrLf & _
"<h2>" & UCase(strSvrName) & " Needs [" & CStr(iUpdatesNeeded) & "] Windows Updates</h2>" & VbCrLf & _
"<table class='updates'>" & _
"<th>Title</th>" & _
"<th>Severity</th>" & _
"<th>Description</th>" & _
"<th>Size(bytes)</th>" & _
"<th>Deadline</th>" & _
"<th>URL</th>" & _
"<th>KBs</th>" & _
"</tr>" & VbCrLf
IsEven = True
For i = 0 to iUpdates - 1
IsInstalled = oUpdates.Item(i).IsInstalled
If (IsInstalled = False) Then
strKBs = ""
strURL = oUpdates.Item(i).SupportURL
If (IsEven = True) Then
strClass = "class='even'"
IsEven = False
Else
strClass = "class='odd'"
IsEven = True
End If
strOut = strOut + "<tr><td " & strClass & ">" & oUpdates.Item(i).Title & "</td>" & _
"<td " & strClass & ">" & oUpdates.Item(i).MsrcSeverity & "</td>" & _
"<td " & strClass & ">" & oUpdates.Item(i).Description & "</td>" & _
"<td " & strClass & ">" & oUpdates.Item(i).MaxDownloadSize & "</td>" & _
"<td " & strClass & "> " & oUpdates.Item(i).Deadline & "</td>" & _
"<td " & strClass & "><A href='" & strURL & "' target='_blank'>" & strURL & "</a></td>"
For Each strArticle in oUpdates.Item(i).KBArticleIDs
If (Len(strKBs) > 0) Then
strKBs = strKBs & ", " & strArticle
Else
strKBs = strArticle
End If
Next 'each KB
strOut = strOut & "<td " & strClass & ">" & strKBs & "</td>"
strOut = strOut & "</tr>" & VbCrLf
End If 'Installed?
Next 'each update
strOut = strOut & "</table>" & VbCrLf
WScript.Echo strOut
'Release our resources
Set oShell = Nothing
Set oUpdates = Nothing
Set oResults = Nothing
Set oSearcher = Nothing
From: Lennon, Padraig [mailto:Padraig.Lennon (at) pioneerinvestments.com]
Sent: Friday, June 26, 2009 3:52 AM
To: hobbit (at) hswn.dk
Subject: [hobbit] Windows update check monitor added to the Shire
I've added a quick and dirty monitor that might be of some use to someone here: http://xymonton.trantor.org/doku.php/monitors:winupd
At the moment its very basic in that it only checks for pending reboots required as a result of windows updates applied to a windows client. This has been useful here on site as sometimes updates are applied to production servers but downtime is not alllowed.. This monitor serves as a reminder to reboot to finish applying the updates
If you think you can enhance the script please do. My vb is poor..
Padraig Lennon
________________________________
CONFIDENTIALITY NOTICE: This email and any attachments are for the
exclusive and confidential use of the intended recipient. If you are not
the intended recipient, please do not read, distribute or take action in
reliance upon this message. If you have received this in error, please
notify us immediately by return email and promptly delete this message
and its attachments from your computer system. We do not waive
attorney-client or work product privilege by the transmission of this
message.