NetXMS Support Forum

English Support => General Support => Topic started by: miniseb on January 03, 2011, 01:32:46 PM

Title: script a wmi query
Post by: miniseb on January 03, 2011, 01:32:46 PM
i would like to monitor what is going on in my IIS server in term of memory.

IIS works with different worker process each of them is linked to an application pool. I found on the internet how to query the counter i want with a WMI query.
The problem is that i dont have only one WMI query to get what i want :

         
   select VirtualBytes, PrivateBytes from Win32_PerfFormattedData_PerfProc_Process where IDProcess = XX
      => this query allows to get the virtual bytes and the private bytes
   the problem is i can not identify the process so i need another query to do that
      
   select ProcessId from Win32_Process where commandline like "%myApplicationPoolName%"
      => this query allows to identify the application pool and get the pid
      
As the WMI query does not enable to make a inner join, the only way is to program that in VBScript or in other programming language.
Is it possible with NetXMS launch a script periodically and get the result to trace in a graph ?
or maybe there is a different way to get what i want ?
Title: Re: script a wmi query
Post by: Victor Kirhenshtein on January 03, 2011, 10:22:32 PM
Hi!

You can define new parameters in agent implemented by external script, and then collect these parameters as usual. You can use any external program as parameter handler, and first line of the command's output will be considered as parameter's value. For example, if you have script myscript.vbs and wish to define new parameter AppUsage, you can add the following line to nxagentd.conf:

ExternalParameter = AppUsage:cscript.exe //B //Nologo myscript.vbs

Restart agent, and you will have new parameter AppUsage available for collection.

Best regards,
Victor
Title: Re: script a wmi query
Post by: miniseb on January 27, 2011, 10:08:20 AM
I am struggling to make that working:

I created a vbscript :
   Dim test
   test = 10
   WScript.Echo test

I insert the following lines in nxagentd.conf :
ExternalParameter = MyParameter:c:\windows\system32\cscript.exe //B //Nologo "c:\MyScript\myscript.vbs"

In the data collection, a new item is shown named "MyParameter". I select it so i see MyParameter in my data collection. The value of this data collection never updates.
thanks for your help
miniseb
Title: Re: script a wmi query
Post by: miniseb on February 08, 2011, 03:00:16 PM
hello

any body have an idea?
miniseb
Title: Re: script a wmi query
Post by: Victor Kirhenshtein on February 08, 2011, 10:47:07 PM
Hi!

jsut check it on my machine, and it looks like cscript suppresses output of WScript.Echo in batch mode, so agent cannot get the result. Changing

ExternalParameter = MyParameter:c:\windows\system32\cscript.exe //B //Nologo "c:\MyScript\myscript.vbs"

to

ExternalParameter = MyParameter:c:\windows\system32\cscript.exe //Nologo "c:\MyScript\myscript.vbs"

gives correct result for MyParameter.

Best regards,
Victor
Title: Re: script a wmi query
Post by: miniseb on February 14, 2011, 03:40:55 PM
wow
thanks a milion
it helps me a lot.
miniseb
Title: Re: script a wmi query
Post by: Rabid on March 08, 2011, 09:35:59 PM
I have created a folder on one of my nodes c:\myscripts.  On the node that i want to run this script on I right-clicked and hit edit agent's config.  I added the following line:

ExternalParameter = MyAVCheck:c:\windows\system32\cscript.exe //Nologo "C:\myscripts\avscript.vbs"

I hit save and apply.  Also restarted service on the node I was working with.


I have ran

c:\windows\system32\cscript.exe //Nologo "C:\myscripts\avscript.vbs"

from a command prompt and it returns the correct value.


I then right-click my node and select Data Collection.  Right-click again and select New.  Hit the select button under the Data/Parameter section with NetXMS agent selected in the dropdown box.  I do not see the MyAVCheck.  How do i start collecting the value from this script?

I am using 1.0.10 console and 1.0.10 agent for windows.
Title: Re: script a wmi query
Post by: Victor Kirhenshtein on March 08, 2011, 09:43:45 PM
List of parameters supported by agent updated during configuration poll. If you wish to see new parameters in the list immediately, you should force configuration poll on the node (by selecting Poll -> Configuration from node's context menu).

Best regards,
Victor
Title: Re: script a wmi query
Post by: Rabid on March 08, 2011, 09:58:04 PM
I did that.  Checked via the same method posted above and still nothing new shows up.  It should show up under Supported agent parameters as MyAVCheck correct?  If so, then nothing is showing up.  Even allowing some time to pass by.  Do I need to add a subagent or anything along those lines?  Also, the vbs file and the config file was edited on the machine I am monitoring.  Nothing needs to be added to the machine that acts as the server correct?
Title: Re: script a wmi query
Post by: Rabid on March 09, 2011, 05:29:39 PM
I figured this out.  I placed the externalparameter line below the *PING line in the config.  Moving it above this line and it works perfectly.

Love this app btw, great work.