Create systemload.sh

This commit is contained in:
Ankam Ravi Kumar
2019-02-24 21:42:45 +05:30
committed by GitHub
parent ae460aa25e
commit 583da457ee

19
systemload.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
##################################################
# #
# Author: Ankam Ravi Kumar #
# Website: server-computer.com #
# Date: 23-02-2019 16:59:56 #
# Purpose: Capture and Store System Load Average #
# CPU Usage and Memory Usage #
##################################################
# Log File Path
LOGFILE=/var/log/systemload.log
HOSTNAME=$(hostname)
DATE=$(date "+%d-%m-%Y %H:%M:%S")
SYSTEMLOAD=$(uptime | awk '{ print $8,$9,$10,$11,$12}')
CPULOAD=$(top -b -n 2 -d1 | grep "Cpu(s)" | tail -n1 |awk '{print $2}')
MEMORYUSAGE=$(free -m |grep Mem: |tail -n1 |awk '{print $2,$3}')
echo "$DATE $HOSTNAME LoadAverage: $SYSTEMLOAD CPU: $CPULOAD Memory: $MEMORYUSAGE" >> $LOGFILE