So, I'm trying to write a script that returns the following data to Cacti:
nsVpnMonIndex
1.3.6.1.4.1.3224.4.1.1.1.1.$
nsVpnMonVpnName
.1.3.6.1.4.1.3224.4.1.1.1.4.${nsVpnMonIndex}|sed 's/[^[:alnum:]_-]//g'`
nsVpnMonIfIndex
.1.3.6.1.4.1.3224.4.1.1.1.39.${nsVpnMonIndex}
nsifSpeed
.1.3.6.1.2.1.2.2.1.5.${nsVpnMonIfIndex}
The logic is based on an existing script that was used with MRTG. I'm having trouble making sense of how to iterate multiple table requests and parse the output.
There is an existing script on the forums that gets the listed information, but it's missing the ifSpeed value, which is rather funky to get (you have to make a relationship between 1.3.6.1.4.1.3224.4.1.1.1.39 and 1.3.6.1.2.1.2.2.1.5.
If any of this doesn't make sense, it's probably because my brain hurts right now from trying to figure it out
Assistance is greatly appreciated.
Script for netscreen vpn interfaces with ifSpeed
Moderators: Developers, Moderators
- nebj00la
- Cacti User
- Posts: 112
- Joined: Fri Feb 17, 2006 9:02 pm
- Location: Massachusetts, USA
- Contact:
Script for netscreen vpn interfaces with ifSpeed
Thanks,
nebj00la
nebj00la
- nebj00la
- Cacti User
- Posts: 112
- Joined: Fri Feb 17, 2006 9:02 pm
- Location: Massachusetts, USA
- Contact:
Re: Script for netscreen vpn interfaces with ifSpeed
So I've got the following put together, and need some assistance getting the Data Query working properly:nebj00la wrote:If any of this doesn't make sense, it's probably because my brain hurts right now from trying to figure it out
Assistance is greatly appreciated.
Attached is the bash script that gathers the appropriate data from the Juniper device, and what I thought would work as an XML Data Query. Unfortunately, nothing useful is being output from the data query, whether I use input/output fields.
- Attachments
-
- netscreen.subinterfaces.xml
- Netscreen Subinterfaces XML Query - Beginnings
- (1.31 KiB) Downloaded 260 times
-
- netscreen.subinterfaces.sh
- Netscreen Subinterfaces Bash Script - (Usage <script.sh> <hostname> <community>
- (867 Bytes) Downloaded 230 times
Thanks,
nebj00la
nebj00la
- nebj00la
- Cacti User
- Posts: 112
- Joined: Fri Feb 17, 2006 9:02 pm
- Location: Massachusetts, USA
- Contact:
Here's the output of the bash script:
Code: Select all
[jtomawski@host]/scripts% ./netscreen_tunnel_interfaces.sh testhost notshowing
vpn1:0:125000000:0:0
vpn2:1:125000000:1447840704:1634286657
vpn3:2:125000000:2399037376:3980692710
vpn4:3:125000000:1790073088:3591907615
vpn5:4:125000000:1150631920:3389572220
vpn6:5:125000000:0:0
[jtomawski@host]/scripts%
Thanks,
nebj00la
nebj00la
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
I think you need an indexed query instead - the aim is to get one graph per vpn right? so the index is some identifier for each vpn (either the interface number if they are all tunnel interfaces, or the endpoint IP or something)...
For Cacti to do that, you need to write a script that understands a couple of arguments - index, num_indexes, get and query. It then presents either a list of the indexes, or the data for one of the VPNs. Then you make an XML file in resources/script_queries/ for it.
I don't know where I found example code for this, but here's one of mine:
obviously not for Netscreen VPNs, although I'd be interested to see that too
For Cacti to do that, you need to write a script that understands a couple of arguments - index, num_indexes, get and query. It then presents either a list of the indexes, or the data for one of the VPNs. Then you make an XML file in resources/script_queries/ for it.
I don't know where I found example code for this, but here's one of mine:
Code: Select all
#!/usr/bin/perl
$statsfile = "/var/tmp/cacti-adsl-bgp-counts.txt";
$max_age = 500;
$nhosts = 0;
if ( open( STATS, $statsfile ) ) {
while (<STATS>) {
chomp;
chomp;
# m/^(\S+)\s*[=:]\s*(\S+)/m ;
( $key, $meta, $value ) = ( m/^\s*(\S+)\s*([=:])\s*(\S+)/ );
if($meta eq ':') { $metadata{$key} = $value; }
if($meta eq '=') { $data{$key} = $value; $nhosts++; }
}
close(STATS);
}
if ( $ARGV[0] eq 'index' ) {
print join( "\n", sort keys %data );
exit();
}
if ( $ARGV[0] eq "query" ) {
push( @needed, sort keys %data );
}
if ( $ARGV[0] eq "get" ) {
push( @needed, $ARGV[2] );
}
if($ARGV[0] eq 'num_indexes')
{
print "$nhosts";
exit();
}
foreach $index (@needed) {
$value = 'U';
if ( $ARGV[1] eq 'hostname' ) { $value = $index; }
if ( $ARGV[1] eq 'count' ) { $value = $data{$index}; }
if ( $ARGV[0] eq 'get' ) {
print $value;
}
else {
print $index. ":" . $value . "\n";
}
}
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
- nebj00la
- Cacti User
- Posts: 112
- Joined: Fri Feb 17, 2006 9:02 pm
- Location: Massachusetts, USA
- Contact:
Thanks for the reply, Howie. Yes, an indexed query is the target. One graph per vpn. The index would simply be the subinterface index value.Howie wrote:I think you need an indexed query instead - the aim is to get one graph per vpn right? so the index is some identifier for each vpn (either the interface number if they are all tunnel interfaces, or the endpoint IP or something)...
For Cacti to do that, you need to write a script that understands a couple of arguments - index, num_indexes, get and query. It then presents either a list of the indexes, or the data for one of the VPNs. Then you make an XML file in resources/script_queries/ for it.
I understand what you're talking about, but I'll need examples and documentation on getting index, num_indexes, get and query to work in this situation. It's a bit over my head right now. I literally just started coding within the past few years, so I'm a typical code novice.
Thanks,
nebj00la
nebj00la
Re: Script for netscreen vpn interfaces with ifSpeed
Hello,
i have make a template to graph vpn tunnel stats. this template was craeted with cacti version 0.8.7d
i have make a template to graph vpn tunnel stats. this template was craeted with cacti version 0.8.7d
- Attachments
-
- tunnel_status.png (29.81 KiB) Viewed 2188 times
Last edited by md88dg on Thu Jan 27, 2011 4:09 am, edited 1 time in total.
Cacti 0.8.7g
PIA 2.8
PHP 5.1.6
MySQL 5.0.82sp1
RRDTool 1.2.23
SNMP 5.1.2
400 Hosts
4000 RRDs
8000 Data Sources
PIA 2.8
PHP 5.1.6
MySQL 5.0.82sp1
RRDTool 1.2.23
SNMP 5.1.2
400 Hosts
4000 RRDs
8000 Data Sources
-
- Posts: 5
- Joined: Mon Aug 11, 2008 9:22 am
- Location: Maryville, TN, USA
Re: Script for netscreen vpn interfaces with ifSpeed
md88dg, I tried importing the 3 xml files but I get "Error: XML: Hash version does not exist.". Is this specific to a version of Cacti? I'm using 0.8.7b.
Edit: Nevermind, hash shows your template created on newer version. Time for me to upgrade.
Edit: Nevermind, hash shows your template created on newer version. Time for me to upgrade.
Who is online
Users browsing this forum: No registered users and 3 guests