Can't execute a Nagios plugin wmi for wql

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
akalb
Posts: 2
Joined: Tue Apr 07, 2015 4:25 am

Can't execute a Nagios plugin wmi for wql

Post 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
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

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

Post by tgriep »

Could you post how you ran the check and the error message you are receiving?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
akalb
Posts: 2
Joined: Tue Apr 07, 2015 4:25 am

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

Post 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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

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

Post by tgriep »

I guess I am confused. Can you give us some detail on what you want to check for?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked