user count access

2007-12-25 10:46:00

Hello Sun-Managers,

here is my first summary concerning "user count access". First I'd like to thank

everyone who responded so far. These were (in no order):

        MOHD ROSLEY OMAR e-mail: rosley@tsi.com.my

         Hahn Kyu Chung e-mail: hchung@cems.umn.edu

        Kevin Sheehan e-mail: Kevin.Sheehan@uniq.com.au

        Sanjiv K. Bhatia e-mail: sanjiv@aryabhat.umsl.edu

        Roland Grefer e-mail: btirg@ui.uis.doleta.gov

        Chad Smith e-mail: chad@sequana.com

        Marty Bullock e-mail: Marty.Bullock@sea.siemens.com

        Amaresh R. Joshi e-mail: joshia@com.msu.edu

Thanks to all the other who will respond after composing this summary, but now

I'd like to present the results I recieved so far :

============================================

Mohd Rosley Omar wrote :

   you can try this simple script I wrote, it's not a good script, but it

   served the purpose...

==============BEGIN SCRIPT===================

#!/bin/sh

xxx=$1

rm /tmp/__X.tmp 1>/dev/null 2>/dev/null

rm /tmp/___X.tmp 1>/dev/null 2>/dev/null

ps -eadf | grep "$xxx" | awk '{printf("%s %s %s %s\n",$1,$2,$6,$8)}'

>/tmp/__X.t

mp

cat /tmp/__X.tmp | grep $xxx | awk

'{printf("\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4)}'

> /tmp/___X.tmp

num_user=`cat /tmp/___X.tmp | wc -l`

echo "\n"

echo "There is $num_user user using $xxx"

echo "---------------------------------------------------------"

cat /tmp/___X.tmp

echo "---------------------------------------------------------"

================END SCRIPT===================

just change the mode to executable and run it with the argument,

since I didn't put the argument checking in there... :)

example:

========

host# chmod 755 getamount

host# getamount mosaic

There is 6 user using mosaic

---------------------------------------------------------

        nobody 232 ? /mosaic2/httpd2

        root 230 ? /mosaic2/httpd2

        nobody 234 ? /mosaic2/httpd2

        nobody 235 ? /mosaic2/httpd2

        nobody 236 ? /mosaic2/httpd2

        nobody 237 ? /mosaic2/httpd2

---------------------------------------------------------

host#

================================================

Hahn Kyu Chung wrote :

You might want to try looking at a program called lsof. If it isn't

on your system you should be able to download the source for it

somewhere.

===================================================

Kevin Sheehan wrote :

The command to list mounts doesn't really tell you who is using it with

NFS unfortunately.

The standard solution is to mv command command- ; cp command+ command

This allow people running the old executable to use the same node (mv

doesn't change that), and anybody who runs it anew gets the new copy.

That way you don't modify a running copy and confuse things.

====================================================

Sanjiv K. Bhatia wrote :

If you keep statistics on the commands that can be seen by the lastcomm

command, it will be straightforward to write the script by using things like:

        lastcomm | sort | awk '{print $1}' | uniq -c | sort -n -r

This will give you the usage count on all the commands sorted in decreasing

order of usage. To get additional information, you may have to write a short

script.

=======================================================

Roland Grefer wrote :

[translated and summarized]

Try : /etc/fuser [-u] dateiname1 dateiname2 ...

without the -u you'll only get the PIDs.

==========================================================

Chad Smith wrote :

This may not be the solution you are looking for, but I've found that by

writing wrapper scripts in the place of common executables, you can freely

change/remove/update those executables without the users ever knowing.

Its a somewhat rare practice, since it takes a lot of work to write the

scripts, but it works rather nifty if implemented correctly.

==============================================================

Marty Bullock wrote :

Try "fuser -u". You can probably filter the output in a script to dowhat you

want

===============================================================

Amaresh R. Joshi wrote :

perhaps i'm misunderstanding what you're asking, but why

can't you just use "ps", say like

alias getamount='ps -ecf | grep'

then on my system:

joshia@leech 165$ getamount ksh

   richs 11049 11047 TS 58 10:22:25 pts/1 0:00 -ksh

  joshia 11168 11166 TS 38 13:13:06 pts/0 0:00 -ksh

you could format it further if you wanted. is that

what you were asking?

// :) The formatting will do a small script, I am sure, so thanks a lot for your

// advice. I will work out your idea and tell you want I did by sending you a

// e-mail, if you want me to.

To all of you : Thanks again for your answers. As I am busy in the next three

weeks I need some time to work out all of your ideas and will summarize the

results. Even some NEW IDEAS are welcome, I will summarize them seperately if

they get too much or will summarize them with my results.

THIS LIST IS FAST AND PROFESSIONAL, I am very impressed.

Best regards

Juergen Schultz

stud. cand. Diplominformatiker (FH)

Comments

Got something to say?

You must be logged in to post a comment.