Monitor Windows via WMI from Cacti on Linux

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
jcsdwes
Posts: 4
Joined: Mon Jun 01, 2009 8:31 am

Post by jcsdwes »

How would I set something up to monitor % disk idle time ?
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Find the correct WMI class and then the correct column and setup your templates similar to the existing ones.

Have you made any templates for cacti before? It not you may be in for a bit of a difficult ride..
jcsdwes
Posts: 4
Joined: Mon Jun 01, 2009 8:31 am

Post by jcsdwes »

I might have made a template before, looking at your Disk IO template is looks like its using the raw perf data which the percentidle time doesn't look right in, so can I duplicate that template, switch it to perf fomatted data and clear it out and put in PercentIdleTime instead ? Even in the perf formatted data the output from WMI scriptomatic doesn't look right,

PercentDiskReadTime: 0
PercentDiskTime: 0
PercentDiskWriteTime: 0
PercentIdleTime: 0

PercentDiskTime and PercentIdleTime should be opposite of each other I would think, not the same. Thanks,
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

I've not used those counters before but I tend to try and use RAW data rather than formatted. Mainly because using the RAW data gives better results for things like disk i/o etc.

With that said, you need to understand how those counters generate the data your requesting.

In the case of percent items you'd need a CDEF.
PercentDiskReadTime

Data type: uint64
Access type: Read-only
Qualifiers: CounterType(542573824), DefaultScale(0), PerfDetail(100)

Percentage of elapsed time that the selected disk drive is busy servicing read requests.

For more information about using uint64 values in scripts, see Scripting in WMI.


PercentDiskReadTime_Base

Data type: uint64
Access type: Read-only
Qualifiers: CounterType(1073939712), DefaultScale(0), PerfDetail(100)

Base value for PercentDiskReadTime.

For more information about using uint64 values in scripts, see Scripting in WMI.
This way the raw values are stored rather than the rounded percentage only.

You should still be able to use the formatted data option though, although some versions of the linux wmi client can't handle it properly (mainly the common ones like the debian package or earlier versions).

But yer you could just use the existing templates and mod to use formatted data. Just make sure to use the correct rrd data type so its stored properly.
jcsdwes
Posts: 4
Joined: Mon Jun 01, 2009 8:31 am

Post by jcsdwes »

So using the raw counters how would I calculate the % ? I have the formatted counters working but they dont' seem too accurate compared to perfomance monitor. Thanks,
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Probably easit via example

You would query the following two counters
* PercentDiskReadTime_Base
* PercentDiskReadTime

Build your graph and pull in both but leave the _Base as a hidden line or element etc. Then use a CDEF to work out the percentage which is simply the PercentDiskReadTime / PercentDiskReadTime_Base * 100

That *should* be all there is to it. But best to check the MSDN details to get the correct formula's :)
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Post by stormonts »

I have database size and log file size monitoring working fine with MS SQL 2005 full, but can't figure out for the life of me which WMI classes to use to get the same data for MSSQL 2005 Express.

\root\CIMV2\Win32_PerfRawData_MSSQLInstanceName_MSSQLInstanceNameBufferManager etc. aren't used with the Express version?
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

stormonts wrote:I have database size and log file size monitoring working fine with MS SQL 2005 full, but can't figure out for the life of me which WMI classes to use to get the same data for MSSQL 2005 Express.

\root\CIMV2\Win32_PerfRawData_MSSQLInstanceName_MSSQLInstanceNameBufferManager etc. aren't used with the Express version?
Do they exist? Could be a limitation of the express version. I assume you've tried all the wmiadap /f type stuff to reinitialize it. Are those counters available via Perfmon itself?
stormonts
Cacti User
Posts: 349
Joined: Tue Mar 31, 2009 10:05 am

Post by stormonts »

They do not exist on the server. yep, tried wmiadap /f and rebooted
jspell
Posts: 1
Joined: Thu Jun 04, 2009 3:20 pm

CDEF update

Post by jspell »

claymen wrote:Ahh the CDEF is wrong. I've seen this before when moving between Cacti 0.7.8 and 0.7.8b.

You'll need to update the CDEF to suit as it normally is used to calculate one of the memory values. From off the top of my head it'l need to be updated to take the available bytes from the total memory to work out the currently used memory. Update your CDEF to suit it and you should be sweet.
I am having what appears to be the same problem - can you give me some direction on how I would go about updating the CDEF???

Here is the debug from my graph..

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Gadmsanapp2 - Available Disk Space" \
--rigid \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
CDEF:cdefe=a,a,- \
AREA:#002A97FF:"Total\:" \
GPRINT::LAST:"Current\:%8.2lf %s" \
GPRINT::AVERAGE:"Average\:%8.2lf %s" \
GPRINT::MAX:"Maximum\:%8.2lf %s\n" \
AREA:cdefe#F51D30FF:"Used\:" \
GPRINT:cdefe:LAST:" Current\:%8.2lf %s" \
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s\n" \
COMMENT:" Free\:" \
GPRINT::LAST:"Current\:%8.2lf %s" \
GPRINT::AVERAGE:"Average\:%8.2lf %s" \
GPRINT::MAX:"Maximum\:%8.2lf %s\n"

RRDTool Says:

ERROR: invalid rpn expression in: a,a,-
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Re: CDEF update

Post by claymen »

jspell wrote:
claymen wrote:Ahh the CDEF is wrong. I've seen this before when moving between Cacti 0.7.8 and 0.7.8b.

