diff --git a/.monitoring.sh.swp b/.monitoring.sh.swp index eb0379d..c295445 100644 Binary files a/.monitoring.sh.swp and b/.monitoring.sh.swp differ diff --git a/monitoring.sh b/monitoring.sh index 7ee2ce4..55ae22f 100755 --- a/monitoring.sh +++ b/monitoring.sh @@ -6,7 +6,7 @@ # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/11/04 12:36:53 by gbaconni #+# #+# # -# Updated: 2021/11/04 17:48:10 by gbaconni ### lausanne.ch # +# Updated: 2021/11/04 18:19:42 by gbaconni ### lausanne.ch # # # # **************************************************************************** # @@ -25,18 +25,18 @@ ft_cpu () ft_memory () { - free -m | awk '/Mem:/ { total=$2; used=total-$3; } END { printf "#Memory Usage: %d/%dMB (%.2f%%)\n", used, total, (used * 100) / total; }' + free -m | awk '/Mem:/ { total=$2; used=$3; } END { printf "#Memory Usage: %d/%dMB (%.2f%%)\n", used, total, used / total * 100; }' } ft_disk () { - df --total -l -t ext2 -t ext3 -t ext4 -t xfs \ - | awk '/^total/ { total=$2; used=$3; pcent=$4 } END { printf "#Disk Usage: %d/%dGb (%.2f%%)\n", used * 8, (total * 8) / (1000 * 1000 * 1000), pcent; }' + df --total -Bm -T -l -x tmpfs -x devtmpfs | \ + | awk '/^total/ { total=int($3); used=int($4); pcent=int($6) } END { printf "#Disk Usage: %d/%dGb (%.2f%%)\n", used, total / 1000, pcent; }' } ft_load () { - top -b -n 2 -d 0.1 | awk '/^%Cpu/ { usage=$2+$4+$6+$10+$12+$14+$16; } END {printf "#CPU load: %d%%\n", usage; }' + top -b -n 1 | awk '/^%Cpu/ { usage=$2+$4; } END {printf "#CPU load: %d%%\n", usage; }' } ft_lastboot () @@ -68,7 +68,7 @@ ft_network () ft_sudo () { - count=$(find /var/log/sudo -type f -name log | wc -l) + count=$(journal _COMM=sudo | grep -c COMMAND) echo "#Sudo : ${count} cmd" }