Help with access to pix via perl script

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
st3rling
Posts: 20
Joined: Thu Mar 16, 2006 12:17 pm

Help with access to pix via perl script

Post by st3rling »

Hi,
I'm using this script posted here http://forums.cacti.net/about14410.html
What I get is message Access denied although I can telnet to the device just fine using Windows telnet and port 23. I do have @ sign in my password so I use backslash so it looks like this (example): ex\@mple
Thank you for any help!

Here is the script itself:

Code: Select all

#!/usr/bin/perl 
use Getopt::Std; # So we can do the processing of the command line options 
use IO::Socket;  # For the connection

$port = '23'; #telnet port
$timeout=20;  #connection timeout

# Process the command line options
die "Usage: $0 -r <router> -u <username> -p <password> -e <enable password>\n" if (@ARGV < 6);

exit if (!getopts('r:u:p:e:'));

$username=$opt_u;
$password=$opt_p;
$enpassword=$opt_e;
$router=$opt_r;

main();

sub main(){
	  $i=0;
    # create a tcp connection to the specified host and port
    $handle = IO::Socket::INET->new(Proto     => "tcp",
                                    PeerAddr  => $router,
                                    PeerPort  => $port,
                                    Timeout   => $timeout)
    or return (print "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nCan't connect to port $port on $router\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
		# split the program into two processes, identical twins
		die "can't fork: $!" unless defined($childpid = fork());
		# the if{} block runs only in the parent process
    if ($childpid) {
        # copy the socket to array
           while (defined ($line = <$handle>)) {
           @strings[$i] = $line;
           $i++;
                }
           kill("TERM", $childpid);
               }
# the else{} block runs only in the child process
		else {
                print $handle $username."\n" if $username; # Use a username only if there is one;
                print $handle $password."\n";
                print $handle "enable\n";
                print $handle $enpassword."\n";
                print $handle "sh uauth\n";
                print $handle "exit\n";
                close ($handle);
                exit;

}
#calculate the connected users
$i=0;
{ foreach (@strings)
    {$i++ if /authenticated/;
     }
print $i;
}
}
greginmadison
Posts: 30
Joined: Fri Mar 07, 2008 8:58 am

why run the perl script?

Post by greginmadison »

Why run this perl script, you can get the number of connections via snmp.

This should work

http://forums.cacti.net/about22261.html
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

I am using this self same template to graph connections on my PIX - works fine.

Out of interest, does the PIX allow telnet connections from your Cacti server ?

Something like

telnet 192.168.1.200 255.255.255.255 inside

Is possibly missing ?
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
st3rling
Posts: 20
Joined: Thu Mar 16, 2006 12:17 pm

Post by st3rling »

The whole network that I'm on is allowed to telnet to the PIX.

I believe those OID's don't work on PIX 7.2, at least I wasn't able to make them work....

Thank you guys for suggestions.
windsor
Posts: 24
Joined: Fri May 07, 2004 5:26 pm
Location: Texas!

Post by windsor »

I can verify that the following work on v7.x on PIX or ASA:

Interface: IF-MIB::ifIndex
free memory: .1.3.6.1.4.1.9.9.48.1.1.1.6.1
used memory: .1.3.6.1.4.1.9.9.48.1.1.1.5.1
5min cpu: .1.3.6.1.4.1.9.9.109.1.1.1.1.5.1
connections: .1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6

edit: 7.2(3) had a bug where free_mem+used_mem didn't match "show mem" figures, that is fixed in 7.2(4)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest