1827487 Members
2672 Online
109965 Solutions
New Discussion

Monitoring nfiles

 
SOLVED
Go to solution
leoh_1
Regular Advisor

Monitoring nfiles

How to monitor maximum nfiles used and allowed in the following SO:

- Linux
- HP-UX
- Solaris
- AIX

We are running out of nfiles and we must monitor how much we are using at a specific time and how much we have available.
6 REPLIES 6
Pete Randall
Outstanding Contributor

Re: Monitoring nfiles

In HP-UX, the easiest way to monitor nfiles is to use Glance > Reports > System Info > System Tables Report.


Pete

Pete
leoh_1
Regular Advisor

Re: Monitoring nfiles

Thank you Randall. But I need something in command line mode. I intent to create a generic monitor script that would do:

------------------
if `uname -s`=SunOS
then

total=nfiles_total_sun()
used=nfiles_used_sun()
elif `uname -s`=linux
etc etc etc
----------------




Steven E. Protter
Exalted Contributor

Re: Monitoring nfiles

Shalom,

You can run glance output to a file and then grep for the information you want.

There may be one script in my monitor set that does the job. Even if not, it will show you how to collect data and parse it.

http://www.hpux.ws/system.perf.sh

Please be patient with the performance of this site. We've had some pretty greivous hardware/networking issues over the past few months and are just coming back online with brand new Internet and routers.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ralph Grothe
Honored Contributor
Solution

Re: Monitoring nfiles

Hi Leoh,

if you have a Glance license (are there still 60 days trial versions available?) then you can get those kernel stats through Glance's adviser interface.
There's no need to run glance interactively.
Simply create a so called adviser syntax file where you would specify the metrics you are interested in
(you find a full list of available metrics including short descriptions in
/opt/perf/paperdocs/gp/C/metrics.txt
Actually, while you run glance interactively you can scan its online help (press h), go to adviser section.
There you'll find a short intro into syntax etc.
For instance if I were after available, used, and percentage usage of the system tables' nfile I could do such
(n.b. 2 iterations is the minimum, you could average in your script or discard the all except the last record)


$ echo "print tbl_file_table_avail,tbl_file_table_used,tbl_file_table_util" >/tmp/nfile.adv

$ glance -syntax /tmp/nfile.adv -j 5 -iterations 2 -adviser_only glance 2>/dev/null
248138 2925 1.2
248138 2925 1.2


As for Solaris it has a wonderful Kstat interface which unlike HP's glance you get access to for free.
But the selection of metrics is bewildering and there seems little documentation about them available.
Probably you get a reference on Solaris systems programming or look up the header files to get a grasp at?
For instance on one of our Solaris boxes I get more than 10000 metrics from kstat.

$ uname -sirmv; kstat -pl|wc -l
SunOS 5.8 Generic_108528-27 sun4us FJSV,GPUZC-M
12752

Once you have identified the metric you are interested you can narrow kstat's output by many flags you supply (see man kstat).
It can also handle regex kind of globs.

On the other hand you could get the tables from sar on both systems.

As for Linux access to kstats is very easy through the procfs.

On one of our RHEL boxes I would get the nfile stats like

$ cat /proc/sys/fs/file-nr
1110 0 206104

See "man proc" for details.



Madness, thy name is system administration
Bill Hassell
Honored Contributor

Re: Monitoring nfiles

The command:

sar -v 1

will give you the current and maximum values. If you want just the current and maximum values, use this:

sar -v 1|tail -1|awk '{print $8}'

Note that the nfile parameter should be doubled whenever it gets close to being full. nfile will always be too small for a large server that is growing is usage. Setting nfile to 50 or 100 thousand (or one million) is not a problem for HP-UX. Note that setting nfile tgo a massively lrge value will waste RAM space. Just keep the maximum value under about 70-75% full.


Bill Hassell, sysadmin
leoh_1
Regular Advisor

Re: Monitoring nfiles

Thank you all for helping. I will check all those suggestion and create a script that does what I need. Thks