I'm trying to use for the first time a Script Data Query, and used the HowTo page
I have a NaN issue.
Nothing in logs about that host, the query seen in the poller is working, I changed the Data Template with "U" as Maximal value, but still the same..
Verbose Query wrote:+ Running data query [61].
+ Found type = '4' [Script Query].
+ Found data query XML file at '/usr/local/share/cacti/resource/script_queries/adva_oam_connectivity.xml'
+ XML file parsed ok.
+ <arg_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting arg_index entries
+ Executing script for list of indexes '/usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php 10.152.201.29 cpdea 2 161 2000 100 "" "" "" "" "" "" index' Index Count: 8
+ Found index: 1
+ Found index: 2
+ Found index: 3
+ Found index: 4
+ Found index: 5
+ Found index: 6
+ Found index: 7
+ Found index: 8
+ Executing script query '/usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php 10.152.201.29 cpdea 2 161 2000 100 "" "" "" "" "" "" query descr'
+ Found item [ifDescr='ETHERNET NETWORK PORT'] index: 1
+ Found item [ifDescr='ETHERNET NETWORK PORT'] index: 2
+ Found item [ifDescr='ETHERNET ACCESS PORT'] index: 3
+ Found item [ifDescr='ETHERNET ACCESS PORT'] index: 4
+ Found item [ifDescr='ETHERNET ACCESS PORT'] index: 5
+ Found item [ifDescr='ETHERNET ACCESS PORT'] index: 6
+ Found item [ifDescr='ETHERNET MANAGEMENT PORT'] index: 7
+ Found item [ifDescr='G3 USB MODEM'] index: 8
+ Executing script query '/usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php 10.152.201.29 cpdea 2 161 2000 100 "" "" "" "" "" "" query index'
+ Found item [ifIndex='1'] index: 1
+ Found item [ifIndex='2'] index: 2
+ Found item [ifIndex='3'] index: 3
+ Found item [ifIndex='4'] index: 4
+ Found item [ifIndex='5'] index: 5
+ Found item [ifIndex='6'] index: 6
+ Found item [ifIndex='7'] index: 7
+ Found item [ifIndex='8'] index: 8
+ Executing script query '/usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php 10.152.201.29 cpdea 2 161 2000 100 "" "" "" "" "" "" query operStatus'
+ Found item [ifOperStatus='up(1)'] index: 1
+ Found item [ifOperStatus='down(2)'] index: 2
+ Found item [ifOperStatus='up(1)'] index: 3
+ Found item [ifOperStatus='down(2)'] index: 4
+ Found item [ifOperStatus='down(2)'] index: 5
+ Found item [ifOperStatus='down(2)'] index: 6
+ Found item [ifOperStatus='down(2)'] index: 7
+ Found item [ifOperStatus='down(2)'] index: 8
+ Executing script query '/usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php 10.152.201.29 cpdea 2 161 2000 100 "" "" "" "" "" "" query testName'
+ Found item [TestName=''] index: 1
+ Found item [TestName=''] index: 2
+ Found item [TestName='ADVA-IXEN-14060152_OAM_1_2'] index: 3
+ Found item [TestName=''] index: 4
+ Found item [TestName=''] index: 5
+ Found item [TestName=''] index: 6
+ Found item [TestName=''] index: 7
+ Found item [TestName=''] index: 8
Poller Cache wrote:ADVA-IXEN-14060152_OAM_1_2 - Connectivity Script: /usr/local/bin/php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php X.X.X.X community 2 161 2000 100 \"\" \"\" \"\" \"\" \"\" \"\" get connectivity 3
I needed to modify the script, that's what I add:[lde@xxxx /usr/local/share/cacti/scripts]$ php -q /usr/local/share/cacti/scripts/query_connectivity_adva_oam.php X.X.X.X community 2 161 2000 100 "" "" "" "" "" "" get connectivity 3
1[lde@xxxx /usr/local/share/cacti/scripts]$
Code: Select all
### Added by LDE ###
} elseif ($cmd == "get" && $query_field == "connectivity" && isset($query_index)) {
//datas
$remoteMEP = cacti_snmp_get($hostname, $snmp_community,
$oids["remoteMEP"] . ".$query_index", $snmp_version, $snmp_auth_username,
$snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol,
$snmp_context, $snmp_port, $snmp_timeout, $snmp_retries, $max_oids, SNMP_POLLER);
//print "remoteMEP: $remoteMEP\n";
$stateRemoteMEP = cacti_snmp_get($hostname, $snmp_community,
$oids["stateRemoteMEP"].".$query_index.1.$remoteMEP", $snmp_version, $snmp_auth_username,
$snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol,
$snmp_context, $snmp_port, $snmp_timeout, $snmp_retries, $max_oids, SNMP_POLLER);
//print "stateRemoteMEP: $stateRemoteMEP\n";
$uptime = cacti_snmp_get($hostname, $snmp_community,
$oids["uptime"].".$query_index.1.$remoteMEP", $snmp_version, $snmp_auth_username,
$snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol,
$snmp_context, $snmp_port, $snmp_timeout, $snmp_retries, $max_oids, SNMP_POLLER);
//print "uptime: $uptime\n";
//if remote MEP is ok
if ($stateRemoteMEP == 4) {
//if uptime bigger than 5 min
if ($uptime < 30000) {
$connectivity = 0;
} else {
$connectivity = 1;
}
//if remote MEP is NOK
} else {
//if uptime smaller than 5 min
if ($uptime < 30000) {
$connectivity = 1;
} else {
$connectivity = 0;
}
}
print $connectivity;
Any ideas?