[TriLUG] "Light" monitoring

John Vaughters jvaughters04 at yahoo.com
Fri Mar 29 12:30:44 EDT 2013


Here is a little script I use to find process hogs. It is very light weight on processor usage. I had a very similar issue to you. My server kept crashing. The issue actually ended up being heat related from a weak fan and the processor would downgrade and build up, so even though I was looking for a process that was causing the issue, when I could find no over offending process, I ended up monitoring the temperature, which is another issue. Not all cpu's support that.

Usage: ./ps_cpu_usage.sh .0 10 >> process_hogs &

# This script will list the processes that are taking up resources when the 1 min uptime is larger than $1
# $2 is the interval to check processes
# The process will run until killed
#!/bin/bash
echo $$
while true
do
  min_usage=$(uptime | cut -d ":" -f 5 | cut -d "," -f 1 | sed 's/ //g')
  list_ps=$(echo "${min_usage} > ${1}" | bc)
  if [ $list_ps -eq 1 ]; then # Use bc to compare real values in bash
     ps aux | awk ' $3 >0.0 ' | awk ' {print d " " $3 " "  $11}' "d=$(date)"
  fi
  if [ "$2" == "" ]; then
    t_delay="30"
  else
    t_delay="$2"
  fi
  sleep $t_delay
done



________________________________
 From: Brian McCullough <bdmc at buadh-brath.com>
To: Triangle Linux Users Group General Discussion <trilug at trilug.org> 
Sent: Friday, March 29, 2013 12:10 PM
Subject: Re: [TriLUG] "Light" monitoring
 
On Fri, Mar 29, 2013 at 08:57:27AM -0700, John Vaughters wrote:
> +1 on Monit, simple and light weight. However, for even more basic information on really skinny embedded systems, consider "uptime" for cpu load and "free" for memory usage. You can easily script that and send it to another computer for analysis. 

That latter was what I started as a roll-your-own solution.  I was
wondering about what was recommended, though.


More information about the TriLUG mailing list