From d5eab96a7de84f1cf93ae43f4cf47e6a071d4a82 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 14 Jun 2012 15:02:00 +0200 Subject: [PATCH] put some scripts from prix.aec.at in there and moved vpnc_config.sh to archive --- vpnc_config.sh => archive/vpnc_config.sh | 0 connect.sh | 0 connection_test.sh | 0 csr_gen.sh | 0 free.sh | 14 ++++++ mail.sh | 56 ++++++++++++++++++++++++ restart_apache_at_ram_threshold.sh | 27 ++++++++++++ rtspstream.pl | 0 8 files changed, 97 insertions(+) rename vpnc_config.sh => archive/vpnc_config.sh (100%) mode change 100644 => 100755 connect.sh mode change 100644 => 100755 connection_test.sh mode change 100644 => 100755 csr_gen.sh create mode 100755 free.sh create mode 100755 mail.sh create mode 100755 restart_apache_at_ram_threshold.sh mode change 100644 => 100755 rtspstream.pl diff --git a/vpnc_config.sh b/archive/vpnc_config.sh similarity index 100% rename from vpnc_config.sh rename to archive/vpnc_config.sh diff --git a/connect.sh b/connect.sh old mode 100644 new mode 100755 diff --git a/connection_test.sh b/connection_test.sh old mode 100644 new mode 100755 diff --git a/csr_gen.sh b/csr_gen.sh old mode 100644 new mode 100755 diff --git a/free.sh b/free.sh new file mode 100755 index 0000000..dc7080d --- /dev/null +++ b/free.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +freememory=$(free -m | grep "cache:" | awk '{print $4}') +threshold="300" + + +if [ $freememory -gt $threshold ]; then + echo "There is $freememory MB availible. Threshold not reached." +else + echo "There is less than $threshold MB of memory availible." + /home/david/mail.sh "There is less than $threshold MB of memory availible!! You should probably do something about that pretty soon brother!!" +fi + +exit 0 diff --git a/mail.sh b/mail.sh new file mode 100755 index 0000000..27203b8 --- /dev/null +++ b/mail.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +############################### +# # +# mbots mail routine # +# # +############################### + +# ***** config section ***** +#don't touch as long as you're not me. feel me? +version=".01" +author="david@socialnerds.org" + +#script config +smtpserver="smtp.aec.at" +recipients="david@aec.at gerald.hochhauser@aec.at michael.grausgruber@aec.at daniel.weihrauch@aec.at" +from="mbots@aec.at" +subject="free memory on prix.aec.at" +line=$1 + +#if [ -f $line ]; then +# line=$(cat $line) +#fi + +# ***** start of script ***** + +#telnet connection +{ + sleep 1 + echo "HELO $HOSTNAME" + sleep 1 + echo "MAIL FROM: $from" + sleep 1 + for address in $recipients; do + echo "RCPT TO: $address" + sleep 1 + done + echo "DATA" + sleep 1 + for address in $recipients; do + echo "To: $address" + done + echo "From: Monitoring Bots <$from>" + echo "Subject: $subject" + sleep 1 + echo "$line" + sleep 1 + echo "." + sleep 1 + echo "QUIT" +} | telnet $smtpserver 25 + + +# ***** end of script ***** +#live long and prosper +exit 0 diff --git a/restart_apache_at_ram_threshold.sh b/restart_apache_at_ram_threshold.sh new file mode 100755 index 0000000..2373970 --- /dev/null +++ b/restart_apache_at_ram_threshold.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +i=1 +j=1 +threshold=850 +while [ 2 -gt 1 ]; do + echo "run count: $i" + sleep 30 + mem=$(free -m | grep + | awk '{print $3}') + echo " used memory: $mem" + echo " threshold: $threshold" + if [ $mem -gt $threshold ]; then + echo " memory usage too high" + echo " too high mem count: $j (apache will be restarted if count reaches 10)" + let j++ + if [ $j -gt 10 ]; then + echo " resetting apache to clear memory" + /etc/init.d/apache2 restart + j=1 + fi + else + echo " memory below threshold" + fi + let i++ +done + +exit 0 diff --git a/rtspstream.pl b/rtspstream.pl old mode 100644 new mode 100755