CPU temperature embedded in Bash command prompt
https://askubuntu.com/questions/779819/cpu-temperature-embedded-in-bash-command-prompt
Filesystem Size Used Avail Use% Mounted on /dev/hdb1 20G 14G 5.5G 71% / tmpfs 394M 4.1k 394M 1% /dev/shm /dev/hdb5 29G 27G 654M 98% /nas/www
$ df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }'
71% /dev/hdb1 98% /dev/hdb5
#!/bin/sh df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do echo $output usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usep -ge 90 ]; then echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" you@somewhere.com fi done
# cp diskAlert /etc/cron.daily/
# chmod +x /etc/cron.daily/diskAlert
crontab -e
10 0 * * * /path/to/diskAlert
#!/bin/sh # set -x # Shell script to monitor or watch the disk space # It will send an email to $ADMIN, if the (free available) percentage of space is >= 90%. # ------------------------------------------------------------------------- # Set admin email so that you can get email. ADMIN="root" # set alert level 90% is default ALERT=90 # Exclude list of unwanted monitoring, if several partions then use "|" to separate the partitions. # An example: EXCLUDE_LIST="/dev/hdd1|/dev/hdc5" EXCLUDE_LIST="/auto/ripper" # #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # function main_prog() { while read output; do #echo $output usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1) partition=$(echo $output | awk '{print $2}') if [ $usep -ge $ALERT ] ; then echo "Running out of space \"$partition ($usep%)\" on server $(hostname), $(date)" | \ mail -s "Alert: Almost out of disk space $usep%" $ADMIN fi done } if [ "$EXCLUDE_LIST" != "" ] ; then df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}' | main_prog else df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}' | main_prog fi
# User specific environment and startup programs
servIP=`ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` REMOTE_USER=`whoami` REMOTE_IP=`who am i` CUTIP=${REMOTE_IP%)*} CUTIP=${CUTIP##*(}
curl -X POST -H 'Authorization: Bearer [LINE-TOKEN ที่ได้มาจากขั้นตอนก่อนหน้า]' -F 'message=Server "'"$servIP"'" have SSH login via IP "'"$CUTIP"'" by user "'"$REMOTE_USER"'" ' https://notify-api.line.me/api/notify