You'll need to update the CDEF to suit as it normally is used to calculate one of the memory values. From off the top of my head it'l need to be updated to take the available bytes from the total memory to work out the currently used memory. Update your CDEF to suit it and you should be sweet.
I am having what appears to be the same problem - can you give me some direction on how I would go about updating the CDEF???

Here is the debug from my graph..

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Gadmsanapp2 - Available Disk Space" \
--rigid \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Bytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
CDEF:cdefe=a,a,- \
AREA:#002A97FF:"Total\:" \
GPRINT::LAST:"Current\:%8.2lf %s" \
GPRINT::AVERAGE:"Average\:%8.2lf %s" \
GPRINT::MAX:"Maximum\:%8.2lf %s\n" \
AREA:cdefe#F51D30FF:"Used\:" \
GPRINT:cdefe:LAST:" Current\:%8.2lf %s" \
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s\n" \
COMMENT:" Free\:" \
GPRINT::LAST:"Current\:%8.2lf %s" \
GPRINT::AVERAGE:"Average\:%8.2lf %s" \
GPRINT::MAX:"Maximum\:%8.2lf %s\n"

RRDTool Says:

ERROR: invalid rpn expression in: a,a,-
Read back through the thread, it's documented a heap of times. However your rpn expression seems really really broken if it's trying to take the same value away from itself...
xv3rse
Posts: 2
Joined: Wed Jun 10, 2009 2:00 am
Location: Sheffield, UK

Post by xv3rse »

Hi all, having a prob with the Disk I/O template, ive done well up to now, got quite a few graphs working, but this one says no unfortunately, so im looking for a little help.
First up, im running cacti 0.8.7d on Ubuntu 8.04 Server.
Heres the poller cache,

Code: Select all

/usr/bin/php -q /var/www/cacti/scripts/wmi.php -h \'10.60.100.11\' -u \'/etc/cacti/cactiwmi.pw\' -w \'Win32_PerfRawData_PerfDisk_LogicalDisk\' -n \'\' -k \'Name\' -v \'F:\' -c \'DiskWritesPersec,DiskWriteBytesPersec,DiskReadsPersec,DiskReadBytesPersec,CurrentDiskQueueLength\'
	RRD: /var/www/cacti/rra/valleydc01_writespersec_79.rrd 
Running the above gives me the following output:

Code: Select all

NTSTATUS: NT code 0xc004100e - NT code 0xc004100e


Return code non-zero, debug mode enabled!



/usr/bin/wmic --namespace=''\'''\''' --authentication-file='/etc/cacti/cactiwmi.pw' //'10.60.100.11' "SELECT 'DiskWritesPersec,DiskWriteBytesPersec,DiskReadsPersec,DiskReadBytesPersec,CurrentDiskQueueLength' FROM 'Win32_PerfRawData_PerfDisk_LogicalDisk' WHERE 'Name'=''''F:''''"
Exec Status: 1
But then if i run the following wmic command:

Code: Select all

 wmic -U domain/adminuser%pass //server "select DiskWritesPersec,DiskWriteBytesPersec,DiskReadsPersec,DiskReadBytesPersec,CurrentDiskQueueLength from Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='F:'"
I get the following:

Code: Select all

CLASS: Win32_PerfRawData_PerfDisk_LogicalDisk
CurrentDiskQueueLength|DiskReadBytesPersec|DiskReadsPersec|DiskWriteBytesPersec|DiskWritesPersec|Name
0|463381992448|12410206|5321132032|486821|F:
Personally i dont understand where all the '''' come from in the wmic output ! Any help would be appreciated :D
If you can go easy on me too, its my first post :D
Thanks
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

You've broken something there mate.

You've got a stack of extra escaped characters which is sure to break things.

Are you manually escaping things when you enter them?

Basically theres something causing you to get everything double escaped which is in turn breaking it entirely.
xv3rse
Posts: 2
Joined: Wed Jun 10, 2009 2:00 am
Location: Sheffield, UK

Post by xv3rse »

Bummer, heres the RRD output: any use? Getting an error with that :(

Code: Select all

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="VALLEYDC01 - Disk I/O" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Operations Per Sec" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/var/www/cacti/rra/valleydc01_readbytespersec_80.rrd":ReadsPersec:AVERAGE \
DEF:b="/var/www/cacti/rra/valleydc01_readbytespersec_80.rrd":WritesPersec:AVERAGE \
DEF:c="/var/www/cacti/rra/valleydc01_readbytespersec_80.rrd":QueueLength:AVERAGE \
CDEF:cdefa=a,e,+ \
AREA:cdefa#BCBEB3FF:"Total\:"  \
GPRINT:cdefa:LAST:"       Current\:%8.2lf %s"  \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:a#FF0000FF:"Read\:"  \
GPRINT:a:LAST:"        Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:b#002A97FF:"Write\:"  \
GPRINT:b:LAST:"       Current\:%8.2lf %s"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:b:MAX:"Maximum\:%8.2lf %s\n"  \
LINE1:c#000000FF:"Queue Length\:"  \
GPRINT:c:LAST:"Current\:%8.2lf %s"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" 

RRDTool Says:

ERROR: invalid rpn expression in: a,e,+
Cheers
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Well that RRDTool output doesn't affect what you are seeing on the console however you also have broken CDEF's there. I'm guessing Cacti 0.8.7c/d? You'll need to update those to suit.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests