-
-
Save TinyPoro/70cf5c59d9700f8036d4547d68a5a07a to your computer and use it in GitHub Desktop.
System usage bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Use : ss command | |
## variable for change : | |
## | |
##---------- | |
Timetemp='%H%M' | |
Time=$(date +"${Timetemp}") | |
Date=$(date +"%y%m%d") | |
Yest=$(date --date="1 day ago" +"%y%m%d") | |
#Day=$(date +"%a") | |
Path="/var/log/system_useage.log" | |
if [ $Time == "0101" ]; then | |
mv $Path $Path-$Yest && cat /dev/null > $Path | |
fi | |
(date | awk '{printf "[" $1 " " $2 " " $3 " " $6 " " $4 "]\t"}'; | |
w | grep load | awk '{printf $3 " " $4 " CPU : " $10 " " $11 " " $12 " \t"}'; | |
free -m | grep "Mem" | awk '{printf "RAM Free: " $7 " MB\t"}'; | |
/usr/sbin/ss -tn state established '( sport = :80 )' | wc -l | awk '{printf "Est_80: " $1 "\t"}'; | |
/usr/sbin/ss -tn state established '( sport = :443 )' | wc -l | awk '{printf "Est_443: " $1 "\t"}'; | |
/usr/sbin/ss -tn state syn-recv | wc -l | awk '{printf "SYN_RECV: " $1 "\t"}'; | |
/usr/sbin/ss -tn state close-wait | wc -l | awk '{printf "CLOSE_WAIT: " $1 "\n"}') >> /var/log/system_useage.log | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment