Operating System - Linux
1751971 Members
4585 Online
108783 Solutions
New Discussion юеВ

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

 
SOLVED
Go to solution
Yogeeraj_1
Honored Contributor

How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

Dear Experts!

I need to monitor the system (RHEL4-U5) so as to determine if the NPROC for the oracle user has been properly set.

In fact, I will need to gather resource usage data and plot a graph on its utilisation over a period of time. What is the best way to do so?

[root@server home]# grep -i nproc /etc/security/limits.conf
# - nproc - max number of processes
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
oracle soft nproc 2047
oracle hard nproc 16384
[root@server home]#

Thanking you in advance for replies.

kind regards,
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
5 REPLIES 5
Ivan Ferreira
Honored Contributor

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

I'm not sure why you want to graph a file that should not change, you could audit/checksum/tripwire the file. But anyway, to graph a file, you could use MRTG + External Monitoring Scripts:

http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
TwoProc
Honored Contributor

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

I think you want the results of the "ps -au " command.

So, if you wanted to check all of the users defined in the limits.conf file;

I wrote the following script as a starting point. Here's an example run of user "john" running 2 processes and user "squid" running nothing:

> /tmp/get_procs
john:
hard 20
soft 10
actv 2
squid:
hard 18
soft 10
actv 0

If you want single line output:

> /tmp/get_procs -l
john: hard 20 soft 10 actv 2
squid: hard 18 soft 10 actv 0

If you want the above data usable for graphing in an Excel or Open Office spreadsheet, just put in "|" pipe delimiters, or "," commas (your preference) in the output instead of " " spaces.

Then, just put it in a cron job, accumulating the data into a file somewhere of your choosing. Of course, you'd need to log rotating tool to clean it up every day (See the HPUX Porting Archives).

The script has a dependency that you are consistent in the order of putting in soft and hard limits. Also, it doesn't work for the "grouping" function of the security file, because in your example, it looked like your just interested in user "oracle" at the time.

Here's whats in my security file:
john hard nproc 20
john soft nproc 10
squid hard nproc 18
squid soft nproc 10

Here's the bash script:
It's a bit klunky at points, and could be cleaned up, but it's what I could do in a hurry.
-----------------------------------------
#!/bin/bash
#
# get_procs - gets process info about items secured by /etc/security/limits.conf
#
# Args: if a "-l" is passed as the first argument, it returns a single line
# display per user defined in security file.


ONELINE=FALSE
if [ $# -gt 0 ]; then
if [ $1 = "-l" ]; then
ONELINE=TRUE
fi
fi


get_procs() {
if [ $ONELINE = "FALSE" ]; then
for i in `grep -v "^#" /etc/security/limits.conf | cut -d " " -f 1| sort | uniq`
do
echo $i:
cat /etc/security/limits.conf | grep "^${i}" | awk '{ print " "$2" "$4}'
echo " "actv `ps -eo user | grep $i| wc -l`
done
else
TMPFILE=/var/tmp/get_procs.$$
if [ -f $TMPFILE ] ; then
rm -f $TMPFILE || ( echo Error deleting $TMPFILE ; exit 1)
fi
for i in `grep -v "^#" /etc/security/limits.conf | cut -d " " -f 1| sort | uniq`
do
echo $i: > $TMPFILE|| ( echo Error creating $TMPFILE ; exit 2)
grep "^${i}" /etc/security/limits.conf | awk '{ print $2" "$4}' >> $TMPFILE
echo actv `ps -eo user |grep $i | wc -l` >> $TMPFILE
set `cat $TMPFILE`
echo $1 $2 $3 $4 $5 $6 $7 $8 $9
rm -f $TMPFILE || ( echo Error deleting $TMPFILE ; exit 3)
done
fi
}

get_procs


----

Hope that helps,

John
We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

Yogeeraj,

It seems that I didn't quite answer your question - What else are you looking for? Do you need help with an example scripts for comma delimited? Cron example? Let us know.
We are the people our parents warned us about --Jimmy Buffett
Stuart Browne
Honored Contributor
Solution

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

When you exceed the limits, the user gets warnings set to it's TTY (Resource temporarily unavailable). I poked through logs and couldn't find it anywhere, so I upped the log levels to see what I could find.. Still nothing.

What I did note however was that there is no 'soft' nproc limit. Both 'soft' and 'hard' references are hard (well, when spawning from 'bash').

Perhaps just graphing the output of the simple command:

ps -U oracle -ocmd= | wc -l

will suffice (You can use that command with MRTG as mentioned above).
One long-haired git at your service...
Yogeeraj_1
Honored Contributor

Re: How to monitor if my NPROC has been undersized in the /etc/security/limits.conf

hi John and Stuart!

Sorry for this late feedback on your replies.

Our main concern is making sure that the NPROC has been properly set. Being rather "new" to the use of Linux at the Enterprise/Production level, my knowledge of resource monitoring at the OS level is rather limited. I thought there was some utility that would easily help me collect the required data.

In fact, i am already using NMON for monitoring of the server resources.

Well, plotting of the data into a meaningful graph using a particular tool is not really of the concern here.


I think "ps -U oracle -ocmd= | wc -l" as mentioned by Stuart will do for the moment ...unless there is something better...

thanking you all for your replies and also those who had a glance at my post too.


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)