I read all topics and howto about script_query but my own script don't work.
My XML file
Code: Select all
<interface>
<name>Get Unix Mounted Partitions</name>
<description>DS8xxx Io Port Stats</description>
<script_path>/usr/bin/perl |path_cacti|/scripts/ds8x_ioports.pl</script_path>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<arg_num_indexes>num_indexes</arg_num_indexes>
<output_delimeter>:</output_delimeter>
<index_order>ioPort</index_order>
<index_order_type>alphabetic</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>
<fields>
<ioPort>
<name>Device Name</name>
<direction>input</direction>
<query_name>ioport</query_name>
</ioPort>
<byteRead>
<name>Bytes Read</name>
<direction>output</direction>
<query_name>byteread</query_name>
</byteRead>
<byteWrite>
<name>Bytes Write</name>
<direction>output</direction>
<query_name>bytewrit</query_name>
</byteWrite>
<byteWritPPRC>
<name>Bytes Write in PPRC</name>
<direction>output</direction>
<query_name>bytewritPPRC</query_name>
</byteWritPPRC>
<byteReadPPRC>
<name>Bytes Read in PPRC</name>
<direction>output</direction>
<query_name>bytereadPPRC</query_name>
</byteReadPPRC>
</fields>
</interface>
here the output of my script
Code: Select all
[cacti@test]$ ./ds8x_ioports.pl index
I0000
I0001
I0002
I0003
[cacti@test]$
Code: Select all
[cacti@test]$ ./ds8x_ioports.pl get bytewrit I0000
2386614[cacti@test]$
Code: Select all
[cacti@MOPB2RPTSV-01]$ ./ds8x_ioports.pl query bytewrit
I0000:2386614
I0001:0
I0002:11108598
I0003:0
[cacti@test]$
Code: Select all
[cacti@test]$ ./ds8x_ioports.pl query ioport
I0000:I0000
I0001:I0001
I0002:I0002
I0003:I0003
[cacti@test]$
Code: Select all
+ Running data query [14].
+ Found type = '4 '[script query].
+ Found data query XML file at '/export/eznim/cacti-0.8.6j/resource/script_queries/ds8000_ioports.xml'
+ XML file parsed ok.
+ Executing script for list of indexes 'perl /export/eznim/cacti-0.8.6j/scripts/ds8x_ioports.pl index'
+ Executing script query 'perl /export/eznim/cacti-0.8.6j/scripts/ds8x_ioports.pl query ioport'
+ Found data query XML file at '/export/eznim/cacti-0.8.6j/resource/script_queries/ds8000_ioports.xml'
+ Found data query XML file at '/export/eznim/cacti-0.8.6j/resource/script_queries/ds8000_ioports.xml'
+ Found data query XML file at '/export/eznim/cacti-0.8.6j/resource/script_queries/ds8000_ioports.xml'
Code: Select all
#!/usr/bin/perl
$cmd = "cat ds8x.out";
open(CMD,"$cmd|")
or die "can't start $cmd: $!\n";
while(<CMD>) {
#
chomp();
@words=split(/\s/,$_);
%output = (
ioport => "$words[0]",
bytewritPPRC => "$words[1]" ,
bytereadPPRC => "$words[2]",
WritesPPRC => "$words[3]",
ReadsPPRC => "$words[4]",
timewritePPRC => "$words[5]",
timereadPPRC => "$words[6]",
byteread => "$words[7]",
bytewrit => "$words[8]",
Reads => "$words[9]",
Writes => "$words[10]",
timeread => "$words[11]",
timewrite => "$words[12]",
);
if ($ARGV[0] eq "index") {
print "$output{ioport}\n";
}elsif (($ARGV[0] eq "get") && ($ARGV[2] eq $output{ioport})) {
print $output{$ARGV[1]};
}elsif ($ARGV[0] eq "query") {
print "$output{ioport}:$output{$ARGV[1]}\n";
}
}
close(CMD);