Handle “Access Gateway Appliance Console” output

0 Likes
over 8 years ago

Problem


NAM 3.1 has "Access Gateway Appliance Console":
 netcat localhost 2300

With lots of information, the problem is that its interactive mode makes it difficult to automatically collect such data.

Personally, I want to collect information about connections every so often for statistics and monitoring. How can we do this?

Solution


I made a script that simulates user interactions to get to the stats screen and immediately closes the console:
#!/usr/bin/expect -f
# Simple script to handle the output
# Of the NAM 3.1 Console
# William Vera wvera@novell.com
# 20 Feb 2013 - V.002
set timeout -1
# TCL escape character for CTR-C
set ctrl "03\r"
# Output file
log_file -noappend lagstats-app.log

spawn netcat localhost 2300
expect {
-exact "Please enter terminal type:" {
send -- "\r"
exp_continue
}
-exact "Pick a screen:" {
send -- "9\r"
exp_continue
}

-exact "Enter option:" {
send -- "9\r"
exp_continue
}

-exact "Client connection data read timeouts:" {
send $ctrl
}
}

The output is saved in the file: lagstats-app.log

As you can see the output is a bit "dirty", so we need a little extra work to get what we need.

Clean up!
tail -1 lagstats-app.log | sed -e "s/^M//g;s/\x00//g" > final-log.txt

Notice: "^M" is CTRL V Enter

Check:
$ cat final-log.txt

Connection Statistics                                                           

Total allocated connections 1458
Number of connections in use: 1155
Idle client persistent connections: -599
Idle server persistent connections: 1087
Total allocated send ECBs: 0
Total allocated request blocks: 300
Number of receive ECBs in use: 0
Number of ICP UDP ECBs in use: 0
Number of DNS UDP ECBs in use: 0
Server Received: 34,980,875,094 bytes, Sent: 141,350,429,652 bytes
Client Sent: 34,117,764,984 bytes, Received: 134,399,196,562 bytes
Client data retransmits: 0 Server data retransmits: 0
Server If-Modified-Since requests: 2405665 Not-Modified replies: 2332539
Client If-Modified-Since requests: 24356 Not-Modified replies: 24027
TCP send callback failures: 0
Total connections throttled: 1603
Current connections throttled: 0
Total connections refused: 0
Total requests on persistent connections refused: 0
Server connection data read timeouts: 0
Client connection data read timeouts: 0

Voilá

Ready for a cron or integrate it with other scripts.
Comment List
Anonymous
Related Discussions
Recommended