[Resolved] NaN issue on Script Data Query

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

Moderators: Developers, Moderators

Post Reply
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

[Resolved] NaN issue on Script Data Query

Post by DraGun »

Hi,

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
[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]$
I needed to modify the script, that's what I add:

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;
As I see nothing is the logs, I can't debug my graphs. Everything seems ok, even when I turn the debug mode on graph or data source.

Any ideas?
Last edited by DraGun on Thu Nov 06, 2014 9:08 am, edited 1 time in total.
Errare humanum est, perseverare diabolicum
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: NaN issue on Script Data Query

Post by BSOD2600 »

When you manually run the command as shown in the poller cache or cacti.log (with the loggging level set to high or debug), does it return data?
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: NaN issue on Script Data Query

Post by DraGun »

Even without the debug logging level it returns data. That's the quote after the "Poller Cache quote" in my previous message.
It only returns 0 or 1, depending on the connectivity of the link.
Errare humanum est, perseverare diabolicum
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: NaN issue on Script Data Query

Post by phalek »

Look at this bug, especially on my last comments in there:

http://bugs.cacti.net/view.php?id=2390
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: NaN issue on Script Data Query

Post by DraGun »

Hi,

All the others scripts run well... But I didn't rebuild the Poller Cache..
What's the impact on the other scripts or whatever if I change the library for removing the addslashes function?
Errare humanum est, perseverare diabolicum
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: NaN issue on Script Data Query

Post by phalek »

There shouldn't be any impact at all. As you can see in the bug, it's going to be fixed/changed in 0.8.8c like that anyway.

See here for the updated file in the cacti subversion:
http://svn.cacti.net/viewvc/cacti/branc ... 37&r2=7440
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: NaN issue on Script Data Query

Post by DraGun »

I modified the utility.php library.
Deteled the graph, reloaded the data query (just in case) and created a new graph

it's better in the poller cache :)

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
RRD: /usr/local/share/cacti/rra/nte-th275-020014_par_connectivity_214308.rrd
[lde@xxxx ~]$ /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
1[lde@xxxx ~]$
But I still have a NaN issue :(
I can't turn on the debug/devel/high logging level. I'm working on the production environment and we have like 9624 devices...
Errare humanum est, perseverare diabolicum
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: NaN issue on Script Data Query

Post by phalek »

If you have spine, you can enable on-demand debug for just a single host in read-only mode with:

Code: Select all

spine -V 5 -R -f <host_id> -l <host_id> -p 0 -S --option=concurrent_processes:1 --option=php_servers:1 --option=max_threads:1
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: NaN issue on Script Data Query

Post by DraGun »

Thanks a lot :)

First I had this result (just the part we are interested in)
Host[12957] TH[1] DS[214319] 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, output: U
Now I have this one:
Host[12957] TH[1] DS[214319] 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, output: 1
We have 3 servers for Cacti. First one for the polling, second one for the database, and third one for log/configuration files/xml files/scripts etc..
First time I ran spine on the polling server, I saw the "U" output. So I copied my script on that server and I have now the output I want.

I just have to wait for the next polling to see if my graphs are ok now :)
Errare humanum est, perseverare diabolicum
DraGun
Posts: 44
Joined: Thu May 24, 2012 11:21 am

Re: NaN issue on Script Data Query

Post by DraGun »

Well, that works :)
Thank you
Errare humanum est, perseverare diabolicum
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest