process monitor (CPU,memory)


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.