Performance Monitor Query [v1.1 - 2011-12-16]

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

Moderators: Developers, Moderators

User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.0 - 2010-01-28]

Post by BSOD2600 »

After redirecting all output from typeperf to file, one can see what is going on...

Code: Select all


"(PDH-CSV 4.0)","\\PCNAME\processor(_Total)\% Processor Time"
"12/16/2011 11:11:18.202","7.188691"
Exiting, please wait...                         
The command completed successfully.
Unfortunately, since delims=, that's why we're getting "wait..." for the second Results since it too is being parsed. I'll have to think about a different method of extracting this info out when I've got time.

http://www.robvanderwoude.com is a great site for batch/other scripting tips/samples.
No point releasing the PS script since Cacti string parsing/cleaning needs to be fixed first (bug #2008)
User avatar
terpmeister
Posts: 4
Joined: Fri Dec 16, 2011 11:29 am
Location: Oregon
Contact:

Re: Performance Monitor Query [v1.0 - 2010-01-28]

Post by terpmeister »

Cool, thanks for the update. I will chew on it some more since I have some time now and will post my results if I can get it working.

Thanks.
-------------------------------------
terpmeister
http://www.redmutt.com
User avatar
terpmeister
Posts: 4
Joined: Fri Dec 16, 2011 11:29 am
Location: Oregon
Contact:

Re: Performance Monitor Query [v1.0 - 2010-01-28]

Post by terpmeister »

Cool, figured it out (I hope). Long story short, since typeperf is outputing 2 lines that meet the delims criteria, I just setup an "array" variable RESULT.x, where x is incremented in the DO loop, and just echo out the first value. I also had to turn on setlocal enabledelayedexpansion, here is an article about it for the curious: http://www.robvanderwoude.com/variableexpansion.php

Here is my recoding: http://pastebin.com/rti8NfMa

Disclaimer, I haven't tested yet with Cacti as of yet, but in theory it should work since it is doing the same output.

Thanks.
-------------------------------------
terpmeister
http://www.redmutt.com
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

Ah arrays in batch, completely forgot about them. Good idea.

I've updated the script with your changes in the OP.
nicoCn
Posts: 12
Joined: Sun Apr 17, 2011 11:29 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by nicoCn »

Hi BSOD2600 , i have a new question , I have used this script and drew many graphs.
now , i have many hosts need to be monitored by cacti, what should i do ?
Setting Data Sources and Graph Management for per host ,its too much trouble.
Colud you please give me some advice?
Thank you very much.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

Completely unrelated to the support of this script... anyways read http://docs.cacti.net/manual:087:6_refe ... ne_scripts
pogorl
Posts: 5
Joined: Tue Jun 24, 2014 1:34 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by pogorl »

Was the issue resolved by any chance?

The script is still working fine in Cacti v0.8.7e on W2k3 32bit machine, but fails in Cacti v0.8.8b on w2k8 64bit.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

pogorl wrote:The script is still working fine in Cacti v0.8.7e on W2k3 32bit machine, but fails in Cacti v0.8.8b on w2k8 64bit.
What's the failure?
pogorl
Posts: 5
Joined: Tue Jun 24, 2014 1:34 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by pogorl »

perfmon_query v1.0 works in Cacti v0.8.7e on W2k3 32bit machine, but fails in Cacti v0.8.8b on w2k8 64bit exactly as already described:

result:wait....

perfmon_query v1.1 works for some hosts, but does not for others like in the log below


06/25/2014 03:00:02 PM - CMDPHP: Poller[0] Host[5] Description[ecnbwn11d] DS[44] Graphs['ecnbwn11d - %CPU'] CMD: E:/htdocs/wwwroot/cacti/scripts/perfmon_query.cmd ecnbwn11d "Processor(_Total)\% Processor Time", output: RESULT:0.765178
06/25/2014 03:00:02 PM - CMDPHP: Poller[0] Time: 1.1544 s, Theads: N/A, Hosts: 1
06/25/2014 03:00:02 PM - CMDPHP: Poller[0] Host[4] Description[ecnbwn06p] DS[10] Graphs['ecnbwn06p - %CPU'] CMD: E:/htdocs/wwwroot/cacti/scripts/perfmon_query.cmd ecnbwn06p "Processor(_Total)\% Processor Time", output: RESULT:9.974165
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Time: 0.4836 s, Theads: N/A, Hosts: 1
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] DS[47] Graphs['ecnbwn11p - Used Space - Physical Memory'] SERVER: E:\htdocs\wwwroot\cacti\scripts\ss_host_disk.php ss_host_disk 10.252.3.57 6 2:161:500:1:10:Public:::::: get total 5, output: 137402515456
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] DS[46] Graphs['ecnbwn11p - %CPU'] CMD: E:/htdocs/wwwroot/cacti/scripts/perfmon_query.cmd 10.252.3.57 "Processor(_Total)\% Processor Time", output: U
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] DS[46] Graphs['ecnbwn11p - %CPU'] WARNING: Result from CMD not valid. Partial Result: U
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] DS[47] Graphs['ecnbwn11p - Used Space - Physical Memory'] SERVER: E:\htdocs\wwwroot\cacti\scripts\ss_host_disk.php ss_host_disk 10.252.3.57 6 2:161:500:1:10:Public:::::: get used 5, output: 7594770432
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] RECACHE DQ[9] OID: .1.3.6.1.2.1.1.3.0, output: 29092037
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] RECACHE DQ[8] OID: .1.3.6.1.2.1.1.3.0, output: 29092037
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] RECACHE DQ[1] OID: .1.3.6.1.2.1.1.3.0, output: 29092037
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[6] Description[ecnbwn11p] PING: ICMP Ping Success (0 ms)
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] PHP Script Server Started Properly
06/25/2014 03:00:01 PM - PHPSVR: Poller[0] PHP Script Server has Started - Parent is cmd
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Time: 0.0780 s, Theads: N/A, Hosts: 1
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[7] Description[ecnswn20p] DS[48] Graphs['ecnswn20p - %CPU'] CMD: E:/htdocs/wwwroot/cacti/scripts/perfmon_query.cmd ecnswn20p ''Processor(_Total)\% Processor Time", output: U
06/25/2014 03:00:01 PM - CMDPHP: Poller[0] Host[7] Description[ecnswn20p] DS[48] Graphs['ecnswn20p - %CPU'] WARNING: Result from CMD not valid. Partial Result: U


Produces normal output if run from commnad line

e:\11>perfmon_query.cmd ecnbwn11p "Processor(_Total)\% Processor Time"
RESULT:2.307061
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

what if you use the IP address instead of the name, does it still work manually?
pogorl
Posts: 5
Joined: Tue Jun 24, 2014 1:34 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by pogorl »

BSOD2600 wrote:what if you use the IP address instead of the name, does it still work manually?
Yes, it does:

e:\11>perfmon_query.cmd 10.252.3.57 "Processor(_Total)\% Processor Time"
RESULT:2.278015

Could it be RRDtools version issue? There are v1.0, v1.2, v1.3 and v1.4 available in dropdown list in settings. I did not find it in rrdtool.exe properties and changed it from default to v1.4. What was the version included with windows installer?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

the last 2 Win Installers have deployed rrdtool 1.4.

You could also be running into a Windows security/permission issue with ecnswn20p. open a command prompt AS the user account which runs the Cacti Scheduled task. verify with the whoami command. Does the typeperf command still return data?
pogorl
Posts: 5
Joined: Tue Jun 24, 2014 1:34 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by pogorl »

BSOD2600 wrote:the last 2 Win Installers have deployed rrdtool 1.4.

You could also be running into a Windows security/permission issue with ecnswn20p. open a command prompt AS the user account which runs the Cacti Scheduled task. verify with the whoami command. Does the typeperf command still return data?
You right. Installer had set scheduled task to local system account. Had to change it to an account with sufficient rights to other hosts.

Really appreciate your help. Thanks....
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by BSOD2600 »

welcome!

You do realize that Cacti comes with SNMP templates for cpu/disk/network which is far more efficient than perfmon queries?
pogorl
Posts: 5
Joined: Tue Jun 24, 2014 1:34 pm

Re: Performance Monitor Query [v1.1 - 2011-12-16]

Post by pogorl »

BSOD2600 wrote:welcome!

You do realize that Cacti comes with SNMP templates for cpu/disk/network which is far more efficient than perfmon queries?
BSOD2600

Thanks for being extremely helpful.

And yes, I realize the benefits of using SNMP. I just want to be sure that I could migrate what I already have on an older server which served me well (again thanks to you) for the past 5 years. SNMP will be the next step.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest