mirror of
https://github.com/techarkit/shell-scripting-tutorial.git
synced 2025-07-25 01:28:51 +00:00
Create systemload.sh
This commit is contained in:
19
systemload.sh
Normal file
19
systemload.sh
Normal 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
|
Reference in New Issue
Block a user