Handle “Access Gateway Appliance Console” output

Handle “Access Gateway Appliance Console” output


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?


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"
-exact "Pick a screen:" {
send -- "9\r"

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

-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

$ 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


Ready for a cron or integrate it with other scripts.
Labels (2)


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
5 of 5
Last update:
‎2020-01-31 22:11
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.