Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Could you suggest improvements to my Cisco network device audit script?

by Anonymous Monk
on Dec 23, 2014 at 00:27 UTC ( [id://1111107]=note: print w/replies, xml ) Need Help??


in reply to Could you suggest improvements to my Cisco network device audit script?

That's a lot of code.

Well, as for suggestions, use perltidy. Hopefully you see why.

if (!defined $match) { print "$ip: ERROR_1\n"; print LOG "$ip: ERROR_1\n"; return; } ... if (!defined $match) { print "$ip: ERROR_13\n"; print LOG "$ip: ERROR_13\n"; return; } ... sub get_inventory { my ($ip, $t) = (@_); if (!$t->cmd('terminal length 0')) { print "$ip: Error changing terminal length\n"; print LOG "$ip: Error changing terminal length\n"; } my @show_run = $t->cmd('show run | inc hostname'); ...
Did you assemble this stuff from different sources?

Replies are listed 'Best First'.
Re^2: Could you suggest improvements to my Cisco network device audit script?
by monkerz57 (Initiate) on Dec 23, 2014 at 00:57 UTC
    Thanks for the reply. I updated the initial question code with perlTidy's output. I did google quite a bit for the ssh portion of code. I couldn't get the channel to function as I wanted using cpan's example code. The telnet portion was created from a simple telnet script a co-worker created a few years ago, however I added quite a few conditionals and login subs due to a lack of standardization within the environment. I couldn't source the tidbits if I tried, if that is what you are getting at. Thanks, Monk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1111107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-03-28 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found