2021-11-04 18:19:45

This commit is contained in:
gbaconni
2021-11-04 18:19:45 +01:00
parent bc7345eff9
commit fa96923d6f
2 changed files with 6 additions and 6 deletions

Binary file not shown.

View File

@@ -6,7 +6,7 @@
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2021/11/04 12:36:53 by gbaconni #+# #+# # # 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 () 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 () ft_disk ()
{ {
df --total -l -t ext2 -t ext3 -t ext4 -t xfs \ df --total -Bm -T -l -x tmpfs -x devtmpfs | \
| awk '/^total/ { total=$2; used=$3; pcent=$4 } END { printf "#Disk Usage: %d/%dGb (%.2f%%)\n", used * 8, (total * 8) / (1000 * 1000 * 1000), pcent; }' | 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 () 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 () ft_lastboot ()
@@ -68,7 +68,7 @@ ft_network ()
ft_sudo () ft_sudo ()
{ {
count=$(find /var/log/sudo -type f -name log | wc -l) count=$(journal _COMM=sudo | grep -c COMMAND)
echo "#Sudo : ${count} cmd" echo "#Sudo : ${count} cmd"
} }