سلام و درود
یک اسکریپت دیگه برای مانیتور کردن سرور برای صما قرار میدم
این اسکریپت در صورت بالا رفتن لود سایت ایمیل میده.با bash نوشته شده که میتونید داخل کرون جاب قرار بدین تاچند دقیقه یک بار چک کنه
کد:
#!/bin/bash
We set a trigger for how high the load can get before we're
alerted via e-mail from this script.
trigger=4.00
We set a load variable to read the current server load from
/proc/loadavg and only from the first column which is the live load.
load=`cat /proc/loadavg | awk '{print $1}'`
We set a response variable to the word "greater" if the current
load is greater than our trigger that we set.
response=`echo | awk -v T=$trigger -v L=$load 'BEGIN{if ( L > T){ print "greater"}}'`
If the response is set to "greater" we run the sar -q command
and pipe | that data to the mail command for recipient@example.com
this sends an e-mail with the server's recent load averages there.
if [[ $response = "greater" ]]
then
sar -q | mail -s"High load on server - [ $load ]" iedb.team@gmail.com
fi
موفق باشید.