Nagios captures only a single line output from VB script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Nagios captures only a single line output from VB script

Post by rifelixd »

[/settings/NSCA/client/targets/default]
payload length = 4096

@mcapra, Thank you for sharing on payload length. Now that I have added 4096 on the client side, I am getting all listed software versions.

@npolovenko, I still have an issue :(. This seems to be pulling the 32-bit applications only. Is there something I am missing to retrieve the 64-bit applications as well ?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Nagios captures only a single line output from VB script

Post by npolovenko »

@rifelixd, Glad I could help! Keep us updated.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios captures only a single line output from VB script

Post by mcapra »

I'd double check the namespace. I'm not 100% sure if Win32_Product would include 64bit apps by default. This TechNet article has some logic in it regarding the OS architecture, unsure of it's related and can't test since I'm on mobile

https://gallery.technet.microsoft.com/s ... d-70d0c0f4
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Nagios captures only a single line output from VB script

Post by kyang »

Thanks @mcapra,

@rifelixd, Let us know how it goes!
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Nagios captures only a single line output from VB script

Post by rifelixd »

@npolovenko @mcapra,

I have finally managed to pull the the required software. If I am using WMI class, some software were missing. I have then tried to pull from registry but then some software which being pulled from WMI are not listed. Therefore I have just combined both and managed to pull all needed software versions. I am attaching the script here.

Code: Select all

const HKEY_LOCAL_MACHINE = &H80000002
Dim strComputer, strKeyPath
Dim Name, Version, Publisher
Dim objReg, strSubkey, arrSubkeys
Dim myString

strComputer = "."

' WMI class search for installed programs
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product where Vendor <> 'Microsoft Corporation'")

' Registry key path of Control panel items for installed programs
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 

Set objReg=GetObject( _ 
    "winmgmts:{impersonationLevel=impersonate}!\\" & _
   strComputer & "\root\default:StdRegProv")

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys 

'Enumerate registry keys 
For Each strSubkey In arrSubkeys 
	objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "DisplayName" , Name
	If Name <> "" Then 
		objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "DisplayVersion" , Version
		objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "Publisher" , Publisher
		myString = myString & "Name= " 
		myString = myString & Name 
		myString = myString & ", Version= " 
		myString = myString & Version 
		myString = myString & ", Publisher= " 
		myString = myString & Publisher
		myString = myString & vbCr
	End If 
Next

For Each objSoftware in colSoftware
myString = myString & "Name= " 
myString = myString & objSoftware.Name 
myString = myString & ", Version= " 
myString = myString & objSoftware.Version
myString = myString & ", Vendor= " 
myString = myString & objSoftware.Vendor
myString = myString & vbCr
Next
WScript.Echo myString
Thank you so much to both of you.
kyang

Re: Nagios captures only a single line output from VB script

Post by kyang »

Sounds good! Thanks for sharing! I'll be closing this thread.

If you have any more questions, feel free to create another thread.

Thanks for using the Nagios Support Forum!
Locked