Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Vyg monitor

258 views

Published on

  • Be the first to comment

  • Be the first to like this

Vyg monitor

  1. 1. "################Anar Godjaev##############################" "################Vyg Manitor###############################" [ora92@dbanar ]$ cat /usr/local/bin/vyg_monitor_mail.sh SISTEMSTATE=0 DISKEXCLUDE="/usr/local/bin/vyg_monitor.sh.EXL" HOSTNAME=`hostname` SISTEMMESSAGE="$HOSTNAME : `date '+%d.%m.%Y %H:%M:%S '`" WARNINGLOAD=`cat /proc/cpuinfo |grep processor| wc -l` #4 degerden yuksek ise calisir WARNINGLOAD=$[WARNINGLOAD*2] CRITICALLOAD=$[WARNINGLOAD*3/2] # Sistem yuku bu WARNINGMEM=1 #YUZDE OLARAK BOS KISIM ICIN KULLANILIR CRITICALMEM=0 #YUZDE OLARAK BOS KISIM ICIN KULLANILIR WARNINGPROCMEM=10000000 CRITICALPROCMEM=20000000 WARNINGDISK=90 #YUZDE OLARAK DOLULUK ORANI ICIN KULLANILIR CRITICALDISK=95 #YUZDE OLARAK DOLULUK ORANI ICIN KULLANILIR ### Sistemde Cok Fazla Ram Tuketen Processi Kontrol Eder #### topmem=`ps -aux|sort -nr +3|head -1|awk '{print $6}'` if [ $topmem -gt $CRITICALPROCMEM ] then SISTEMSTATE=2 SISTEMMESSAGE="$SISTEMMESSAGE.n `hostname` sunucuda $[topmem/1024/1024] GB ram kullanan process var!!! " elif [ $topmem -gt $WARNINGPROCMEM ] then if [ $SISTEMSTATE -lt 1 ]; then SISTEMSTATE=1; fi SISTEMMESSAGE="$SISTEMMESSAGE.n `hostname` sunucuda $[topmem/1024/1024] GB ram kullanan process var!!! " fi #### Sistemdeki Yuku Kontrol Eder ##### LOAD=`uptime|awk -F, '{ print $4,$5,$6 }'|awk -F: '{print $2}'` ACTIVELOAD=`echo $LOAD|awk '{print $1}'|awk -F. '{ print $1 }'` if [[ $ACTIVELOAD -ge $CRITICALLOAD ]] ;then SISTEMSTATE=2 SISTEMMESSAGE="$SISTEMMESSAGE.n Asiri Yuk. Yuk=$[ACTIVELOAD] " elif [[ $ACTIVELOAD -ge $WARNINGLOAD ]] ;then SISTEMSTATE=1 SISTEMMESSAGE="$SISTEMMESSAGE.n Yuk Artiyor. Yuk=$[ACTIVELOAD] " fi #### Sistemdeki BELLEGI Kontrol Eder ##### TOTALMEM=`free|grep Mem|awk '{print $2}'` FREEMEM=`free|grep Mem|awk '{print $4}'` FREEPERC=$[FREEMEM*100/TOTALMEM] if [[ $CRITICALMEM -ge $FREEPERC ]] ;then SISTEMSTATE=2 SISTEMMESSAGE="$SISTEMMESSAGE.n Bos Bellek Kalmadi. Bos Bellek=$[FREEPERC]%"
  2. 2. elif [[ $WARNINGMEM -ge $FREEPERC ]] ;then if [ $SISTEMSTATE -lt 1 ]; then SISTEMSTATE=1; fi SISTEMMESSAGE="$SISTEMMESSAGE.n Bos Bellek Azaldi. Bos Bellek=$[FREEPERC]%" fi ### Disklerdeki Bos Alani Kontrol Eder ##### for DEV in `df -h|awk '{print $1}'|grep "/"` do SIZE=`df -h|grep $DEV|awk '{print $2}'` AVAILSIZE=`df -h|grep $DEV|awk '{print $4}'` USEPERC=`df -h|grep $DEV|awk '{print $5}'|awk -F % '{print $1}'` MOUNTEDON=`df -h|grep $DEV|awk '{print $6}'` if [ `grep -w $MOUNTEDON $DISKEXCLUDE|wc -l` -eq 0 ] ;then if [[ $USEPERC -ge $CRITICALDISK ]] ;then SISTEMSTATE=2 SISTEMMESSAGE="$SISTEMMESSAGE.n $MOUNTEDON Da Cok Az Yer Kaldi.Kalan=$AVAILSIZE" elif [[ $USEPERC -ge $WARNINGDISK ]] ;then if [ $SISTEMSTATE -lt 1 ]; then SISTEMSTATE=1; fi SISTEMMESSAGE="$SISTEMMESSAGE.n $MOUNTEDON Da Az Yer Kaldi.Kalan=$AVAILSIZE" fi fi done echo $SISTEMMESSAGE > /tmp/vyg_monitor_mail.log if [ $SISTEMSTATE -gt 0 ]; then /usr/local/bin/mailtome "`hostname` ONEMLI" /tmp/vyg_monitor_mail.log fi

×