Skip to content

Commit 583da45

Browse files
author
Ankam Ravi Kumar
authored
Create systemload.sh
1 parent ae460aa commit 583da45

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

systemload.sh

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

0 commit comments

Comments
 (0)