Files
born2beroot/.monitoring.sh.swp

12 lines
12 KiB
Plaintext
Raw Normal View History

2021-11-04 17:34:13 +01:00
b0VIM 8.2/ <0B>a96s<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 17:34:13 +01:00
<00> <00> <00> } { @ > = / - <00><00><00><00><00>KIH:8<00><00>b`_RP"<00><00>b\/+<00><00><00><00><00>icUPG?4-)  <00><00><00><00><00><00><00><00><00><00><00><00><00><00><00>#42exit $?main $@} return 0 ft_update ft_userlog ft_tcpcon ft#42exit $?main $@} return 0 ft_update ft_userlo#42#####42exit $?main $@} return 0 ft_update ft_network ft_userlog ft_tcpcon ft_lvmused ft_lastboot ft_load ft_disk ft_memory ft_cpu ft_arch fi done sleep 3 ${0} clear do while [ 1 ] then if [ "${1}" == "-f" ] fi return 0 then if [ "${MONITORING}" != "yes" ] && [ "${1}" != "-f" ] test -f /etc/default/monitoring && source /etc/default/monitoring{main ()} rm -f ${temp} fi cat ${temp} > /usr/local/bin/monitoring.sh then if grep -q '^#42' ${temp} && bash -n ${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 "#Network: IP ${ip} (${mac})" mac=$(arp -an | awk "/${ip}/ { print \$4 }") ip=$(hostname -I | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'){ft_network ()} echo "#User log: "$(who | wc -l){ft_userlog ()} netstat -an | awk '/^tcp/ { if(/ESTABLISHED/) count++; } END { printf "#Connexions TCP : %d ESTABLISHED\n", count; }'{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 17:34:10 by gbaconni ### lausanne.ch ## Created: 2021/11/04 12:36:53 by gbaconni #+# #+# ## +#+#+#+#+#+ +#+ ## By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ ## +:+ +:+ +:+ ## monitoring.sh :+: :+: :+: ## ::: :::::::: ## ## **************************************************************************** #