Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

OID for network topology

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

OID for network topology

L4 Transporter

Hi,

 

I got one request where the client is asking about the OID for L2/L3 topology and arp cache table.

 

I checked the following article but it doesn't have any reference for the above.

 

https://live.paloaltonetworks.com/t5/Management-Articles/SNMP-for-Monitoring-Palo-Alto-Networks-Devi...

 

Appreciate your help!

 

Regards,

Sharief

Regards,
Sharief
1 accepted solution

Accepted Solutions

L2 Linker

I’m not sure what you mean with L2/L3 topology, but (as far as I know!) there’s no OID for reading the ARP cache. That’s why I created a perl script to do this.

 

Im using Cacti to graph the arp cache and alerts on to high by 90% of total (see this post), but maybe you can use the script for other monitoring tools?

 

The script uses the PAN-OS XML API, and can read the arp cache, the number of sessions, the number of user's found by user-id and the throughput, but can easily be extended.

 

Good luck!

 

use strict;
use warnings;
use URI::Escape;
use LWP::UserAgent;  
use HTTP::Request;
use XML::LibXML;

my $type        = $ARGV[0]; 
my $hostname    = $ARGV[1]; 
my $apikey    = $ARGV[2]; 

my $command;
if($type eq "arp")          {$command = "<show><arp><entry name='all'/></arp></show>";}
elsif($type eq "userid")    {$command = "<show><user><ip-user-mapping><all><option>count</option></all></ip-user-mapping></user></show>";}
else                        {$command = "<show><session><info></info></session></show>";}
 
my $urlcommand	= uri_escape($command);
my $URL		= 'https://'.$hostname.'/api/?type=op&key='.$apikey.'&cmd='.$urlcommand;

my $xml_string;

my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $header = HTTP::Request->new(GET => $URL);  
my $request = HTTP::Request->new('GET', $URL, $header);  
my $response = $ua->request($request);  

if ($response->is_success){  
        $xml_string = $response->content;
}
elsif ($response->is_error){  
        print "Error:$URL\n";  
        print $response->error_as_HTML;  
}

my $parser = XML::LibXML->new();
my $xmlfile = XML::LibXML->load_xml(string => $xml_string);

if($type eq "arp") {
	my($node) = $xmlfile->findnodes('/response/result/max');
	my $max=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/total');
	my $total=$node->textContent();
	print "max:".$max." total:".$total."\n";
}
elsif($type eq "userid") {
	my($node) = $xmlfile->findnodes('/response/result');
	my $userids=$node->textContent();
	$userids =~ s/"users"/""/g;
	my $userid = substr $userids, 7, length($userids)-15, "";
	print "userids:".$userid."\n";
}
elsif($type eq "sessions") {
	my($node) = $xmlfile->findnodes('/response/result/num-max');
	my $max=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-active');
	my $active=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-tcp');
	my $tcp=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-udp');
	my $udp=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-icmp');
	my $icmp=$node->textContent();
	print "max:".$max." active:".$active." tcp:".$tcp." udp:".$udp." icmp:".$icmp."\n";
}
else {
	my($node) = $xmlfile->findnodes('/response/result/kbps');
	my $throughput =$node->textContent();
	print "throughput:".$throughput."\n";
}

 

 

View solution in original post

1 REPLY 1

L2 Linker

I’m not sure what you mean with L2/L3 topology, but (as far as I know!) there’s no OID for reading the ARP cache. That’s why I created a perl script to do this.

 

Im using Cacti to graph the arp cache and alerts on to high by 90% of total (see this post), but maybe you can use the script for other monitoring tools?

 

The script uses the PAN-OS XML API, and can read the arp cache, the number of sessions, the number of user's found by user-id and the throughput, but can easily be extended.

 

Good luck!

 

use strict;
use warnings;
use URI::Escape;
use LWP::UserAgent;  
use HTTP::Request;
use XML::LibXML;

my $type        = $ARGV[0]; 
my $hostname    = $ARGV[1]; 
my $apikey    = $ARGV[2]; 

my $command;
if($type eq "arp")          {$command = "<show><arp><entry name='all'/></arp></show>";}
elsif($type eq "userid")    {$command = "<show><user><ip-user-mapping><all><option>count</option></all></ip-user-mapping></user></show>";}
else                        {$command = "<show><session><info></info></session></show>";}
 
my $urlcommand	= uri_escape($command);
my $URL		= 'https://'.$hostname.'/api/?type=op&key='.$apikey.'&cmd='.$urlcommand;

my $xml_string;

my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $header = HTTP::Request->new(GET => $URL);  
my $request = HTTP::Request->new('GET', $URL, $header);  
my $response = $ua->request($request);  

if ($response->is_success){  
        $xml_string = $response->content;
}
elsif ($response->is_error){  
        print "Error:$URL\n";  
        print $response->error_as_HTML;  
}

my $parser = XML::LibXML->new();
my $xmlfile = XML::LibXML->load_xml(string => $xml_string);

if($type eq "arp") {
	my($node) = $xmlfile->findnodes('/response/result/max');
	my $max=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/total');
	my $total=$node->textContent();
	print "max:".$max." total:".$total."\n";
}
elsif($type eq "userid") {
	my($node) = $xmlfile->findnodes('/response/result');
	my $userids=$node->textContent();
	$userids =~ s/"users"/""/g;
	my $userid = substr $userids, 7, length($userids)-15, "";
	print "userids:".$userid."\n";
}
elsif($type eq "sessions") {
	my($node) = $xmlfile->findnodes('/response/result/num-max');
	my $max=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-active');
	my $active=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-tcp');
	my $tcp=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-udp');
	my $udp=$node->textContent();
	($node) = $xmlfile->findnodes('/response/result/num-icmp');
	my $icmp=$node->textContent();
	print "max:".$max." active:".$active." tcp:".$tcp." udp:".$udp." icmp:".$icmp."\n";
}
else {
	my($node) = $xmlfile->findnodes('/response/result/kbps');
	my $throughput =$node->textContent();
	print "throughput:".$throughput."\n";
}

 

 

  • 1 accepted solution
  • 1976 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!