LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-07-2014, 07:25 AM   #1
kumartnj
LQ Newbie
 
Registered: Apr 2009
Posts: 15

Rep: Reputation: 0
Post Difference between Apache processes & connections ( netstat )


Hi All,

Need someone help here

I need to know the difference between the below 2 commands and the output

[xxx@yyy ~]$ netstat -an | grep 8009 | wc -l
93

[xxx@yyy ~]$ ps -ef | grep apache | wc -l
39

Thanks in advance !

Regards
Kumar
 
Old 04-07-2014, 05:41 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Code:
[xxx@yyy ~]$ netstat -an
As unprivileged user list all network connections and disable name resolution (that's good)

Code:
| grep 8009
grep the output for the arbitrary string "8009" (no explanation so here that could be a port or inode number or part of a name of a socket)

Code:
 | wc -l
count the output lines



Code:
[xxx@yyy ~]$ ps -ef
As unprivileged user full-format list all processes (a lot of people haven't heard of 'pgrep' or the "-C" arg of 'ps')

Code:
 | grep apache
grep the output for the arbitrary string "apache" (that could be any part of a user or process or file name or argument)

Code:
 | wc -l
count the output lines


If you want to count all TCP/8009 ports that aren't in use (listening) or closing down (any *_WAIT states) you could use 'lsof -Pwln -iTCP:8009 -sTCP:ESTABLISHED|wc -l'.
Counting process names "/usr/sbin/httpd" could be 'pgrep httpd|wc -l' or in BASH: 'PIDS=($(\ps --no-header -C httpd -o pid)); echo ${#PIDS[@]};'.

Last edited by unSpawn; 04-07-2014 at 05:42 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trace number of connections & threads in apache server sushantchawla2005 Linux - Server 3 05-16-2010 08:23 AM
netstat has tones of localhosts connections??? crypted Linux - Server 3 04-15-2010 12:21 PM
netstat - killing connections? Sir P Linux - Server 4 08-07-2009 04:01 PM
Difference Between Apache 2.0 & 2.2 chnlinux Linux - Newbie 1 12-14-2007 09:04 AM
Difference between Tomcat 1.5&1.6 and Apache 2.1 & 2.2 chnlinux Linux - Newbie 1 12-04-2007 09:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:17 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