LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-09-2009, 10:22 PM   #1
mnchur
LQ Newbie
 
Registered: Feb 2004
Location: ohio
Posts: 16

Rep: Reputation: 0
count number of used ports


I have been trying to create a superkaramba theme that shows my ports open/used at any given time. My problem comes in when I turn on transmission(bit torrent).

Bit torrent as you know uses just about every port on your comp and is making my script run its results over the size that I want so I looking for a way to lump all the ports for transmission together.

Idealy I would like to put a line in the app that has a total ports open count for transmission. here is what I have so far.

Code:
"netstat -pa --numeric-hosts |grep ':' | grep -v unix|grep -v '*'|grep -v '   - ' | sed 's/.*://' | sed 's/ .*   [0-9]/   /' | sed 's/ .*\// /' | sed 's/konqueror.*/konqueror/' | sed 's/kmail.*/kmail/' | sort -u | column -t;echo --------------------------------;nmap -F -e eth0 localhost |grep open"
I tried just greping out transmission and that works for getting rid of the problem but I would like to have some idea of just how many ports are being used by transmission. Any ideas
 
Old 02-10-2009, 01:49 PM   #2
camh
Member
 
Registered: Feb 2005
Distribution: Slack/Debian
Posts: 163
Blog Entries: 2

Rep: Reputation: 33
"netstat -pa | grep -v unix | grep transmission | wc -l" should more or less work
 
Old 02-10-2009, 02:11 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
netstat -pa | awk '$1 ~ /(tcp|udp)/ {print gensub(/.*:([^:]*$)/, "\\1", 1, $4)}'|sort -u|wc -l
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to count the number of occurrences of a process beeblequix Linux - General 3 09-18-2006 04:17 PM
count total number of lines in several files xushi Programming 5 11-12-2005 04:42 PM
Javasript to count number of mouse clicks LinuxLala Programming 3 06-17-2005 12:23 AM
C++ STL count() number of substring occurences... nyk Programming 4 06-25-2004 07:12 AM
Count number of line in a file. philipina Programming 7 03-18-2004 05:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration