juniper policer data-query (QoS) released

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

Moderators: Developers, Moderators

terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

So far so good,

After commenting lines 25 and 26 the script gives me this message:

Fatal error: Call to undefined function snmp_data_array() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 135

I think it's no problem to run the script under Windows.
What can I do further ?
Last edited by terziyski on Mon Aug 25, 2008 5:49 am, edited 1 time in total.
Cacti user
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

terziyski wrote:So far so good,

After commenting lines 25 and 26 the script gives me this message:

Fatal error: Call to undefined function snmp_data_array() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 135

I think it's no problem to run the script under Windows, but may be there is a differences between commands in PHP versions.
What can I do further ?
could you please try update functions.php (v2) - i've uploaded it in this topic's first post. If this won't help - well, it sucks then and i'll have to setup cacti windows test environment - it might take a while :evil:
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

I have updated functions.php(v2), but result is the same :

Fatal error: Call to undefined function snmp_data_array() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 135

I think snmp_data_array() function is the problem.

When I run the script I am running it from cacti\lib folder if this could be helpful.
I noticed that this folder contains functions.php from original Cacti instalation and may be snmp_data_array() is defined in your functions.php, but not in the original cacti\lib\functions.php
Cacti user
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

terziyski wrote:I have updatted functions.php(v2), but result is the same :

Fatal error: Call to undefined function snmp_data_array() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 135

I think snmp_data_array() function is the problem.Is this a Cacti built-in function or not...

When I run the script I am running it from cacti\lib folder if this could be helpful.
it is not cacti's build in function and, for some reason, functions.php seems not to be included.

you could try replace 3rd line in juniper-policer-64.php from
include "functions.php"
to
include dirname(__FILE__)."/functions.php";
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

I' ve done that, but now the script tells me this:

Fatal error: Call to undefined function cacti_snmp_walk() in C:\Inetpub\wwwroot\cacti\scripts\functions.php on line 37

I think for some reason now it does not use cacti\lib\functions.php where cacti_snmp_walk() is declared, even I am starting the script from cacti\lib folder.

I think we are missing something very insignificant.
Maybe the name of your functions.php mismatching that from the Cacti instalation. Is it possible changing the name of your functions.php to something else could resolve this problem ?
Cacti user
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

terziyski wrote:I' ve done that, but now the script tells me this:

Fatal error: Call to undefined function cacti_snmp_walk() in C:\Inetpub\wwwroot\cacti\scripts\functions.php on line 37

I think for some reason now it does not use cacti\lib\functions.php where cacti_snmp_walk() is declared, even I am starting the script from cacti\lib folder.

I think we are missing something very insignificant.
Maybe the name of your functions.php mismatching that from the Cacti instalation. Is it possible changing the name of your functions.php to something else could resolve this problem ?
well...you are first to report such problem. lot's of people are using same scripts (functions.php is used by my cicso-car and cisco-qos templates as well) and none reported such strange behaviour.

could you arrange me a remote session to your machine tomorrow? (ssh,rdp,vnc - whatever). Or...i'll ask for you to wait ~ 1week because currently i have no time to establish cacti windows test platform.
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

I cannot arrang you a remote access to the machine, because this has to be done by the sysadmins. Nevertheless, if I succeed to arrange that I will post you a message.
I can wait too, because this is no urgent matter for me, but is interesting because we have a few m320 and I wanted to graph the qos for them.

P.S. I use cicso-car and cisco-qos templates too, but on the other Linux machine where Cacti version is 0.8.6g and I cannot import the XML files for juniper qos:(
Cacti user
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

terziyski wrote:I cannot arrang you a remote access to the machine, because this has to be done by the sysadmins. Nevertheless, if I succeed to arrange that I will post you a message.
I can wait too, because this is no urgent matter for me, but is interesting because we have a few m320 and I wanted to graph the qos for them.

P.S. I use cicso-car and cisco-qos templates too, but on the other Linux machine where Cacti version is 0.8.6g and I cannot import the XML files for juniper qos:(
Ok, anyway,
I'll respond ASAP - most likely this weekend.
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

I managed to resolve this issue like this:

1)in functions.php(v2):
replace $pth = str_replace("/scripts","",dirname(__FILE__));
with $pth = str_replace("\scripts","",dirname(__FILE__));

2)rename functions.php(v2) to functions2.php (it was a must)

3)in juniper-policer-64:
replace include "functions.php";
with include "functions2.php";

It works also with your suggestion to replace :
include "functions.php" with include dirname(__FILE__)."/functions.php";
in juniper-policer-64.php,
but 1) was mandatory.

My next question is why I receive in Data Query Debug Information results with '' symbols ?

+ Found item [index='".L__auto_policer_template_2____policer_tmpl__-fc1||3||0"'] index: ".L__auto_policer_template_2____policer_tmpl__-fc1||3||0"
Cacti user
User avatar
johnrembo
Cacti User
Posts: 216
Joined: Mon Apr 24, 2006 3:33 am

Post by johnrembo »

terziyski wrote:I managed to resolve this issue like this:

1)in functions.php(v2):
replace $pth = str_replace("/scripts","",dirname(__FILE__));
with $pth = str_replace("\scripts","",dirname(__FILE__));

2)rename functions.php(v2) to functions2.php (it was a must)

3)in juniper-policer-64:
replace include "functions.php";
with include "functions2.php";

It works also with your suggestion to replace :
include "functions.php" with include dirname(__FILE__)."/functions.php";
in juniper-policer-64.php,
but 1) was mandatory.

