keyongtech


  keyongtech > shell > 06/2006

 #1  
06-02-06, 12:50 PM
NoE
Hello all,
first let me apologize if you find this question too stupid to post it
to this group :-)
I have some problem with swap space utilization and for this reason I
would like to log some information from lsof command.
I would like to parse lsof output line by line, take the first field
(command column of output table) and pick up only diffrrent names for
commands. Then I would like to make count for each differrent command
found - to find out how many times the command has been issued.
Thnx a lot in advance.
NoE
 #2  
06-02-06, 02:08 PM
base60
NoE wrote:
> Hello all,
> first let me apologize if you find this question too stupid to post it
> to this group :-)
> I have some problem with swap space utilization and for this reason I
> would like to log some information from lsof command.
> I would like to parse lsof output line by line, take the first field
> (command column of output table) and pick up only diffrrent names for
> commands. Then I would like to make count for each differrent command
> found - to find out how many times the command has been issued.
> Thnx a lot in advance.
> NoE
>


"man awk"
 #3  
06-02-06, 02:16 PM
NoE
>>sigh<< really helpful....

base60 wrote:
[..]
 #4  
06-02-06, 02:36 PM
NoE
oh, please. do not answer me with such guru-from-unix-heaven answers.
they are just statements, not helping at all.

base60 wrote:
[..]
 #5  
06-02-06, 03:56 PM
John L
"NoE" <dusankm> wrote in message news:3220
> Hello all,
> first let me apologize if you find this question too stupid to post it
> to this group :-)
> I have some problem with swap space utilization and for this reason I
> would like to log some information from lsof command.
> I would like to parse lsof output line by line, take the first field
> (command column of output table) and pick up only diffrrent names for
> commands. Then I would like to make count for each differrent command
> found - to find out how many times the command has been issued.
> Thnx a lot in advance.
> NoE
>


The usual idiom for counting things is to pipe them through
sort and then uniq -c (and then perhaps sort -n).

get list of things to count | sort | uniq -c | sort -n

lsof | sed 's/ .*//' | sort | uniq -c | sort -n
 #6  
06-02-06, 05:17 PM
NoE
Thnx a lot John, it proves to be so simple (I thought about loops
etc.:-) )
 #7  
06-03-06, 12:20 AM
Dan Mercer
"NoE" <dusankm> wrote in message news:3220
: Hello all,
: first let me apologize if you find this question too stupid to post it
: to this group :-)
: I have some problem with swap space utilization and for this reason I
: would like to log some information from lsof command.
: I would like to parse lsof output line by line, take the first field
: (command column of output table) and pick up only diffrrent names for
: commands. Then I would like to make count for each differrent command
: found - to find out how many times the command has been issued.
: Thnx a lot in advance.
: NoE
:

You don't have to parse the data. man lsof:

-F f This option specifies a character list, f, that selects the
fields to be output for processing by another program, and the
character that terminates each output field. Each field to be
output is specified with a single character in f. The field
terminator defaults to NL, but may be changed to NUL (000).
See the OUTPUT FOR OTHER PROGRAMS section for a description of
the field identification characters and the field output
process.

When the field selection character list is empty, all standard
fields are selected (except the raw device field and zone
field for compatibility reasons) and the NL field terminator
is used.

When the field selection character list contains only a zero
(`0'), all fields are selected (except the raw device field
for compatibility reasons) and the NUL terminator character is
used.

Other combinations of fields and their associated field termi-
nator character must be set with explicit entries in f, as
described in the OUTPUT FOR OTHER PROGRAMS section.

When a field selection character identifies an item lsof does
not normally list - e.g., PPID, selected with -R - specifica-
tion of the field character - e.g., ``-FR'' - also selects the
listing of the item.

When the field selection character list contains the single
character `?', lsof will display a help list of the field
identification characters. (Escape the `?' character as your
shell requires.)

If you google mercer and lsof you should run into some scripts I wrote
and posted.

Dan mercer
Similar Threads
Newbie question....Copy Command...

Hi All, Am running arch Linux. It only has a command mode. Am trying to copy "glib-2.6.6.tar.gz" from my CD-ROM drive into a folder named "glib" in my HD.I tried cp command...

Newbie question: comm command

Hi, I have two files: "foo1": 2 4 "foo2": 1 a

Newbie question: sed command

Hi, I want to substitute a group of equal characters at the begining of the line. For example, in the next line I want to change "aa" for "x": aaaabbaac -> xxbbaac How can...

Newbie question on mkvg command

Hi, I am a newbie to UNIX and want to know the following about the mkvg command. What is best way to determine the value for the number of megabytes in each physical...

How to use the WRITETEXT command - newbie question

Hello all and please excuse me if I am in the wrong group. I am very new to sql server and I am trying to update a ntext field. Of course I realized I couldn't do a normal...


All times are GMT. The time now is 01:49 PM. | Privacy Policy