View previous topic :: View next topic |
Author |
Message |
KHeitz
Joined: 27 Jan 2011 Posts: 14
|
Posted: Thu Jan 27, 2011 8:21 am Post subject: Test Windows Updates |
|
|
Hi,
We use Host Monitor 8.82.
Is there the possibility of a test to check the Windows Updates?
The test will show the number of critical Updates from the Microsoft site, have not yet been installed.
Thank you for your help |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Jan 27, 2011 10:15 am Post subject: Test Windows Updates |
|
|
You may use Shell Script test method and custom made script.
E.g. script may look like the following:
'============================================================================
Option Explicit
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
dim updateSession, updateSearcher, searchResult
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
if cnt>0 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & " critical updates found!"
else
WScript.StdOut.Write statusOk 'No new critical updates found
End If
'============================================================================
'Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
'============================================================================
Please note: Script execution may take much time. You should set higher Timeout for script execution. |
|
Back to top |
|
|
KHeitz
Joined: 27 Jan 2011 Posts: 14
|
Posted: Thu Jan 27, 2011 11:01 am Post subject: |
|
|
Hi, many thanks for the quick response.
how do I now install the script exactly?
the script must be stored on the server, I would like to monitor?
Or copy to my host monitor server?
Do I need a new test script?
there must be the only path to the specified script file, or more parameters so that the test works
Thank you for your help |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Jan 27, 2011 11:15 am Post subject: Test Windows Updates |
|
|
Quote: | how do I now install the script exactly?
the script must be stored on the server, I would like to monitor?
Or copy to my host monitor server? |
This script is designed for ShellScript test method :http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#chkShell
You should create new ShellScript test (menu Test->New->Shell Script Test -> Script Manager)
Script Manager is used to store and test scripts.
Please check the manual or visit our web site for more information:
http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#shellmng
Quote: | Do I need a new test script? |
Sure, see above.
Quote: | here must be the only path to the specified script file, or more parameters so that the test works |
This script does not require any parameters.
You should use Start cmd in Script Manager like: cmd /c cscript /B /E:VBScript %Script% %Params% |
|
Back to top |
|
|
KHeitz
Joined: 27 Jan 2011 Posts: 14
|
Posted: Mon Jan 31, 2011 2:31 pm Post subject: |
|
|
Hi,
thanks for the helpful response.
I have the script now has the script manager added with the parameters.
If I now lets try the most popular script I get the following error message.
Agent error: no Response from agent within specified timeout.
time out is second to 600.
Thank you for your help |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12800 Location: USA
|
Posted: Mon Jan 31, 2011 2:50 pm Post subject: |
|
|
Have you tried to start script on the same system from command line?
Regards
Alex |
|
Back to top |
|
|
KHeitz
Joined: 27 Jan 2011 Posts: 14
|
Posted: Mon Jan 31, 2011 3:42 pm Post subject: |
|
|
Hi,
The test wokrs now fine.
One more question for this test:
How can I make the following query?
0 updates => display "No important windows updates"
1 update => display "one important windowns Update
more then one => display "xx important windows updates available "
Because in the German language, there are several variations of the word important
1 = wichtiges
more then one = wichtige
Thank you for your help |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12800 Location: USA
|
Posted: Mon Jan 31, 2011 5:01 pm Post subject: |
|
|
Quote: | How can I make the following query?
0 updates => display "No important windows updates"
1 update => display "one important windowns Update
more then one => display "xx important windows updates available " |
You may change script in any way you want
E.g. Code: |
if cnt>1 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & "text1"
elseif cnt=1 then
WScript.StdOut.Write statusBad & searchResult.Updates.Count & "text2"
else
WScript.StdOut.Write statusOk "text3"
End If |
Regards
Alex |
|
Back to top |
|
|
KHeitz
Joined: 27 Jan 2011 Posts: 14
|
Posted: Tue Feb 01, 2011 3:53 am Post subject: |
|
|
hi,
many thanks for the helpful response.
I knew the parameters elseif not.
At the momment I have the problem when ther is a server with no critical updates I always get the message:
error: script returns no results
But I can not find the error.
Any idea where I assumed something wrong?
My script now looks like this.
-------------------------------------------------------------------------------------
Option Explicit
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
dim updateSession, updateSearcher, searchResult
dim objInstallationBehavior
dim i, cnt
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If
-------------------------------------------------------------------------------------
Thank you for your help |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Tue Feb 01, 2011 9:13 am Post subject: |
|
|
ShellScript returns "error: script returns no results" error when there is an error in script.
I think you missed If statement here:
If cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If |
|
Back to top |
|
|
xcentric
Joined: 23 Oct 2010 Posts: 176
|
Posted: Sun Feb 06, 2011 4:13 pm Post subject: |
|
|
THis is a great addition to my shell scripts. Thank you.
I was wondering if you have one agent in a network with multiple servers, how do you specify the server name in each test you want to create?
Ultimately you would want one update test per server. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon Feb 07, 2011 9:48 am Post subject: |
|
|
I have modified script. Now it should retrieve updates count from another system.
Script can accept one parameter - name (or IP) of remote machine.
Code: | Option Explicit
On Error Resume Next
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
dim updateSession, updateSearcher, searchResult, objArgs
dim objInstallationBehavior
dim i, cnt
Set objArgs = WScript.Arguments
if objArgs.count = 0 then
Set updateSession = CreateObject("Microsoft.Update.Session")
else
Set updateSession = CreateObject("Microsoft.Update.Session",objArgs(0))
end if
if Err.Number <> 0 then
WScript.StdOut.Write statusUnknown & Err.Description
WScript.Quit
end if
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
cnt = 0
FOR i = 0 to searchResult.Updates.Count-1
Set objInstallationBehavior = searchResult.Updates.Item(i).InstallationBehavior
IF objInstallationBehavior.Impact=2 then
cnt = cnt+1 'high impact updates
ELSE
'WScript.StdOut.WriteLine searchResult.Updates.Item(i).Title & ", Impact: " & objInstallationBehavior.Impact
END IF
NEXT
If cnt>1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtiges Windows-Updates steht zur Installation bereit"
elseif cnt=1 then
WScript.StdOut.Write statusOk & searchResult.Updates.Count & " wichtige Windows-Update stehen zur Installation bereit"
else
WScript.StdOut.Write statusbad & " Keine wichtigen Windows-Updates stehen zur Instalaltion bereit "
End If |
Please note: user account, under wich script is started, should have administrator privileges on remote machine. |
|
Back to top |
|
|
MichaelF
Joined: 15 Feb 2011 Posts: 5
|
Posted: Tue Feb 15, 2011 3:16 am Post subject: |
|
|
Hi,
this is my first test in hostmoni with shell script.
I have Hostmoni Version 8.68.
In the Script Manager i create a new script an copied the Script.
Now what do i have to enter under Hint and Prams?
On start cmd i enter cmd /c cscript /B /C:windowsupdate.vbs %Script% %Params%
When ein Test the Script Hostmoni says Error: unable to start script.
Can you help me? |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12800 Location: USA
|
Posted: Tue Feb 15, 2011 12:56 pm Post subject: |
|
|
Quote: | cmd /c cscript /B /C:windowsupdate.vbs %Script% %Params%
|
This does not look correctly.
1) I think cscript utility does not support such /C parameter
2) If you stored script in external file (windowsupdate.vbs) then you don't need to use %Script% variable. If you stored script using Script Manager then you need to use %Script% variable but then windowsupdate.vbs has no sense.
As you may see VB script example uses the following command
cmd /c cscript /B /E:VBScript %Script% %Params%
Why don't you use the same command?
Quote: | Now what do i have to enter under Hint and Prams? |
Quote fro the manual
=================
Hint
List of script parameters (if any). This parameter is optional however we recommend to use it. It will be displayed in the Test Properties dialog as a reminder - which parameters should be specified for the script. E.g. "Process: %CPU usage (average)" script has 2 parameters: <process_name> and <maximum threshold (%)>
=================
So you may use this field for any information useful for you.
Parameter?
As Tom said script can accept one parameter - name (or IP) of remote machine.
Regards
Alex |
|
Back to top |
|
|
xcentric
Joined: 23 Oct 2010 Posts: 176
|
Posted: Tue Feb 15, 2011 4:47 pm Post subject: |
|
|
I am having a tough time with a modification. On windows 2003 the script provided here in this forum will check for "High Priority" and "Software, Optional" updates. I would like it to check only for "High Priority".
I found the following script on the internet that checks "High Priority" updates only but I am having difficulty merging the two scripts together to make it work.
Code: |
' check this category for 'High Priority' updates
category = "UpdateClassification"
highpriority = ",Security Updates,Update Rollups,Critical Updates,"
' create instance of update.searcher (offline)
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
objSearcher.Online = 1
' find and fetch collection of updates
Set objResults = objSearcher.Search("Type='Software' and IsInstalled=0")
Set colUpdates = objResults.Updates
count = 0
titles = ""
For i = 0 to colUpdates.Count - 1
' check categories
Set colCategories = colUpdates.Item(i).Categories
For c = 0 to colCategories.Count - 1
If colCategories.item(c).Type = category _
And InStr(highPriority, "," & colCategories.item(c).Name & ",") > 0 Then
count = count + 1
titles = titles & vbCRLF & colUpdates.Item(i).Title
End If
Next
Next
If count > 0 Then
Wscript.Echo count & " pending updates:" & titles
Wscript.Quit 2
Else
Wscript.Echo "No pending updates"
Wscript.Quit 0
End If
|
I believe I am close to getting this to work but I am stuck so far woth this.
Code: |
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
' check this category for 'High Priority' updates
category = "UpdateClassification"
highpriority = ",Security Updates,Update Rollups,Critical Updates,"
' create instance of update.searcher (offline)
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
objSearcher.Online = 1
' find and fetch collection of updates
Set objResults = objSearcher.Search("Type='Software' and IsInstalled=0")
Set colUpdates = objResults.Updates
count = 0
titles = ""
For i = 0 to colUpdates.Count - 1
' check categories
Set colCategories = colUpdates.Item(i).Categories
For c = 0 to colCategories.Count - 1
If colCategories.item(c).Type = category _
And InStr(highPriority, "," & colCategories.item(c).Name & ",") > 0 Then
count = count + 1
titles = titles & vbCRLF & colUpdates.Item(i).Title
End If
Next
Next
if count > 0 then
WScript.StdOut.Write statusBad & colupdates.Updates.Count & " critical updates found!"
else
WScript.StdOut.Write statusOk 'No new critical updates found
End If
'If count > 0 Then
'Wscript.Echo count & " pending updates:" & titles
'Wscript.Quit 2
'Else
'Wscript.Echo "No pending updates"
'Wscript.Quit 0
'End If
| [/quote] |
|
Back to top |
|
|
|