Breaking the results in status information

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

Breaking the results in status information

Post by rifelixd »

https://support.nagios.com/forum/viewto ... 07#p237307

Hi @mcapra, @mcapra,
I am following up from the previous thread. The link is attached above.
Is there a way I can do for a more presentable display on the received results of my software version.

As of now it appears in a single line.

Code: Select all

Name= Service Pack 2 for SQL Server 2008 R2 (KB2630458) (64-bit), Version= 10.52.4000.0, Publisher= Microsoft Corporation Name= GDR 4042 for SQL Server 2008 R2 (KB3045313) (64-bit), Version= 10.52.4042.0, Publisher= Microsoft Corporation Name= System Center Endpoint Protection, Version= 4.10.209.0, Publisher= Microsoft Corporation Name= Microsoft SQL Server 2008 R2 (64-bit), Version= , Publisher= Microsoft Corporation Name= Microsoft SQL Server 2008 R2 (64-bit), Version= , Publisher= Microsoft Corporation
Is that possible me to display as below?

Code: Select all

Name= Service Pack 2 for SQL Server 2008 R2 (KB2630458) (64-bit), Version= 10.52.4000.0, Publisher= Microsoft Corporation 
Name= GDR 4042 for SQL Server 2008 R2 (KB3045313) (64-bit), Version= 10.52.4042.0, Publisher= Microsoft Corporation 
Name= System Center Endpoint Protection, Version= 4.10.209.0, Publisher= Microsoft Corporation 
Name= Microsoft SQL Server 2008 R2 (64-bit), Version= , Publisher= Microsoft Corporation 
Name= Microsoft SQL Server 2008 R2 (64-bit), Version= , Publisher= Microsoft Corporation
I am reattaching the initial working vb script from the previous thread.

Code: Select all

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

Dim myString
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 & objSoftware.Vendor
myString = myString & vbCr
Next
WScript.Echo myString
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Breaking the results in status information

Post by mcapra »

You could try using vbCrLf instead of vbCr:

Code: Select all

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate}!\\" _
& strComputer & "\root\cimv2")
objWMIService.Security_.ImpersonationLevel = 3
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

Dim myString
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 & objSoftware.Vendor
myString = myString & vbCrLf
Next
WScript.Echo myString
But that won't guarantee a multi-line output in the Nagios Core web interface. There's 3 layers of "difference" that need to be dealt with: VBScript, NSClient++, and Nagios Core's web interface. Hopefully a different VBScript new-line is all that is required.
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Breaking the results in status information

Post by kyang »

Thanks @mcapra!
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Breaking the results in status information

Post by rifelixd »

mcapra wrote:You could try using vbCrLf instead of vbCr
Hi @mcapra,
I missed to mention that I did tried vbCrLf previously but end up it shows a single line entry i.e as below:

Code: Select all

Name= Service Pack 2 for SQL Server 2008 R2 (KB2630458) (64-bit), Version= 10.52.4000.0, Publisher= Microsoft Corporation 
All information shows only if I use vbCr. :(
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Breaking the results in status information

Post by dwhitfield »

Did you try vbNewLine? What version of VB is this?
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Breaking the results in status information

Post by rifelixd »

dwhitfield wrote:Did you try vbNewLine? What version of VB is this?
Hi @dwhitfield,

I have tried vbCrLf as well vbNewLine but the results shows a single string with a single entry of Name, Version and Publisher. When I apply run this vb from my cmd, the results shows fine but on Nagios, only vbCr pulls the entire information. The other 2 commands displays a single entry only.

I am not sure which version is this. The code is attached at the top of this thread.
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Breaking the results in status information

Post by rifelixd »

Hi Experts,

I am not sure if this should be reason for not allowing full text to displayed IF break command like vbCr or vbNewLine is applied in my script.
https://assets.nagios.com/downloads/nag ... viceoutput

I am seeing macros to be applied. If yes, could you please teach me how this can be applied in my environment?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Breaking the results in status information

Post by npolovenko »

@rifelixd, Please try to run the following version. I added <br> sign to the end of each loop. And since Nagios is using PHP for the front end, there's a chance that it might render the "special tag".

Code: Select all

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate}!\\" _
& strComputer & "\root\cimv2")
objWMIService.Security_.ImpersonationLevel = 3
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

Dim myString
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 & objSoftware.Vendor
myString = myString & vbCr
myString = myString & "\n" 
Next
WScript.Echo myString
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rifelixd
Posts: 35
Joined: Mon Nov 06, 2017 12:50 pm

Re: Breaking the results in status information

Post by rifelixd »

npolovenko wrote:@rifelixd, Please try to run the following version. I added <br> sign to the end of each loop. And since Nagios is using PHP for the front end, there's a chance that it might render the "special tag".
Hi @npolovenko,
Thank you for your suggestion. I have tried as advised but there the results appears same as I use vbCrLf.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Breaking the results in status information

Post by npolovenko »

@rifelixd , I think you're looking at the quick service overview. I'm pretty sure it's limited to one line only. But, if you actually click on the service hyperlink you'll see all lines. The following code worked for us, each entry was on a new line.

Code: Select all

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate}!\\" _
& strComputer & "\root\cimv2")
objWMIService.Security_.ImpersonationLevel = 3
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

Dim myString
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 & objSoftware.Vendor
myString = myString & vbCrLf
Next
WScript.Echo myString
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked