Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu May 23, 2019 10:03 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: tcp connections script
PostPosted: Thu Mar 30, 2006 1:42 pm 
Offline

Joined: Thu Mar 30, 2006 1:37 pm
Posts: 5
hi,

just put this quick hack of a script together so i can monitor the state of tcp connections.

it's quick n' dirty.

J


Attachments:
File comment: sample graph
tcp_connections.png
tcp_connections.png [ 50.13 KiB | Viewed 47345 times ]
File comment: graph template
bash script
sample graph

tcp-connections.zip [53.09 KiB]
Downloaded 9527 times
Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:57 pm 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22376
Location: Muenster, Germany
Am I right assuming this one works for localhost only?
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 2:01 pm 
Offline

Joined: Thu Mar 30, 2006 1:37 pm
Posts: 5
hi,

actually, it will do remote hosts too.

it uses snmpnetstat from the net-snmp package to get netstat-like output on a remote host via snmp - a very cool tool.

J


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 7:18 am 
Offline
Cacti User

Joined: Thu Feb 16, 2006 9:20 am
Posts: 98
On which snmp devices is it working ?

Cisco? Unix?

Thanks

Qwertz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 8:16 am 
Offline
Cacti Guru User
User avatar

Joined: Fri Sep 19, 2003 8:36 am
Posts: 2326
Location: Sophia-Antipolis, France
Hi

I assumed it works only with Ucd/Net-SNMP, available for Unix & Win32.

However, testing it with a Cisco 2700 router gives an anwser :
Code:
$ snmpnetstat -v 1 -c yyyyyy xxx.xxx.xxx.xxx  -an -P tcp
Active Internet (tcp) Connections (including servers)
Proto Local Address                Foreign Address              (state)
tcp    xxx.xxx.xxx.xxx.179            xxx.xxx.xxx.xxx.63919           ESTABLISHED
Active Internet (udp) Connections
Proto Local Address
udp    xxx.xxx.xxx.xxx.161
udp    xxx.xxx.68.10.49
udp    xxx.xxx.68.10.67
udp    xxx.xxx.68.10.123
udp    xxx.xxx.68.10.162
udp    xxx.xxx.68.10.1967
udp    xxx.xxx.68.10.49862
udp    xxx.xxx.68.10.50414
udp    xxx.xxx.68.10.55884

_________________

HOWTOs :
Templates :


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 9:28 am 
Offline

Joined: Thu Mar 30, 2006 1:37 pm
Posts: 5
it should work for any snmp-capable device.

i haven't tested on any network equipment specifically, but it works against net-snmp (linux), MS SNMP (windows xp, windows 2003).

from the output of the previous post, it should work on cisco too.

I will try to clean up the script a little so it's more dynamic (accpets snmp version for example).

feel free to post results (success/failure) of devices in your environment.

J


Top
 Profile  
 
 Post subject: not getting output
PostPosted: Tue Apr 18, 2006 7:18 am 
Offline
Cacti User

Joined: Tue Feb 21, 2006 9:50 am
Posts: 70
hi

i am a windows CACTI user.I downloaded this script and installed bash shell for windows
I can see tmp file in tmp directory getting data from snmpnetstat very well
I have grep,wc for windows in place.
but the graph shows -1 for all variables pls help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 7:30 am 
Offline

Joined: Thu Mar 30, 2006 1:37 pm
Posts: 5
Hi,

there's a new (better) version of this script here:

http://forums.cacti.net/about12787.html

it's written in perl and does not generate any tmp files.

if you want to use my (hacky) shell version, it sounds like you're missing the snmpnetstat tool, or that it's not in your path or something. make sure you have snmpnetstat.exe, and that it's in your path, or edit the script to point directly at it.

i.e., edit this line:

snmpnetstat -v 2c -c $2 -Can -Cp tcp $1 > $TMPDIR/$1

to something like:

/path/to/snmpnetstat -v 2c -c $2 -Can -Cp tcp $1 > $TMPDIR/$1


thx,

J


Top
 Profile  
 
 Post subject: Cacti log
PostPosted: Tue Apr 18, 2006 7:57 am 
Offline
Cacti User

Joined: Tue Feb 21, 2006 9:50 am
Posts: 70
i can see files getting generated snmpnetstat is executing properly

Cacti log file says

CMDPHP: Poller[0] Host[161] DS[583] WARNING: Result from CMD not
valid. Partial Result: established: 29 list


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 7:58 am 
Offline

Joined: Thu Mar 30, 2006 1:37 pm
Posts: 5
what happens when you run the script by hand?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2010 4:34 am 
Offline

Joined: Tue Jun 30, 2009 4:00 am
Posts: 14
Hi there,

First of all very usefull for me except the fact that it dosent graph tcp6.

get_connection_stats.pl -H xxx -c xxx
closed:0 closing:0 timeWait:0 deleteTCB:0 listen:3 synSent:0 synReceived:0 established:6 finWait1:0 finWait2:0 closeWait:0 lastAck:0


When I look at the server with a netstat -an I see lots more:

tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 127.0.0.1:50992 ESTABLISHED
tcp 0 0 127.0.0.1:5432 127.0.0.1:45245 ESTABLISHED
tcp 0 0 127.0.0.1:5432 127.0.0.1:46596 ESTABLISHED
tcp 0 0 127.0.0.1:5432 127.0.0.1:54418 ESTABLISHED
tcp 0 0 127.0.0.1:5432 127.0.0.1:48768 ESTABLISHED
tcp 0 0 127.0.0.1:5432 127.0.0.1:50234 ESTABLISHED
tcp6 0 0 :::42436 :::* LISTEN
tcp6 0 0 :::2575 :::* LISTEN
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
tcp6 0 0 :::40281 :::* LISTEN
tcp6 0 0 :::34972 :::* LISTEN
tcp6 0 0 :::7676 :::* LISTEN
tcp6 0 0 ::ffff:127.0.0.1:58409 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:39943 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:48792 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:54811 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:56832 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:33332 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:33888 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:39943 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:58409 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:59213 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:54811 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:35770 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:33332 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:42275 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:50234 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:57238 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:48768 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:48792 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:54418 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:57519 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:44880 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:56038 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:59213 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:46926 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:57377 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:35203 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:35203 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:33888 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:35770 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:57519 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:57377 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:50992 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:57238 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:44880 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:56832 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:56038 ESTABLISHED
tcp6 0 0 ::ffff:10.145.1.38:22 ::ffff:10.152.10.:57388 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:47411 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:47411 ::ffff:127.0.0.1:40281 ESTABLISHED
tcp6 0 792 ::ffff:10.145.1.38:22 ::ffff:10.200.11.1:3887 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:46596 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:40281 ::ffff:127.0.0.1:46926 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:45245 ::ffff:127.0.0.1:5432 ESTABLISHED
tcp6 0 0 ::ffff:127.0.0.1:42275 ::ffff:127.0.0.1:40281 ESTABLISHED
udp 0 0 127.0.0.1:32768 127.0.0.1:32768 ESTABLISHED


Top
 Profile  
 
 Post subject: Re: tcp connections script
PostPosted: Thu Dec 01, 2011 9:22 am 
Offline

Joined: Thu Dec 01, 2011 9:18 am
Posts: 6
thank you so much , it was working well


Top
 Profile  
 
 Post subject: Re: tcp connections script
PostPosted: Thu Mar 15, 2012 11:26 pm 
Offline

Joined: Mon Feb 13, 2012 8:09 pm
Posts: 1
Howto use this script & template ?
I put script into scripts directory, change path in the template
where i must change host & community ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


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 post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group