Can I create a data input methods which return more fields with one query?
Explain it with more details. I would interrogate a database which not
support SNMP and so I develop a script for query. On the machine I have more database. I create a DataQuery and a XML for list of database. My script support command get, index and query. When insert the "Associated Data Queries" in my devices cacti invoke my script first with parameter index and after with parameter query. After I create a data source for one of list return, cacti invoke my script with get but it take all output for one field.
Script
Code: Select all
function ss_database($hostname, $user, $pass,$cmd, $arg1 = "", $arg2 = "") {
if ($cmd == "index" || $cmd == "query") {
$dblist = list_database($hostname,$user,$pass);
for($i=0;($i<sizeof($dblist));$i++) {
if($cmd == "index")
echo $dblist[$i] . "\n";
else
echo $dblist[$i] . '!' . $dblist[$i] . "\n";
}
} elseif ($cmd == "get") {
echo "field1!10 field2!20";
}
}
Code: Select all
<query>
<name>Database</name>
<script_path>|path_php_binary| -q |path_cacti|/scripts/script.php</script_path>
<arg_prepend>|host_hostname| |host_snmp_username| |host_snmp_password|</arg_prepend>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<output_delimeter>!</output_delimeter>
<index_order>DatabaseName</index_order>
<index_order_type>alphabetic</index_order_type>
<index_title_format>Database Name|chosen_order_field|</index_title_format>
<fields>
<DatabaseName>
<name>Database Name</name>
<direction>input</direction>
<query_name>index</query_name>
</DatabaseName>
<Output>
<name>Output</name>
<direction>output</direction>
<query_name>output</query_name>
</Output>
</fields>
</query>
Input Fields
Name Field Order Friendly Name
index_type 0 (Not In Use) Index Type Delete
index_value 0 (Not In Use) Index Value Delete
output_type 0 (Not In Use) Output Type ID Delete
Output Fields
Name Field Order Friendly Name Update RRA
field1 0 (Not In Use) Field1 Selected Delete
field2 0 (Not In Use) Field2 Selected Delete
On data query I associate the same field output to 2 data source but I think is not correct.
Thanks for help
Giovanni