LinuxQuestions.org
Help answer threads with 0 replies.
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 11-28-2005, 05:16 AM   #1
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Rep: Reputation: 31
getting pid of iptables!!


Hi to all,

i would like to know how to get the pid of iptables which is running on a machine. I want to know what %CPU is it using? I tried with the top command but got only a long list of pids and other stuffs..

Is there a better way to know this?

Warm regards,
Visham
 
Old 11-28-2005, 05:47 AM   #2
sjoerdvvu
LQ Newbie
 
Registered: Nov 2005
Location: the Netherlands
Distribution: Ubuntu, Mandrake, DSL
Posts: 24

Rep: Reputation: 15
ps -p (list process by PID)

check for more options:

http://linux.about.com/od/commands/l/blcmdl1_ps.htm
 
Old 11-28-2005, 07:12 AM   #3
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
Iptables is only used to control the kernel's packet filtering. It only runs when you set or modify your rules with it, after which it terminates. It's the kernel itself that does the actual filtering. So actually iptables runs only a very brief time, it doesn't really consume your system resources (or at least the amount is insignificant).

Last edited by alienDog; 11-28-2005 at 07:14 AM.
 
Old 11-29-2005, 12:09 AM   #4
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Hi to all,

Quote:
ps -p (list process by PID)
I did check this but i didn't find that of iptables process...how is it called? Do you find it on your system? If it's the kernel that does the filtering, then under what kernel process name does it come?

Quote:
So actually iptables runs only a very brief time, it doesn't really consume your system resources (or at least the amount is insignificant).
When i use the "top" command, i get values for user, system, idle...in which of these categories will the iptables process fall (user or system?)? How can I know the % of CPU usage of the packet filtering process?

Many thx for your repiles..

Warm regards,
Visham
 
Old 11-29-2005, 01:13 AM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
As was said above, iptables is just a frontend for the netfilterstuff that runs in the kernel. It is not its own process. I'm not sure if there's any really good way to get performance stats for it. In recent kernels that support kprobes I imagine you could work up something that would give you performance metrics, but beyond that I'm not sure if there's a way. As a general rule, unless you have a really large (hundreds or thousands of rules) the overhead of packet filtering is next door to nothing.

Beyond that I'm just not sure, although doiung a Google search for iptables performance measuring shows some results that may be helpful.
 
Old 11-29-2005, 11:08 AM   #6
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
Quote:
Originally posted by btmiller
Beyond that I'm just not sure, although doiung a Google search for iptables performance measuring shows some results that may be helpful.
Actually it's netfilter performance measurings that you're looking for, of course

--edit--

Maybe this would be helpful: http://people.netfilter.org/kadlec/nftest.pdf


Last edited by alienDog; 11-29-2005 at 11:24 AM.
 
Old 12-01-2005, 01:37 AM   #7
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
To Aliendog: Many thx for the link..really interesting document...and yes you are right, it's the performance of netfilter that i'm looking for.

I tried using top command (top -b -d 1 > /etc/file1) and stored the outputs in a file.

I found that the % for system increased during the filtering and i'm using this as performance results.

What do you think sbt it?

Regards,
Visham
 
Old 12-01-2005, 03:24 PM   #8
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
How big increase are you talking about and with what kind of ruleset?
 
Old 12-01-2005, 09:32 PM   #9
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Fo the ruleset i simply put 1000 rules in the filter table of the forward chain. For example:

/sbin/iptables -A FORWARD -i eth0 -o eth0 -s 192.167.10.1 -d 192.125.10.99 -j ACCEPT

I changed the src & dst ip addresses to get 1000 rules. I'm using a restrictive iptables firewall, with all policies set to drop. Then i place the rule that will accept the packet last.

When I have 1000 rules, I get a maximum increase of 78.4 % (on avr it's 50%)
When I have 2000 rules, I get a maximum increase of 95.5 % (on avr it's 90%)

Before filtering began, the % system CPU usage was 0.3 and 0.5 respectively.

I used top -b -d 1 > /home/file1 to get the results. Is there a way to get only the value for %system rather than the whole lot of porcess names and the other unwanted details?

Any comments on the results will be very much appreciated..

Warm regards,
Visham
 
Old 12-02-2005, 07:30 AM   #10
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
So your cpu usage for system is up to 95.5% with 2000 rules in the table or you get an increase of 95.5% (which would make your cpu usage% about 1.0)? Prior case would sound a lot to me, but I guess it's possible if the machine that you're using as a firewall is an old one and there is a lot of network traffic.

For filtering out unwated information from top's output you could simply use grep:

top -b -d 1 | fgrep 'cpu(s):' > /etc/file1
 
Old 12-02-2005, 10:28 AM   #11
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Quote:
So your cpu usage for system is up to 95.5% with 2000 rules in the table or you get an increase of 95.5%
The CPU usage for system reaches a max of 95.5%..made a mistake in saying a max increase of 95.5%. ;-)

Quote:
guess it's possible if the machine that you're using as a firewall is an old one and there is a lot of network traffic
I'm actually using a P4, 256 MB Ram. I used iperf to generate TCP traffic, with a window size of 214KB.

MAny thx for the fgrep command hint..i thought of using grep but didn't know how to formulate the command for getting the values of the "% system" only.

Regards,
Visham

Last edited by vishamr2000; 12-02-2005 at 11:03 AM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM
rm cannot remove /var/run/atd.pid and /var/run/xdm.pid danishmr Linux - Software 1 05-04-2004 08:01 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM
iptables OUTPUT rules: DROP by process (PID)? gregory76 Linux - Security 6 07-11-2003 04:28 PM
Pid jucovschi Linux - General 3 10-02-2002 01:13 PM

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

All times are GMT -5. The time now is 09:49 AM.

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