Shell Script for script to log the cpu and memory usage of linux processes - Printable Version +- Hackonology Forums (https://hackonology.com/forum) +-- Forum: Technology & Configuration (https://hackonology.com/forum/forumdisplay.php?fid=3) +--- Forum: Configuration Scripts (https://hackonology.com/forum/forumdisplay.php?fid=6) +--- Thread: Shell Script for script to log the cpu and memory usage of linux processes (/showthread.php?tid=166) |
Shell Script for script to log the cpu and memory usage of linux processes - SysAdmin - 02-17-2021 REDIS_PID=$(ps -ef | grep redis | grep -v grep | awk '{print $2}') LOGSTASH_PID=$(ps -ef | grep logstash | grep -v grep | awk '{print $2}') ELASTICSEARCH_PID=$(ps -ef | grep elasticsearch | grep -v grep | awk '{print $2}') KIBANA_PID=$(ps -ef | grep kibana | grep -v grep | awk '{print $2}') LOG_FILE=/var/log/user/usage.log echo $LOG_FILE top -b | awk -v redis="$REDIS_PID" -v logstash="$LOGSTASH_PID" '/redis|logstash/ {print $1","$9","$10","$12}' |