My next question is why I receive in Data Query Debug Information results with '' symbols ?

+ Found item [index='".L__auto_policer_template_2____policer_tmpl__-fc1||3||0"'] index: ".L__auto_policer_template_2____policer_tmpl__-fc1||3||0"
that must be realated to chr() and ord() disfunction in juniper-policer-64.php on windows box.

short description on how it works:
normal data-query index should look like:
__auto_policer_template_1__.__policer_tmpl__-fc0||3||27

while snmp oid of this value is:
SNMPv2-SMI::enterprises.2636.3.5.2.1.5.27.95.95.97.117.116.111.95.112.111.108.105.99.101.114.95.116.101.109.112.108.97.116.101.95.49.95.95.20.95.95.112.111.108.105.99.101.114.95.116.109.112.108.95.95.45.102.99.48.3

to convert oid to textual representation we must firs separate major oid part:
SNMPv2-SMI::enterprises.2636.3.5.2.1.5.
what we have left now is:
27.95.95.97.117.116.111.95.112.111.108.105.99.101.114.95.116.101.109.112.108.97.116.101.95.49.95.95.20.95.95.112.111.108.105.99.101.114.95.116.109.112.108.95.95.45.102.99.48.3
first digit here represents string length - that is 27 characters.
then, we have string itself:
95.95.97.117.116.111.95.112.111.108.105.99.101.114.95.116.101.109.112.108.97.116.101.95.49.95.95
every number here represents decimal ascii character code from
http://www.asciitable.com/:
95="_"
97="a"

after converthig all 27 character codes to letters we have the following string:
__auto_policer_template_1__

then goes oid separator "." and next we procceed with the following sub-oid by the same scheme.

it's up to you to check translation problems or you can wait untill this weekend or next monday...
[url=http://forums.cacti.net/viewtopic.php?t=24934&highlight=zond]zond plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?t=28384]memorize plugin[/url]
[url=http://forums.cacti.net/viewtopic.php?p=141322#141322]transporter plugin[/url]
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

In juniper-policer-64.php

Adding :
$index = str_replace('.enterprises.2636.3.5.2.1.5.',"",$index);
after :
$index = str_replace($oids["indexes"].".","",$indexOid);

solved the problem.
Now it works pretty well, thank you for your time and assistance.
Cacti user
tim-atl
Posts: 3
Joined: Sun Aug 31, 2008 9:11 am

Post by tim-atl »

Hi John,

Thanks for the great script/template. I had to make a couple changes to get it working on a Centos 4.6 (if that makes a difference) install:

Cacti kept choking on content type: txt/html. I fixed that by adding the -q flag to /usr/bin/php in juniper-policer-64.xml

Functions V2 also required a change but I'm unsure if I was supposed to but it fixed my problem.

around Line 117 (I made some edits and line numbers may be off), there was a reference to function str_split I changed it to str_splt and all is well.

Thx,

Tim
tim-atl
Posts: 3
Joined: Sun Aug 31, 2008 9:11 am

Post by tim-atl »

I'm having a new problem, it was there from the start but I didn't realize.

I'm using cacti .87b and php 4.3.9, assuming that's important.

The numbers on my graphs just don't match up with what I see in the router, after a bit of investigation, it looks like juniper-policer-64.php is stripping the first two digits of the snmp response:

/usr/bin/php -q /var/www/cacti/scripts/juniper-policer-64.php x.x.x.x "1::XXXXXXXXX::::::MD5::::DES::" get ByteCount "DNS-SERVICE-IN-ge-7/0/9.98-i.-hits-ge-7/0/9.98-i||2||28"
8089

When I do the query with snmpget, I see this:

snmpget -v1 -c xxxxxxxxxxx X.X.X.X .1.3.6.1.4.1.2636.3.5.2.1.5.28.68.78.83.45.83.696.73.67.69.45.73.78.45.103.101.45.55.47.48.47.57.46.57.56.45.105.31.56.53.46.50.53.53.46.49.49.50.46.48.45.104.105.116.115.45.103.101.45.55.47.48.47.57.46.57.56.45.105.2
SNMPv2-SMI::enterprises.2636.3.5.2.1.5.28.68.78.83.45.83.69.82.86.73.67.69.45.73.78.45.103.101.45.55.47.48.47.57.46.57.56.45.105.31.56.53.46.50.53.53.46.49.49.50.46.48.45.104.105.116.115.45.103.101.45.55.47.48.47.57.46.57.56.45.105.2 = Counter64: 1878089
tim-atl
Posts: 3
Joined: Sun Aug 31, 2008 9:11 am

Post by tim-atl »

This is fixed, (not by me but one of our local php guys):

Change is in the functions.php that comes with the script, not the main cacti functions.php

Old code:

Code: Select all

return trim(substr($counter,strrpos($counter,":")+2));
New code:

Code: Select all

return trim(substr($counter,strrpos($counter,":")));

Tim
terziyski
Cacti User
Posts: 93
Joined: Thu Nov 02, 2006 6:02 am
Location: Bulgaria
Contact:

Post by terziyski »

Hi, I have a problem with a different M320 router which running the same Junos version as the first router that I managed to query in Cacti:

Warning: Invalid argument supplied for foreach() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 35

Notice: Undefined variable: structure in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 59

Warning: Invalid argument supplied for foreach() in C:\Inetpub\wwwroot\cacti\scripts\juniper-policer-64.php on line 59

There is no timeouts in snmpwalk. The Junos version is [8.1R1.5]
Both routers have the same configuration except that second one has twice as much interfaces configured than the first one.
Cacti user
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests