Monitor Windows via WMI from Cacti on Linux

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

Moderators: Developers, Moderators

Post Reply
zeroy
Posts: 25
Joined: Wed Jan 25, 2006 8:27 am

Post by zeroy »

claymen wrote:It looks like it wasn't able to run the WMI query.
What happens when you run the wmic command itself?
OK, here is the output:

Code: Select all

[root@localhost ~]# /usr/bin/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.1.235 "SELECT PercentProcessorTime FROM Win32_ComputerSystem"
ERROR: Retrieve result data.
NTSTATUS: NT code 0xc0041017 - NT code 0xc0041017
However running the following command instead:

Code: Select all

[root@localhost ~]# /usr/bin/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.1.235 "SELECT * FROM Win32_ComputerSystem"
I get the full output correctly:

Code: Select all

CLASS: Win32_ComputerSystem
AdminPasswordStatus|AutomaticResetBootOption|AutomaticResetCapability|BootOptionOnLimit|BootOptionOnWatchDog|BootROMSupported|BootupState|Caption|ChassisBootupState|CreationClassName|CurrentTimeZone|DaylightInEffect|Description|DNSHostName|Domain|DomainRole|EnableDaylightSavingsTime|FrontPanelResetStatus|InfraredSupported|InitialLoadInfo|InstallDate|KeyboardPasswordStatus|LastLoadInfo|Manufacturer|Model|Name|NameFormat|NetworkServerModeEnabled|NumberOfProcessors|OEMLogoBitmap|OEMStringArray|PartOfDomain|PauseAfterReset|PowerManagementCapabilities|PowerManagementSupported|PowerOnPasswordStatus|PowerState|PowerSupplyState|PrimaryOwnerContact|PrimaryOwnerName|ResetCapability|ResetCount|ResetLimit|Roles|Status|SupportContactDescription|SystemStartupDelay|SystemStartupOptions|SystemStartupSetting|SystemType|ThermalState|TotalPhysicalMemory|UserName|WakeUpType|Workgroup
1|True|True|0|0|True|Normal boot|<myhost>|4|Win32_ComputerSystem|60|True|AT/AT COMPATIBLE|<myhost>|<my_host_domain>|5|True|2|False|Unsupported|(null)|2|(null)|Dell Computer Corporation|PowerEdge 400SC              |DLK-OFFICE-01|(null)|True|2|Unsupported|Unsupported|True|-1|Unsupported|False|1|0|3|(null)|Nehemie IEM|1|-1|-1|Unsupported|OK|Unsupported|30|Unsupported|0|X86-based PC|3|1072648192|(null)|3|(null)
Then, trying the same above command using the wmi php produces correct output also; Does this mean the command used by your templates aren't compatible with my wmic version?

Thanks,
¬¬ZeRoY¬¬
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Hang on I see the problem

PercentProcessorTime does not exist in the Win32_ComputerSystem class.

Your templates are buggered.

Can you try with the final build rather than rc.
zeroy
Posts: 25
Joined: Wed Jan 25, 2006 8:27 am

Post by zeroy »

claymen wrote:Can you try with the final build rather than rc.
Not sure what the latest is, is it this?

http://www.parkingdenied.com/2009/05/21 ... -cactiwmi/
¬¬ZeRoY¬¬
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Yer that should be the latest released version.

Let me know how you go.
zeroy
Posts: 25
Joined: Wed Jan 25, 2006 8:27 am

Post by zeroy »

OK, im getting better results now and it could have been related partially on the fact that i was using FQDN for servers, using IP i DID get some output (not anymore) for the CPU related stuff ( i could see the processor time,etc in Cacti log).

Now im back to getting this:

Code: Select all

04/08/2010 03:25:21 PM - CMDPHP: Poller[0] Host[6] DS[149] CMD: /usr/bin/php -q /var/www/cacti/scripts/wmi.php -h '192.168.253.236' -u '/etc/cacti/cactiwmi.pw' -w 'Win32_PerfFormattedData_PerfOS_Processor' -n '' -k '' -v '' -c 'PercentProcessorTime', output: U
Running the same php on the box works however now everytime:

Code: Select all

[root@localhost log]# /usr/bin/php -q /var/www/cacti/scripts/wmi.php -h '192.168.253.236' -u '/etc/cacti/cactiwmi.pw' -w 'Win32_PerfFormattedData_PerfOS_Processor' -n '' -k '' -v '' -c 'PercentProcessorTime'

/usr/bin/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.253.236 "SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor"
Exec Status: 0

Name0:0
PercentProcessorTime0:6
Name1:1
PercentProcessorTime1:9
Name2:_Total
¬¬ZeRoY¬¬
zeroy
Posts: 25
Joined: Wed Jan 25, 2006 8:27 am

Post by zeroy »

Update again, CPU stuff is outputting fine now but no luck on the Exchange stuff:

Code: Select all

[root@localhost log]# /usr/bin/php -q /var/www/cacti/scripts/wmi.php -h '192.168.253.236' -u '/etc/cacti/cactiwmi.pw' -w 'Exchange_Mailbox' -n 'rootMicrosoftExchangeV2' -k 'MailboxDisp,TotalItems,DeletedMessageSizeExtended'
NTSTATUS: NT code 0xc004100e - NT code 0xc004100e

Return code non-zero, debug mode enabled!

/usr/bin/wmic --namespace='rootMicrosoftExchangeV2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.253.236 "SELECT Size,TotalItems,DeletedMessageSizeExtended FROM Exchange_Mailbox WHERE MailboxDisplayName="
Exec Status: 1
¬¬ZeRoY¬¬
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Why is there no filter on that exchange one ?

Code: Select all

/usr/bin/wmic --namespace='rootMicrosoftExchangeV2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.253.236 "SELECT Size,TotalItems,DeletedMessageSizeExtended FROM Exchange_Mailbox WHERE MailboxDisplayName="
That query will fail without it. E.g. Your asking WMI to select size, total items, deleted message size from the exchange_mailbox table where mailboxdisplayname is equal to nothing. WMI queries like this are basically a cut down SQL (aptly named WQL). So your query will fail. Check what you have configured.

I would also install scriptomatic2 on the exhcange box and see if those classes even exist..
User avatar
JorisFRST
Cacti User
Posts: 229
Joined: Mon Oct 02, 2006 1:22 pm
Location: Belgium
Contact:

Citrix - sessions

Post by JorisFRST »

Hi,

I just made a simple citrix one based on your script.
I hope to do some more in the next weeks as we're planning to monitor more of our windows boxes.

Image

This one basicly shows the number of sessions active / disconnected.
It also includes the "total" counter, but I can't find out 100% what it means.

The active, disconnected however is exactly what you would see when looking in task manager/users.

Any suggestions to make it nicer are welcome.


http://www.routerjanitor.com/2011/09/ca ... -from.html
Attachments
cacti_graph_template_citrix_-_sessions_wmi.xml
(18.62 KiB) Downloaded 495 times
citrix-sessions.png
citrix-sessions.png (6.3 KiB) Viewed 6993 times
Last edited by JorisFRST on Thu Sep 08, 2011 2:36 am, edited 4 times in total.
User avatar
JorisFRST
Cacti User
Posts: 229
Joined: Mon Oct 02, 2006 1:22 pm
Location: Belgium
Contact:

Post by JorisFRST »

Fixed above post.
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Looks pretty sweet to me, nice work :)
DWAyotte
Posts: 32
Joined: Wed Mar 28, 2007 1:37 pm

Post by DWAyotte »

How can i get wmi-client for ubuntu server 10.04? Does it exist?
I try sudo apt-get install wmi-client and it fails to find package :(
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Download the source and compile it. The deb packages were traditionally rather old or using the old build which had a few crashing problems.

Best bet grab the latest source and build it :)
DWAyotte
Posts: 32
Joined: Wed Mar 28, 2007 1:37 pm

Post by DWAyotte »

crap. I am a windows dude and suck at remotely advanced linux things. I will give it a shot i guess. Thanks for the fast reply.
fredyap1234
Posts: 12
Joined: Fri May 14, 2010 3:15 am

Auth file

Post by fredyap1234 »

Hi there,

I'm wondering where can you read about configuring Remote RPC privileges and firewall access?

My RRD files has been created but my graph shows NaN at the present moment. I believe this has something to do with the RPC configuration.

Thanks in advance.
fredyap1234
Posts: 12
Joined: Fri May 14, 2010 3:15 am

Post by fredyap1234 »

Further investigation shows that it may not be RPC after all.

Looks like I'm missing wmi-client in my linux box. wmi-client is not supported by Ubuntu anymore. :(
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests