-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitoring.sh
32 lines (32 loc) · 1.71 KB
/
monitoring.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
arc=$(uname -a)
pcpu=$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)
vcpu=$(grep "^processor" /proc/cpuinfo | wc -l)
fram=$(free -m | awk '$1 == "Mem:" {print $2}')
uram=$(free -m | awk '$1 == "Mem:" {print $3}')
pram=$(free | awk '$1 == "Mem:" {printf("%.2f"), $3/$2*100}')
fdisk=$(df -Bg | grep '^/dev/' | grep -v '/boot$' | awk '{ft += $2} END {print ft}')
udisk=$(df -Bm | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} END {print ut}')
pdisk=$(df -Bm | grep '^/dev/' | grep -v '/boot$' | awk '{ut += $3} {ft+= $2} END {printf("%d"), ut/ft*100}')
cpul=$(top -bn1 | grep '^%Cpu' | cut -c 9- | xargs | awk '{printf("%.1f%%"), $1 + $3}')
lb=$(who -b | awk '$1 == "sistem" {print $3 " " $4}')
lvmt=$(lsblk | grep "lvm" | wc -l)
lvmu=$(if [ $lvmt -eq 0 ]; then echo no; else echo yes; fi)
#You need to install net tools for the next step [$ sudo apt install net-tools]
ctcp=$(cat /proc/net/sockstat{,6} | awk '$1 == "TCP:" {print $3}')
ulog=$(users | wc -w)
ip=$(hostname -I)
mac=$(ip link show | awk '$1 == "link/ether" {print $2}')
cmds=$(journalctl _COMM=sudo | grep COMMAND | wc -l) # journalctl should be running as sudo but our script is running as root so we don't need in sudo here
wall " #Mimari ve Kernel Versiyonu: $arc
#Fiziksel Islemci Sayisi: $pcpu
#Sanal Islemci Sayisi: $vcpu
#RAM Miktar ve Kullanimi: $uram/${fram}MB ($pram%)
#Disk Miktari ve Kullanimi: $udisk/${fdisk}Gb ($pdisk%)
#CPU Kullanim Orani: $cpul
#Son Yeniden Baslama Tarihi: $lb
#LVM Kullanim Durumu: $lvmu
#Aktif Baglanti Sayisi: $ctcp ESTABLISHED
#Sunucuyu Kullanan K. Sayisi: $ulog
#IP ve MAC Adresi: IP $ip ($mac)
#Kullanilmis Sudo Sayısı: $cmds cmd"