new: [add] init commit, elab-update, elab-manage-install & scripts
This commit is contained in:
7
etc/cron.daily/remove_state_file_48h
Executable file
7
etc/cron.daily/remove_state_file_48h
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
## Remove every .state file older than 48h -- Cleanup script if the others aren’t strong enougth
|
||||
find /var/run/elab-manage -name "*.state" -type f -mtime +2 -delete
|
40
etc/cron.hourly/disk_usage
Executable file
40
etc/cron.hourly/disk_usage
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
## check disk usage and send a notification if it's above 75% or 90%
|
||||
|
||||
percent_usage=$(df /srv -h)
|
||||
percent_usage=${percent_usage##*$'\n'}
|
||||
percent_usage=${percent_usage% *}
|
||||
percent_usage=${percent_usage##* }
|
||||
percent_usage=${percent_usage%\%}
|
||||
|
||||
STATE_WORKING_DIR="/var/run/elab-manage"
|
||||
mkdir -p "$STATE_WORKING_DIR"
|
||||
|
||||
if [ "$percent_usage" -ge "90" ]; then
|
||||
if [ -e $STATE_WORKING_DIR/disk_usage_90.state ]; then
|
||||
exit 0
|
||||
else
|
||||
touch $STATE_WORKING_DIR/disk_usage_90.state
|
||||
message="$(hostname): WARNING disk usage >=90%"
|
||||
send -c disk.crit "$message"
|
||||
fi
|
||||
elif [ "$percent_usage" -ge "75" ]; then
|
||||
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
||||
exit 0
|
||||
else
|
||||
touch $STATE_WORKING_DIR/disk_usage_75.state
|
||||
message="$(hostname): WARNING disk usage >=75 <90%"
|
||||
send -c disk.alert "$message"
|
||||
fi
|
||||
else
|
||||
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
||||
rm $STATE_WORKING_DIR/disk_usage_75.state
|
||||
fi
|
||||
if [ -e $STATE_WORKING_DIR/disk_usage_90.state ]; then
|
||||
rm $STATE_WORKING_DIR/disk_usage_90.state
|
||||
fi
|
||||
fi
|
32
etc/cron.hourly/load_average_max
Executable file
32
etc/cron.hourly/load_average_max
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
MAX_PER_PROC=3
|
||||
|
||||
## integer only for the 5m load avg
|
||||
|
||||
LOCK_WORKING_DIR="/var/run/elab-manage"
|
||||
mkdir -p "$LOCK_WORKING_DIR"
|
||||
|
||||
int_avg=$(while read line; do
|
||||
echo "$line"
|
||||
done < /proc/loadavg)
|
||||
int_avg=${int_avg#* }
|
||||
int_avg=${int_avg%%.*}
|
||||
max=$[$MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo)]
|
||||
if [ "$int_avg" -gt "$max" ]; then
|
||||
if [ -e $LOCK_WORKING_DIR/load_average_max.lock ]; then
|
||||
exit 0
|
||||
else
|
||||
touch $LOCK_WORKING_DIR/load_average_max.lock
|
||||
message="[$(hostname)] : WARNING - load average ($int_avg) is above max per processor : ($MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo) = $max)"
|
||||
echo $message | logger -t load_average_max
|
||||
send "$message"
|
||||
fi
|
||||
else
|
||||
if [ -e $LOCK_WORKING_DIR/load_average_max.lock ]; then
|
||||
rm $LOCK_WORKING_DIR/load_average_max.lock
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user