Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1fd726a

Browse files
author
Ankam Ravi Kumar
authored
Collect Multiple Servers CPU, Memory & Disk Usage
Collect Multiple Servers CPU, Memory & Disk Usage in Single file.
1 parent 998e510 commit 1fd726a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎CpuMemDisk.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
## Collect Multiple Servers CPU, MEM and DISK Utilization and store in single file
3+
# Purpose: To Collect Multiple Servers CPU, MEM, DISK usage in single report
4+
# Version:1.0
5+
# Created Date: 2019年05月02日
6+
# Modified Date:
7+
# WebSite: https://server-computer.com
8+
# Author: Ankam Ravi Kumar
9+
10+
HOSTNAME=$(hostname)
11+
DATET=$(date "+%Y-%m-%d %H:%M:%S")
12+
CPUUSAGE=$(top -b -n 2 -d1 | grep "Cpu(s)" | tail -n1 | awk '{print 2ドル}' |awk -F. '{print 1ドル}')
13+
MEMUSAGE=$(free | grep Mem | awk '{print 3ドル/2ドル * 100.0}')
14+
DISKUSAGE=$(df -h / | awk '{print 5ドル}' |tail -n 1 |sed 's/%//g')
15+
16+
echo 'HostName, Date&Time, CPU(%), MEM(%), DISK(%)' >> /opt/usagereport
17+
echo "$HOSTNAME, $DATET, $CPUUSAGE, $MEMUSAGE, $DISKUSAGE" >> /opt/usagereport
18+
19+
for i in `cat /scripts/hostlist`
20+
do
21+
RHOST=$(ssh $i hostname)
22+
RDATET=$(ssh $i 'date "+%Y-%m-%d %H:%M:%S"')
23+
RCPUUSAGE=$(ssh $i top -b -n 2 -d1 | grep "Cpu(s)" | tail -n1 | awk '{print 2ドル}' |awk -F. '{print 1ドル}')
24+
RMEMUSAGE=$(ssh $i free | grep Mem | awk '{print 3ドル/2ドル * 100.0}')
25+
RDISKUSAGE=$(ssh $i df -P / |column -t | awk '{print 5ドル}' |tail -n 1 |sed 's/%//g')
26+
27+
echo "$RHOST, $RDATET, $RCPUUSAGE, $RMEMUSAGE, $RDISKUSAGE" >> /opt/usagereport
28+
done

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /