script query debugging

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
ahhdem
Posts: 18
Joined: Thu Jun 14, 2007 1:41 pm

script query debugging

Post by ahhdem »

Here's what I've got going on, running cacti 0.6.8i,
with no plugins or other mods. Straight from the src.

the script lives in scripts/ioparse.php and the
resource/script_queries/host_disk_stats.xml file is below. I used the
host_disk.xml as a template to build from:


<interface>
<name>Get Host IO stats</name>
<script_path>|path_php_binary| -q |
path_cacti|/scripts/ioparse.php</script_path>
<arg_prepend>|host_hostname|</arg_prepend>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<output_delimeter>!</output_delimeter>
<index_order>Index:Device</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>

<fields>
<Index>
<name>Index</name>
<direction>input</direction>
<query_name>index</query_name>
</Index>
<Device>
<name>Device</name>
<direction>input</direction>
<query_name>name</query_name>
</Device>

<readRqsM>
<name>Read RQ/s Merged</name>
<direction>output</direction>
<query_name>rrqms</query_name>
</readRqsM>
<writeRqsM>
<name>Write RQ/s Merged</name>
<direction>output</direction>
<query_name>wrqms</query_name>
</writeRqsM>
<readS>
<name>Read Operations per Sec</name>
<direction>output</direction>
<query_name>rs</query_name>
</readS>
<writeS>
<name>Write Opertations per Sec</name>
<direction>output</direction>
<query_name>ws</query_name>
</writeS>
<readSecS>
<name>Read Sectors per Sec</name>
<direction>output</direction>
<query_name>rsecs</query_name>
</readSecS>
<writeSecS>
<name>Write Sectors per Sec</name>
<direction>output</direction>
<query_name>wsecs</query_name>
</writeSecS>
<rkBytes>
<name>Read kilobyte/s</name>
<direction>output</direction>
<query_name>rkBs</query_name>
</rkBytes>
<wkByteS>
<name>Write kilobyte/s</name>
<direction>output</direction>
<query_name>wkBs</query_name>
</wkByteS>
<avgRequest>
<name>Average Request Size</name>
<direction>output</direction>
<query_name>avgrq_sz</query_name>
</avgRequest>
<avgQueue>
<name>Average Queue Size</name>
<direction>output</direction>
<query_name>avgqu_sz</query_name>
</avgQueue>
<avgWait>
<name>Average wait time per Request</name>
<direction>output</direction>
<query_name>await</query_name>
</avgWait>
<serviceTime>
<name>Time to service Request</name>
<direction>output</direction>
<query_name>svctm</query_name>
</serviceTime>
<Util>
<name>Disk CPU Util</name>
<direction>output</direction>
<query_name>util</query_name>
</Util>
</fields>
</interface>


Heres my script in action:

[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 index
1
2
3
4
5
6
[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 query name
1!sda
2!sdb
3!md0
4!md1
5!dm_0
6!dm_1
[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 query rsecs
1!249.54
2!249.53
3!0.00
4!499.07
5!498.90
6!0.00
[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 query rkBs
1!124.77
2!124.77
3!0.00
4!249.53
5!249.45
6!0.00
[root@ranger scripts]#
[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 get wkBs 5
1032.17[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 get wkBs 6
0.00[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 get wkBs 2
515.93[root@ranger scripts]# php -q /var/www/cacti/scripts/ioparse.php
10.0.0.43 get wkBs 1
516.29[root@ranger scripts]#

However, it seems that the data being graphed for all devices is that of
the first ordered index.

From the cacti console:

Data Query Debug Information
+ Running data query [15].
+ Found type = '4 '[script query].
+ Found data query XML file at
'/var/www/cacti/resource/script_queries/host_disk_stats.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php
-q /var/www/cacti/scripts/ioparse.php 10.0.0.43 index'
+ Executing script query '/usr/bin/php
-q /var/www/cacti/scripts/ioparse.php 10.0.0.43 query index'
+ Found item [Index='1'] index: 1
+ Found item [Index='2'] index: 2
+ Found item [Index='3'] index: 3
+ Found item [Index='4'] index: 4
+ Found item [Index='5'] index: 5
+ Found item [Index='6'] index: 6
+ Executing script query '/usr/bin/php
-q /var/www/cacti/scripts/ioparse.php 10.0.0.43 query name'
+ Found item [Device='sda'] index: 1
+ Found item [Device='sdb'] index: 2
+ Found item [Device='md0'] index: 3
+ Found item [Device='md1'] index: 4
+ Found item [Device='dm_0'] index: 5
+ Found item [Device='dm_1'] index: 6
+ Found data query XML file at
'/var/www/cacti/resource/script_queries/host_disk_stats.xml'
+ Found data query XML file at
'/var/www/cacti/resource/script_queries/host_disk_stats.xml'
+ Found data query XML file at
'/var/www/cacti/resource/script_queries/host_disk_stats.xml'

Look below for the graphs it's creating:

As you can see, they are all the same values, which I believe are being
pulled from sda, but I'm not certain -- sda and sdb are in a mirror via device md0/dm_0, so sda and sdb should look the same, but certainly not dm_0 -- It seems cacti does not put debug data for script queries in the log, as I am unable to match by fieldname or script name when grepping, and i am in full debug.

Also, I added in some debugging code to output the input line (called + args), the input from the remote host, a couple arry dumps and finally the output to a file pointer, but it seems like cacti somehow circumvents that when it polls, as my debug log only fills up when executing the query from the host.php?action=edit screen.

I'm pretty stumped and have been wrestling this for the past couple
days... I'm not sure where to look now... logic tells me it's in the
template or the script, but as far as I can tell they are behaving
properly.
Attachments
graphs created via my script
graphs created via my script
badgraphs.png (96.13 KiB) Viewed 4220 times
ahhdem
Posts: 18
Joined: Thu Jun 14, 2007 1:41 pm

Post by ahhdem »

*bump* ; plus noone responds to a thread with no responses already...... :-)
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please verify from "System Utilities -> Poller Cache", that threquired entries for that host are correct
Reinhard
ahhdem
Posts: 18
Joined: Thu Jun 14, 2007 1:41 pm

Post by ahhdem »

Reinhard, the poller cache is pointing to three diferent rrds, one for each device, but the values in the rrd's are all the same....

thanks
-adam

[root@ranger ~]# rrdtool dump /var/www/cacti/rra/tyree_sda_util_2205.rrd |grep -A10 kBs
<name> sda_wkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 3.6734400000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
--
<name> sda_rkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 1.5191200000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
[root@ranger ~]# rrdtool dump /var/www/cacti/rra/tyree_sda_util_2206.rrd |grep -A10 kBs
<name> sda_rkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 1.5191200000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
--
<name> sda_wkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 3.6734400000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
[root@ranger ~]# rrdtool dump /var/www/cacti/rra/tyree_sda_util_2207.rrd |grep -A10 kBs
<name> sda_rkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 1.5191200000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
--
<name> sda_wkBs </name>
<type> GAUGE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> NaN </max>

<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 3.6734400000e+03 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
[root@ranger ~]#
Attachments
poller_cache_items.png
poller_cache_items.png (33.54 KiB) Viewed 4100 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please post the script and an export of the Graph template (including dependencies) as well as the latest XML file. I will try to reproduce.
But starting from wednesday, I will be off for 3 weeks: woooow, holidays!
Reinhard
ahhdem
Posts: 18
Joined: Thu Jun 14, 2007 1:41 pm

Post by ahhdem »

ooooh lucky you, that is a loooonng vacation! hopefully I will have figured something out by then!

attached is the script, the graph template export + the query xml template... thanks so much for your help

oh also be ware to change the $input variable line in the ioparse.php script -- requires iostat on the local machine. I had to rename the php script to .xml to get past the filter...
Attachments
host_disk_stats.xml
resources/script_queries xml template
(2.33 KiB) Downloaded 191 times
ioparse.actually.php.xml
php script to read in values and produce cacti query interface
(4.09 KiB) Downloaded 180 times
cacti_graph_template_iostatparse_rw_kbytes.xml
graph template export + dependancies
(32.21 KiB) Downloaded 202 times
ahhdem
Posts: 18
Joined: Thu Jun 14, 2007 1:41 pm

Post by ahhdem »

I haven't gotten anywhere with this.. were you able to replicate the issue?

thanks
-adam
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Sorry for responding thus late.
I've put your issue onto my todo list and did not find time until now.
I've tried to install your ressources to no avail. I need an export of the whole Data Query.
But prio to posting this, please change <direction>input to <direction>output in your XML. Then, you will be able to see the data returned when selection Verbose Query.
HTH
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests