Graphing WMI VBScript scripts

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
batch
Posts: 2
Joined: Tue Nov 23, 2004 12:39 pm

Graphing WMI VBScript scripts

Post by batch »

I'm so ready to pull my hair out, cannot figure this out! I learned how to graph MRTG values with WMI scripts, and now I've found cacti, very nice user interface, perfect for what I want to do.

Problem: I have create this script -> memory.vbs

Code: Select all

Set objArgs = wscript.Arguments
Computer = objArgs.item(0)
set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2")
set memory = WMI.ExecQuery( "Select TotalVisibleMemorySize,FreePhysicalMemory from Win32_OperatingSystem",,48 )
For each counter in memory
	totalmemory = counter.TotalVisibleMemorySize
	freememory = counter.FreePhysicalMemory
Next
fixedtotalmemory = totalmemory * 1024
fixedfreememory = freememory * 1024
fixedusedmemory = fixedtotalmemory - fixedfreememory
WScript.Echo "totalmemory:" & fixedtotalmemory & " usedmemory:" & fixedusedmemory
To get useful info from this you need to run:

Code: Select all

cscript //nologo memory.vbs computername
I cannot figure out how to do this from the manul to save my life.

I have created a new Data Input Method called "Windows - Memory Usage". It's a "Script/Command" and "cscript.exe //nologo <path_cacti>/scripts/memory.vbs <computername>" is in the Input String field. I have created an input field called "computername" with only the Friendly Name field filled in with "PC Name". I have created two output fields, one titled "totalmemory" friendly name "Total Memory" and then "usedmemory" friendly name "Used Memory" to match the results of running the script.

Have I done anything wrong so far? I haven't seen ANYWHERE that I can tell cacti what to plug into the <computername> input field. What else do I need to do, what am I missing? Please help.
batch
Posts: 2
Joined: Tue Nov 23, 2004 12:39 pm

Post by batch »

If there is a walkthrough somewhere online, I haven't found it, and I've searched the forum. If you know of one that would answer my question, please point me in the right direction. I have read the manual and cannot find how to do what I want to do.
Guest

Post by Guest »

My script outputs like this:
totalmemory:234234234234 usedmemory:234234234234234

(numers fake, of course)
For the script to work though, you have to pass the computer name to it. Where do you pass variables to the script? How does the script know to use the computer name? Please help, I am stuck and have worked on this for hours!
Guest

Post by Guest »

Isn't that the way the script is supposed to output? I used the example in the manual, but I'm still brand new to this product.
Guest

Post by Guest »

Can anyone please help me? You are able to graph other hosts and not just the one that is running Cacti, right?! How and where do I pass the <computername> to the script so I can graph a whole bunch of other PCs?
Guest

Post by Guest »

I think you do it in the "Input String" under "Data Input Methods"

So I think it would work like this.

cscript //nologo<path_cacti>/scripts/w32_query_cpu.vbs <hostname> get LoadPercentage 4

Gonna try this myself right now... :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest