Fetch ipsec Tunnel in/out octets with SNMP

Download Template
Simple bash script to retrieve ingress and egress traffic statistics for an ipsec tunnel.

akonkol
February 16, 2012



#!/usr/bin/bash
tunnel_oid=`snmpwalk -v 2c  -c %{snmp_community}% %{headend_ip}% 1.3.6.1.4.1.9.9.171.1.2.3.1 |grep %{remote_peer}% | awk -F'.' '{print $10}' | awk '{print $1}'`

in_oct=`snmpget -v 2c -c %{snmp_community}% %{headend_ip}% 1.3.6.1.4.1.9.9.171.1.2.3.1.19.$tunnel_oid | awk '{print $4}'`
out_oct=`snmpget -v 2c -c %{snmp_community}% %{headend_ip}% 1.3.6.1.4.1.9.9.171.1.2.3.1.27.$tunnel_oid | awk '{print $4}'`

You must be logged in to comment.