Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. script a wmi query

script a wmi query

Scheduled Pinned Locked Moved Support
10 Posts 3 Posters 26.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    M
    miniseb
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M
        M
        miniseb
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M
          M
          miniseb
          wrote on last edited by
          #4

          hello

          any body have an idea?
          miniseb

          1 Reply Last reply
          0
          • V
            V
            Victor Kirhenshtein
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • M
              M
              miniseb
              wrote on last edited by
              #6

              wow
              thanks a milion
              it helps me a lot.
              miniseb

              1 Reply Last reply
              0
              • R
                R
                Rabid
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • V
                  V
                  Victor Kirhenshtein
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • R
                    R
                    Rabid
                    wrote on last edited by
                    #9

                    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?

                    1 Reply Last reply
                    0
                    • R
                      R
                      Rabid
                      wrote on last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      Powered by NodeBB Contributors
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups