Page 1 of 1

Can't execute a Nagios plugin wmi for wql

Posted: Tue Apr 07, 2015 4:35 am
by akalb
i want to execute a wmi query passing only 2 parameter. For example please take a look at my vbs script below. In this example I want pass the first sql query parameter ("Select * from Win32_ComputerSystem") and the second parameter ("UserName"). I try it using the standard plugin check_wmi_plus.pl but it doesnt' works. Maybe I have to use other solutions. Please help me as soon as possible. Thanks a lot. Bye, Kalibert

' -----------------------------------------------'
' Sample VBScript to discover which user is logged on
' -----------------------------------------------'
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer

strComputer = "MyPcName"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
Wscript.Echo objComputer.UserName
Next

Re: Can't execute a Nagios plugin wmi for wql

Posted: Tue Apr 07, 2015 2:31 pm
by tgriep
Could you post how you ran the check and the error message you are receiving?

Re: Can't execute a Nagios plugin wmi for wql

Posted: Tue Apr 07, 2015 3:33 pm
by lmiltchev
I tried the following check and it worked:

Code: Select all

./check_wmi_plus.pl -H <client ip> -u <username> -p <password> -m checkusers -s count -a "name like '%lmiltchev%'"
OK - Number of Users=1 - User information shown on next line is: Name(FullName) |'Number of Users'=1;
 lmiltchev()

./check_wmi_plus.pl -H <client ip> -u <username> -p <password> -m checkusers -s count -a "name like '%fakeuser%'"
WMI Query returned no data. The item you were looking for may NOT exist or the software that creates the WMI Class may not be running, or all data has been excluded.

Re: Can't execute a Nagios plugin wmi for wql

Posted: Wed Apr 08, 2015 7:50 am
by akalb
sorry I wish use a function like this
function GetResult(wmiClass,wmiField:string):string
SELECT wmiField FROM wmiClass

and next call this function passing myQuery for example GetResult(Win32_ComputerSystem,TotalPhysicalMemory) to obtain some value but I dont' undertand how can I do.

Re: Can't execute a Nagios plugin wmi for wql

Posted: Wed Apr 08, 2015 1:46 pm
by tgriep
I guess I am confused. Can you give us some detail on what you want to check for?