I have created a script query to graph the # of received prefixes over a BGP session. The script itself works from the command line when passing arguments to it, and I can add it to a device in Cacti as a data query and successfully retrieve indexes, peer ip, # of received prefixes, etc...
However it looks like the script query is not actually being executed, no rrd files are created, and nothing is placed in the poller cache.
Can someone please take a look at this and let me know where I went wrong? Thanks a bunch.
Unfortunately JunOS requires 2 look ups, as the BGP index and IP address are stored in a diff table then the # of received prexifes. Which is why I'm doing a script query rather then a basic snmp query. Also you cannot do an snmpget on the second lookup which contains the # of received prefixes, you have to do another walk.
Output is below. Please let me know if you need anything else. Thanks!
IPs have been replaced with x's, community string has also been taken out.
Code: Select all
+ Running data query [59].
+ Found type = '6 '[script query].
+ Found data query XML file at '/home/mhinzel/cacti/resource/script_queries/juniper_bgp.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: index'
+ Executing script query '/usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: query index'
+ Executing script query '/usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: query peerip'
+ Found item [hrPeerIP='x.x.x.x'] index: 52
+ Found item [hrPeerIP='x.x.x.x'] index: 44
...(output trimmmed)
+ Found data query XML file at '/home/mhinzel/cacti/resource/script_queries/juniper_bgp.xml'
+ Found data query XML file at '/home/mhinzel/cacti/resource/script_queries/juniper_bgp.xml'
+ Found data query XML file at '/home/mhinzel/cacti/resource/script_queries/juniper_bgp.xml'
Code: Select all
cacti:~/cacti/resource/script_queries$ /usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: get received 10
214418
Code: Select all
cacti:~/cacti/resource/script_queries$ /usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: index
52
44
45
46
53
47
....
Code: Select all
cacti:~/cacti/resource/script_queries$ /usr/bin/php5 -q /home/mhinzel/cacti/scripts/juniperbgpreceived.php x.x.x.x 2:161:10000:1:10:cstring:::MD5::DES: query peerip
52!x.x.x.x
44!x.x.x.x
45!x.x.x.x
46!x.x.x.x
XML file:
Code: Select all
<interface>
<name>Juniper BGP Peer received prefixes</name>
<script_path>|path_php_binary| -q |path_cacti|/scripts/juniperbgpreceived.php</script_path>
<arg_prepend>|host_hostname| |host_snmp_version|:|host_snmp_port|:|host_snmp_timeout|:|host_ping_retries|:|host_max_oids|:|host_snmp_community|:|host_snmp_username|:|host_snmp_password|:|host_snmp_auth_protocol|:|host_snmp_priv_passphrase|:|host_snmp_priv_protocol|:|host_snmp_context|</arg_prepend>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<output_delimeter>!</output_delimeter>
<index_order>hrPeerIndex</index_order>
<index_order_type>numeric</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>
<fields>
<hrPeerIndex>
<name>Index</name>
<direction>input</direction>
<query_name>index</query_name>
</hrPeerIndex>
<hrPeerIP>
<name>BGP Peer IP</name>
<direction>input</direction>
<query_name>peerip</query_name>
</hrPeerIP>
<hrPrefixes>
<name>Prefixes Received</name>
<direction>output</direction>
<query_name>received</query_name>
</hrPrefixes>
</fields>
</interface>