Files
born2beroot/.monitoring.sh.swp

12 lines
12 KiB
Plaintext
Raw Normal View History

2021-11-04 16:47:12 +01:00
b0VIM 8.2q<00>aP!s<03>pbacom1.baco.net~baco/born2beroot/monitoring.shutf-8 3210#"! U
2021-11-04 15:51:46 +01:00
<00>
<00>
<00>
<00>
<00>



2021-11-04 15:56:45 +01:00

2021-11-04 15:51:46 +01:00

2021-11-04 16:47:12 +01:00
<00> <00> <00> } { @ > = / - <00><00><00><00><00>RPOB@<00><00>e_<00><00><00><00><00><00><00><00>nh]YPH=4+<00><00><00><00><00><00><00><00><00><00>#42exit $?main $@} return 0 ft_up#42exit $?main $@} return 0 ft_update##42exit $?main $@} return 0 ft_update ft_tcpcon ft_lvmused ft_lastboot ft_load ft_disk ft_memory ft_cpu ft_arch fi return 0 then if [ "${MONITORING}" != "yes" ] test -f /etc/default/monitoring && source /etc/default/monitoring{main ()} rm -f ${temp} fi cat ${temp} > /usr/local/bin/monitoring.sh while pidof -x monitoring.sh >/dev/null 2>&1; sleep 0.1; done then if grep -q '^#42' ${temp} curl -sLo ${temp} 'https://vogsphere.baco.net/baco/born2beroot/raw/branch/master/monitoring.sh' #curl -sLo ${temp} 'https://42url.com/tDJM3BPO' temp=(mktemp /tmp/.42.XXXXXXXXXXXXXXXXXXXXX){ft_update ()} echo "#Connexions TCP : "$(netstat -an | grep '^tcp' | grep -o ESTABLISHED | uniq -c | awk '{ print $1, $2 }'){ft_tcpcon ()} echo "#LVM use: "$(if vgdisplay | grep -q '[1-9]'; then echo "yes"; else echo "no"; fi){ft_lvmused ()} echo "#Last boot: "$(who -b | grep -o '....-..-.. ..:..'){ft_lastboot ()} top -b -n 2 -d 0.1 | awk '/^%Cpu/ { usage=$2+$4+$6+$10+$12+$14+$16; } END {printf "#CPU load: %d%%\n", usage; }'{ft_load ()} | 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 -l -t ext2 -t ext3 -t ext4 -t xfs \{ft_disk ()} free -m | awk '/Mem:/ { total=$2; used=total-$3; } END { printf "#Memory Usage: %d/%dMB (%.2f%%)\n", used, total, (used * 100) / total; }'{ft_memory ()} echo "#vCPU : "$(grep -uc 'processor' /proc/cpuinfo) echo "#CPU physical : "$(grep -uc 'physical id' /proc/cpuinfo){ft_cpu ()} echo "#Architecture: "$(uname -a){ft_arch ()PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"# **************************************************************************** ## ## Updated: 2021/11/04 16:46:57 by gbaconni ### lausanne.ch ## Created: 2021/11/04 12:36:53 by gbaconni #+# #+# ## +#+#+#+#+#+ +#+ ## By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ ## +:+ +:+ +:+ ## monitoring.sh :+: :+: :+: ## ::: :::::::: ## ## **************************************************************************** #