Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A little convenient script to calculate the percentage of vnodes used' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A little convenient script to calculate the percentage of vnodes used
Authored by: sx1 on Jul 19, '03 04:21:09AM

The maxvnodes tip is useful but it's all in the fine tuning. Here's a little script that calculates how many vnodes are used as a percentage of the maximum vnodes. I put it in /usr/local/bin/vnodeusage. I found it invaluable when tweaking the maxvnodes value.

#!/bin/tcsh
# returns the percentage of vnodes used

set vnodesused=`pstat -T | grep vnodes | sed 's/vnodes//' `
set vnodesmax=`sysctl kern.maxvnodes | sed 's/kern.maxvnodes = //'`

set result=`expr $vnodesused \* 100 / $vnodesmax`
echo "${result}% used"

Enjoy!



[ Reply to This | # ]
sh version
Authored by: gatorparrots on Jul 20, '03 01:40:07AM
Here's an sh version (repeat after me: I will not script in tcsh, I will not script in tcsh...) that uses awk instead of sed:
#!/bin/sh
# returns percentage of maxvnodes used
vnodes=$(pstat -T |awk '/vnodes/ {print $1}')
maxvnodes=$(sysctl kern.maxvnodes | awk '{print $3}')
echo "$(expr $vnodes \* 100 / $maxvnodes)% used"


[ Reply to This | # ]
A little convenient script to calculate the percentage of vnodes used
Authored by: tegbains on Jul 20, '03 07:19:04PM

There is a mistake on the second to last line:

It was: set result=`expr $vnodesused * 100 / $vnodesmax`

But should be: set result=`expr $vnodesused \* 100 / $vnodesmax`

Corrected code is below:
__

#!/bin/tcsh
# returns the percentage of vnodes used

set vnodesused=`pstat -T | grep vnodes | sed 's/vnodes//' `
set vnodesmax=`sysctl kern.maxvnodes | sed 's/kern.maxvnodes = //'`

set result=`expr $vnodesused \* 100 / $vnodesmax`
echo "${result}% used"

___

---
___
Teg Bains



[ Reply to This | # ]