I am trying to get the total number of active NAT sessions on a CISCO ASR1004 device.
Currently, I only know to get this information via logging into the console and running 'show ip nat statistices'.
In order to add this to a monitoring system (cacti and icinga), I created a script that does the same, but it's a nasty hack and sometimes (one time in 8 or 10) stalls out and sits waiting for nothing.
If someone can either direct me to an SNMP item for this stat (I can't seem to find one in all the MIBS I have) or a way to make my scripts more stable, I would appreciate it very much :D
active_nats.sh
#!/bin/sh
output=$(/opt/mon/all_nat_stats.sh $1 | grep "Total active translations:" | awk '{print $4}')
echo -n "$output"
all_nat_stats.sh
#!/bin/bash
set ipaddr [lrange $argv 0 0]
set timeout -1
spawn ssh monitor@$ipaddr show ip nat statistics
match_max 100000
expect -timeout 2 "yes/no" {send "yes\r"; exp_continue}
expect "*?assword:*"
send -- "<password>\r"
send -- "\r"
expect eof