Discussion:
COMMAND datasource to read number of connections on port via smnpnetstat
jeronimo
2013-03-14 03:20:16 UTC
Permalink
jeronimo [http://community.zenoss.org/people/jeronimo] created the discussion

"COMMAND datasource to read number of connections on port via smnpnetstat"

To view the discussion, visit: http://community.zenoss.org/message/72411#72411

--------------------------------------------------------------
Just thought other people might find this useful.  I wanted to build a COMMAND datasource that would pull in the number of users connected to a given port.  I came up with this, which works on Windows or Linux:

/bin/echo {\"values\": {\"\": {\"users\":`snmpnetstat -Cp tcp -Cn -v2c -cpublic ${here/manageIp} | pcregrep "tcp +\d+\.\d+\.\d+\.\d+\.80 .+ ESTABLISHED" | wc -l`}}}

You need to add a COMMAND datasource and set the Parser to JSON.  For a different port, just change the "80" above to whatever port you want.   You could also look for different statuses than "ESTABLISHED" such as "TIMEWAIT" or "CLOSEWAIT".  You could also tweak the IP address regexp "\d+\.\d+\.\d+\.\d+" to pin it down to just certain IPs.

Beyond that, snmpnetstat is also handy as a Zenoss user command (the kind that pop from the button, such as "ping", "traceroute", etc.)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72411#72411]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...