Posted By

blackthorne on 03/04/10


Tagged

alert process monitor blackthorne


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

blackthorne


process monitor (CPU,memory)


 / Published in: Bash
 

generates CSV log file with CPU and memory usage as metrics for a desired process . May easily be adapted to multiple processes or to fire alerts for defined limits

  1. #!/bin/bash
  2. TIME_UNIT=60
  3. PROCESS="SQLSubscriber"
  4. LOG_FILE="/var/log/ap/sql_subscriber.log"
  5. while [ 1 ]; do sleep $TIME_UNIT; MEM=`ps -eo cmd,pcpu,rss|grep -i $PROCESS|grep -v grep|awk '{print $4","$5}'`; echo `date +"%m-%d-%Y %H:%M:%S"`,$MEM >> $LOG_FILE; done

Report this snippet  

You need to login to post a comment.