Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 32 lines (29 sloc) 1.21 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/bin/bash
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this
# program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301, USA.
#
# Change Log
#----------------
# 11-Jan-2012 - stevenpan@gmail.com
# Initial revision
#

if [ $# -ne 2 ]; then
    echo "usage: $0 hostname snmp-community-string"
    exit 3
fi

host=$1
comm=$2

snmpwalk -v2c -c$comm $host tcpConnState |awk '{
sub(/\([0-9][0-9]*\)/,"",$NF)
a[$NF]+=1
}
END {
#for(j in a)print j,a[j] >> "/var/tmp/awk.debug"
printf "TCP Connection State OK | closed=%d;;; listen=%d;;; synSent=%d;;; synReceived=%d;;; established=%d;;; finWait1=%d;;; finWait2=%d;;; closeWait=%d;;; lastAck=%d;;; closing=%d;;; timeWait=%d;;; deleteTCB=%d;;; \n",a["closed"],a["listen"],a["synSent"],a["synReceived"],a["established"],a["finWait1"],a["finWait2"],a["closeWait"],a["lastAck"],a["closing"],a["timeWait"],a["deleteTCB"]
}'
Something went wrong with that request. Please try again.