From 87e82749df08040b38ee37bd2c0a9479462619ab Mon Sep 17 00:00:00 2001 From: gbaconni Date: Fri, 5 Nov 2021 14:52:47 +0100 Subject: [PATCH] 2021-11-05 14:52:47 --- bootstrap.sh | 4 ++-- monitoring.sh | 53 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index f35823a..2a8226d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -6,7 +6,7 @@ # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/11/04 10:58:16 by gbaconni #+# #+# # -# Updated: 2021/11/04 13:40:11 by gbaconni ### lausanne.ch # +# Updated: 2021/11/05 14:51:22 by gbaconni ### ########.fr # # # # **************************************************************************** # @@ -91,7 +91,7 @@ ft_monitoring () user=${1-marvin} curl -sLo /usr/local/bin/monitoring.sh 'https://42url.com/tDJM3BPO' chmod 0755 /usr/local/bin/monitoring.sh - echo "*/10 * * * * root /usr/local/bin/monitoring.sh 2>/dev/null | fold -w 80 | wall -n" > /etc/cron.d/monitoring + echo "*/10 * * * * root /usr/local/bin/monitoring.sh -w" > /etc/cron.d/monitoring echo "MONITORING=yes" > /etc/default/monitoring } diff --git a/monitoring.sh b/monitoring.sh index 1a43172..0ea0564 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 18:23:28 by gbaconni ### lausanne.ch # +# Updated: 2021/11/05 14:52:43 by gbaconni ### ########.fr # # # # **************************************************************************** # @@ -84,22 +84,8 @@ ft_update () rm -f ${temp} } -main () +ft_dashboard () { - test -f /etc/default/monitoring && source /etc/default/monitoring - if [ "${MONITORING}" != "yes" ] && [ "${1}" != "-f" ] - then - return 0 - fi - if [ "${1}" == "-f" ] - then - while [ 1 ] - do - clear - ${0} - sleep 3 - done - fi ft_arch ft_cpu ft_memory @@ -112,6 +98,41 @@ main () ft_network ft_sudo ft_update +} + +ft_loop () +{ + while [ 1 ] + do + clear + ${0} + sleep 3 + done +} + +ft_wall () +{ + test -f /etc/default/monitoring && source /etc/default/monitoring + if [ "${MONITORING}" != "yes" ] + then + return 0 + fi + ft_dashboard | sed 's/^/ /' | cut -c-75 | wall +} + +main () +{ + case "${1}" in + -f) + ft_loop + ;; + -w) + ft_wall + ;; + *) + ft_dashboard + ;; + esac return 0 }