2021-11-05 14:52:47

This commit is contained in:
gbaconni
2021-11-05 14:52:47 +01:00
parent c7ef36054a
commit 87e82749df
2 changed files with 39 additions and 18 deletions

View File

@@ -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
}

View File

@@ -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
}