1827801 Members
2274 Online
109969 Solutions
New Discussion

fuser counting

 
chin hyeon jung
Advisor

fuser counting

I use oracle by raw device
and some times appear message " too many users use this devices"(?) maybea
Anyway I want to know how many users use this devices
like this
oracle users=203
oracle8 users=108
root users=5
Do you have any good idea
4 REPLIES 4
Steven Sim Kok Leong
Honored Contributor

Re: fuser counting

Hi,

One way is to create a script like this (replace RAW value with your raw LV):

======================================
#!/sbin/sh

RAW=/dev/vx/dsk/rootdg/homevol

fuser -u $RAW 2>&1 | tr [")"] ["\n"] | grep \( |cut -d\( -f2 > /tmp/fuser.list
NAMES=`cat /tmp/fuser.list | sort | uniq`
for name in $NAMES
do
echo $name users=`grep $name /tmp/fuser.list |wc -l`
done
rm -f /tmp/fuser.list
======================================

Note is that fuser outputs the userids into STDERR and the process IDs into STDOUT. As such, 2>&1 is necessary to capture fuser's output in entirety.

Tested the script to work. Hope this helps. Regards.

Steven Sim Kok Leong
chin hyeon jung
Advisor

Re: fuser counting

RAW=/dev/vx/dsk/rootdg/test_vol1;fuser -u $RAW
/dev/vx/dsk/rootdg/test_vol1: 21732c(root) 21892c(root) 21654c(admin1) 21811c(root)
RAW=/dev/vx/dsk/rootdg/test_vol1;fuser -u $RAW 2>&1 | tr [")"] ["\n"]
/dev/vx/dsk/rootdg/test_vol1: 21732c(root
21893c(root
21894c(root
21654c(admin1
21811c(root
]RAW=/dev/vx/dsk/rootdg/test_vol1;fuser -u $RAW 2>&1 | tr [")"] ["\n"] | grep \( |cut -d\( -f2
root
root
root
admin1
root
root
root
Um Very interestrang
Why this happen very interestrang
Steven Sim Kok Leong
Honored Contributor

Re: fuser counting

Hi,

interestrang = interesting but strange?

The script extracts the list of process owners currently using the raw volume (you have just listed this during stepping through of the script), identifies each owner uniquely (sort | uniq)and counts the number of processes running on the raw volume for each unique user (grep ... | wc -l).

Please feel free to let me know of any clarifications you need regarding the script.

Hope this helps. Regards.

Steven Sim Kok Leong
Steven Sim Kok Leong
Honored Contributor

Re: fuser counting

Hi,

tr [")"] ["\n"]
- this replaces all ) characters with the newline, thus breaking the usernames into separate lines.

grep \(
- because there are blank lines right at the end, this is one method to clear the blank lines.

cut -d\( -f2
- this extracts just the username without the prefixed process id and ( character.

Hope this helps. Regards.

Steven Sim Kok Leong