Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
snmpnetstat -v 1 -c xxx -an -P tcp <target>
Active Internet (tcp) Connections (including servers)
Proto Local Address Foreign Address (state)
tcp *.443 *.* LISTEN
...
tcp 127.0.0.1.80 *.* LISTEN
tcp 127.0.0.1.1024 *.* LISTEN
tcp 127.0.0.1.1024 127.0.0.1.4327 ESTABLISHED
tcp 127.0.0.1.1024 127.0.0.1.4329 ESTABLISHED
tcp 127.0.0.1.1024 127.0.0.1.4331 ESTABLISHED
tcp 127.0.0.1.1024 127.0.0.1.4332 ESTABLISHED
tcp 127.0.0.1.4312 127.0.0.1.8989 ESTABLISHED
tcp 127.0.0.1.4324 127.0.0.1.8989 ESTABLISHED
tcp 127.0.0.1.4325 127.0.0.1.8989 ESTABLISHED
tcp 127.0.0.1.4327 127.0.0.1.1024 ESTABLISHED
tcp 127.0.0.1.4329 127.0.0.1.1024 ESTABLISHED
tcp 127.0.0.1.4331 127.0.0.1.1024 ESTABLISHED
tcp 127.0.0.1.4332 127.0.0.1.1024 ESTABLISHED
tcp 127.0.0.1.4532 *.* LISTEN
tcp 127.0.0.1.8989 *.* LISTEN
tcp 127.0.0.1.8989 127.0.0.1.4312 ESTABLISHED
tcp 127.0.0.1.8989 127.0.0.1.4324 ESTABLISHED
tcp 127.0.0.1.8989 127.0.0.1.4325 ESTABLISHED
tcp 127.0.0.1.18196 *.* LISTEN
tcp 127.0.0.1.18281 *.* LISTEN
tcp 127.0.0.1.65535 *.* LISTEN
I've rewritten this shell script with perl to make it usable for windows guys as well. It will not use any temporary file.
Please put the script into <path_cacti>/scripts and import the XML as usual. Exporting was done using cacti 0.8.6g; you'll need that version at minimum when importing. Attention! Please check your RRA definitions after importing! I'm currently using non-standard RRAs! Attention! On busy servers, this perl script will run for "some" time. I decided to upper the Settings->Poller->Script and Script Server Timeout Value to 50 seconds
Attention
On some busy server, I noticed that the execution of snmpnetstat will take considerable time. This may required changes of some Settings -> Poller items (Script and Script Server Timeouts). As I'm not aware of the internals of snmpnetstat on the remote host, this may require your attention.
Reinhard
There is the problem in template, after import the template, I found the running command is
D:\Perl\bin\perl G:/ROOT/WEB/home.ausmis.com/cacti/scripts/lvm_netstat_tcp.pl 192.168.1.10 2 public 161 500
and I got error like this :
Invalid version: 2
Usage: snmpnetstat [options...] hostname [interval]
NET-SNMP version: 5.2
-v [1 | 2c ] SNMP version
-V display version number
-c community specify community name
-t timeout SNMP packet timeout (seconds)
-i show interfaces with packet counters
-o show interfaces with octet counters
-r show routing table
-s show general statistics
-n show IP addresses, not names
-a show sockets in LISTEN mode too
-P proto show only details for this protocol
-I interface show only this interface
-d dump packets
-Ddebugspec
established:0 listen:0 timewait:0 timeclose:0 finwait1:0 finwait2:0 synsent:0 synrecv:0 closewait:0
once I change the data input method by fix value or add 'c', then it's works...
i have used this script in windows 2000k cacti server and i m using cmd.php as poller.i could add this for few servers where no of connections was low but when i create graph for big servers poller almost hangs. what should i do??
dust2k wrote:There is the problem in template, after import the template, I found the running command is
D:\Perl\bin\perl G:/ROOT/WEB/home.ausmis.com/cacti/scripts/lvm_netstat_tcp.pl 192.168.1.10 2 public 161 500
and I got error like this :
Invalid version: 2
This will require some investigation, as snmp_version is a cacti built-in variable, that should yield 2c when choosing SNMP Version 2 from dropdown.
Reinhard
anuraganuj wrote:i have used this script in windows 2000k cacti server and i m using cmd.php as poller.i could add this for few servers where no of connections was low but when i create graph for big servers poller almost hangs. what should i do??
Please run the snmpnetstat from command line. I suppose, this will take a lot of time as I stated above. I'm not aware of any fact that would make it faster. Supression of DNS name lookup (option: -n) is already given.
Reinhard
lvm wrote:This will require some investigation, as snmp_version is a cacti built-in variable, that should yield 2c when choosing SNMP Version 2 from dropdown.
Reinhard
I guess so, but don't know the value is 2 not 2c, but anyway, so far my script is running alright. thanks for your great work.
i am able to create graph for my squid server which is not busy. i m using cmd.php as poller in win2k but when i use this graph some time poller gives error which is attached . also graphs starts cutting in between.
poller doesnt run properly.pls help i want this graph badly
I used this perl scripts, but I cant get the ESTABLISTHED connections.
snmpnetstat -v 1 -c public -t 500 -an -P tcp 127.0.0.1:161
Active Internet (tcp) Connections (including servers)
Proto Local Address Foreign Address (state)
tcp *.111 *.* LISTEN
tcp *.199 *.* LISTEN
tcp *.3306 *.* LISTEN
tcp *.32768 *.* LISTEN
tcp 127.0.0.1.25 *.* LISTEN
tcp 127.0.0.1.631 *.* LISTEN
the above question hs been resolved . I guess it only occurs in localhost when using snmpwalk.
now another question , how can get connection information from IPV6?
some program such as ssh and apache will make its listening port showed with IPV6 format.
tcp 0 0 :::80 :::* LISTEN 2527/httpd
tcp 0 0 :::22 :::* LISTEN 1983/sshd
such infos cant be gotten from normal snmpnetstat.
I searched how to get these infos through snmpnetstat, but I failed.
if someone can get it, please show yr methods, thanks ~
I had exactly the same problem as dust2k. The snmp_value is actually "2" in the log, and not "2c" as it should be. Changing this value in the script seems to rectify this issue, although now I'm not able to poll data from SNMP 1 hosts.
Does anyone have any idea as to why this is ?
Thanks
Cacti Version 0.8.8b Cacti OS Ubuntu LTS RRDTool Version RRDTool 1.4.7 Poller Information Type SPINE 0.8.8b