SNMP OID for Active IP Connections?

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Sun Jul 02, 2006 3:17    Post subject: SNMP OID for Active IP Connections? Reply with quote
Hi, I looking for a SNMP OID for Active IP Connections, as in DD-WRT v23 SP1 control panel Status / Router / Network.
I've tried to look and search thru wiki, old & new forums and browse SNMP with Getif, but found nothing.

In the "Get temperature through snmp (OID)" thread mapas wrote about "tcp connections (active/passive)" (.1.3.6.1.2.1.6.5.0 and .1.3.6.1.2.1.6.6.0), but it doesn't work for me, these numbers do not correspond to the above mentioned counter in the web control panel -- which stands for concurrent connections, and these OIDs from mapas are counters.

So, I'm looking for the concurrent connections OIDs.
Anyone? TIA.
Sponsor
daedalus01
DD-WRT User


Joined: 07 Jun 2006
Posts: 74

PostPosted: Sun Jul 02, 2006 6:29    Post subject: Reply with quote
You could try:

RFC1213-MIB:tcpCurrEstab

OID 1.3.6.1.2.1.6.9
Type Gauge
Units
Access read-only
Status mandatory

The number of TCP connections for which the
current state is either ESTABLISHED or CLOSE-
WAIT.


I would think this would show you the number of open TCP connections.

EDIT: Actually, after doing an SNMPwalk of the device while I had the status page open, the OID 1.3.6.1.2.1.6.6.0 looks feasible. I know you mentioned that this one didn't correspond to the number of connections (was it way off or just slightly off?), but my walk value was fairly close to the numbers I was seeing on the web interface during the walk.

_________________
WPA2-RADIUS AP: DD-WRT v24 SP1 std on WRT54GS v2.1
Spare AP: DD-WRT v24 SP1 std on WRT54G v3
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Mon Jul 03, 2006 4:01    Post subject: Reply with quote
daedalus01 wrote:
You could try:

RFC1213-MIB:tcpCurrEstab

OID 1.3.6.1.2.1.6.9


This OID shows zero all the time. :(

daedalus01 wrote:
Actually, after doing an SNMPwalk of the device while I had the status page open, the OID 1.3.6.1.2.1.6.6.0 looks feasible. I know you mentioned that this one didn't correspond to the number of connections (was it way off or just slightly off?), but my walk value was fairly close to the numbers I was seeing on the web interface during the walk.


Currently (shortly after router restart) it's like 1476, while in DD-WRT UI it shows 291 concurrent active IP connections. OID you are suggesting grows indefinitely until the router is restarted. But I'm looking for immediate count ("gauge" in the language of mrtg) of concurrent IP connections, as shown in DD-WRT UI.

I've even upgraded my firmware to match yours (from your signature), but it did not help.
Thanks for your input anyway. :)

So, I'm still looking for it --
IMHO it's vital to watch this number, as the majority of us knows what happens when DD-WRT reaches the limit of "IP Filter Maximum Ports". Wink
daedalus01
DD-WRT User


Joined: 07 Jun 2006
Posts: 74

PostPosted: Mon Jul 03, 2006 6:18    Post subject: Reply with quote
It may be something as simplistic as cat'ing /proc/net/ip_conntrack and counting the number of lines it spits out, I'm not entirely sure.

You could check out the source code for the web page and see what it actually does to fine the number of connections. It may not be an SNMP OID - I'm not entirely sure.

_________________
WPA2-RADIUS AP: DD-WRT v24 SP1 std on WRT54GS v2.1
Spare AP: DD-WRT v24 SP1 std on WRT54G v3
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Tue Jul 04, 2006 2:16    Post subject: Reply with quote
daedalus01 wrote:
It may be something as simplistic as cat'ing /proc/net/ip_conntrack and counting the number of lines it spits out, I'm not entirely sure.


Yes,
Code:
wc -l /proc/net/ip_conntrack
returns the desired number, indeed.
Unfortunately I have no idea how to turn it into SNMP counter
and/or if it's a good thing to do...?
daedalus01
DD-WRT User


Joined: 07 Jun 2006
Posts: 74

PostPosted: Tue Jul 04, 2006 4:53    Post subject: Reply with quote
I know with Cacti (it sounds like you're using MRTG - I highly recommend you check out Cacti) you can poll statistics from a machine in other ways than just SNMP polls - you can run local linux scripts. There actually exists a "Unix - Get TCP Connections" Data Input Method preinstalled in Cacti. If you wanted to make your own, see Cacti's website for details on how exactly to do this.

Poke around in the /etc/snmp/snmpd.conf file to see if you can add this as an SNMP OID - I've never done it personally.

_________________
WPA2-RADIUS AP: DD-WRT v24 SP1 std on WRT54GS v2.1
Spare AP: DD-WRT v24 SP1 std on WRT54G v3
u3gyxap
DD-WRT User


Joined: 07 Jun 2006
Posts: 298

PostPosted: Tue Jul 04, 2006 17:01    Post subject: Reply with quote
.1.3.6.1.2.1.6.5.0 <-- active open connections
.1.3.6.1.2.1.6.6.0 <-- passive open connections

Good luck.
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Wed Jul 05, 2006 1:08    Post subject: Reply with quote
u3gyxap wrote:
.1.3.6.1.2.1.6.5.0 <-- active open connections
.1.3.6.1.2.1.6.6.0 <-- passive open connections


Yes, but it is not what I'm looking for, what I was asking.
u3gyxap
DD-WRT User


Joined: 07 Jun 2006
Posts: 298

PostPosted: Wed Jul 05, 2006 10:07    Post subject: Reply with quote
Well, then the only other solution I can see is writing a simple script to export the values given by
wc -l /proc/net/ip_conntrack
to the snmpd.
I don't do it with the nvram settings, I preffer jffs or smbshare. So here is how I would do it:

cat - >/jffs/ip_conntrack
#!/bin/sh
wc -l /proc/net/ip_conntrack |/usr/bin/cut -b 4-7


Ctrl+C

chmod a+rx /jffs/ip_conntrack

cat - >/jffs/etc/config/snmpd.startup
#!/bin/sh
echo "exec ip_conntrack /jffs/ip_conntrack" >> /var/snmp/snmpd.conf
killall -TERM snmpd
/usr/sbin/snmpd -c /var/snmp/snmpd.conf


Ctrl+C

chmod a+rx /jffs/etc/config/snmpd.startup

reboot

At this point, if I am not wrong, it should appear somewhere around

1.3.6.1.4.1.2021.8.1.101.1

Use GetIf to determine the wright OID.
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Fri Jul 07, 2006 7:40    Post subject: Reply with quote
That's it, u3gyxap! Thank you indeed! :)

One minor problem may arise when there's less than 1000 connections, since cut -b 4-7 embeds at least one space then. So I'd rather use sed -n $= /proc/net/ip_conntrack.
And because I have no jffs at the time, I'm using the following as a startup script (defined thru UI: Administration / Commands / Save Startup). Maybe someone will find it useful:

Code:
#!/bin/sh
cd /tmp/var/snmp
grep count_ip_conntrack < snmpd.conf || echo "exec count_ip_conntrack \
  /bin/sed -n $= /proc/net/ip_conntrack" >> /var/snmp/snmpd.conf
killall -TERM snmpd
/usr/sbin/snmpd -c /var/snmp/snmpd.conf


(I hope I didn't do anything bad here, but, you know, should it brick someone's router, don't blame me please.)

And let me thank u3gyxap one more time! Smile
pazuzu
DD-WRT Novice


Joined: 04 Jul 2006
Posts: 44

PostPosted: Fri Jul 07, 2006 15:45    Post subject: Reply with quote
Why not use

wc -l /proc/net/ip_conntrack | awk '{print $1}'

_________________
D-link DI-524 -> DD-WRT v23sp1 WRT54GS v2 client bridge -> DD-WRT v23sp1 WRT54GS v1 AP and Apple AirPort Graphite base station bridge
MortyGarfa
DD-WRT Novice


Joined: 02 Jul 2006
Posts: 10

PostPosted: Sat Jul 08, 2006 0:30    Post subject: Reply with quote
pazuzu wrote:
Why not use

wc -l /proc/net/ip_conntrack | awk '{print $1}'


Well, you mean use wc -l /proc/net/ip_conntrack | awk '{print $1}' instead of /bin/sed -n $= /proc/net/ip_conntrack, right?
I don't know if it would be more efficient, but a) my method executes only one executable each time SNMP is queried, and b) when I put piped command directly in snmpd.conf it didn't work.
xtdv
DD-WRT Novice


Joined: 04 Mar 2010
Posts: 8

PostPosted: Fri Jan 04, 2013 6:36    Post subject: Reply with quote
MortyGarfa wrote:
pazuzu wrote:
Why not use

wc -l /proc/net/ip_conntrack | awk '{print $1}'


Well, you mean use wc -l /proc/net/ip_conntrack | awk '{print $1}' instead of /bin/sed -n $= /proc/net/ip_conntrack, right?
I don't know if it would be more efficient, but a) my method executes only one executable each time SNMP is queried, and b) when I put piped command directly in snmpd.conf it didn't work.


I found a better command:
Code:
grep -c tcp /proc/net/ip_conntrack

for the number of active TCP connections, use the command below for active UDP connections:
Code:
grep -c udp /proc/net/ip_conntrack


Hope this helpful.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum