Getting the hostname is easy enough, get gethostbyname. The router type and IOS version are going to be more tricky.
The safest way would be to set up your SNMP environment correctly, and then ask the router to send you its 'system.sysDescr.0' OID. There are loads of ways to do this with Perl, but I don't know which way would suit you. Start by looking at Net::SNMP.
Another way would be to open up a telnet session with the router and ask it to tell you.
When I used to play with Cisco routers I was quite happy with Net::Telnet::Cisco. It's pretty simple to use if you're familiar with Net::Telnet or Expect. In a nutshell, if you can craft a command (e.g.: get version, you can get what you are looking for.
Shamelessly stealing from the documentation, an example of how you would go about this would look like:
use Net::Telnet::Cisco;
my $session = Net::Telnet::Cisco->new(Host => '123.123.123.123');
$session->login('login', 'password');
# Execute a command
my @output = $session->cmd('show version');
print @output;
# Enable mode
if ($session->enable("enable_password") ) {
@output = $session->cmd('show privilege');
print "My privileges: @output\n";
} else {
warn "Can't enable: " . $session->errmsg;
}
$session->close;
This approach is of course only as safe as your network. I would hope you use an account/password pair that has no privileges to change the routers' configurations.
print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u' |