initial commit of bin scripts into git

This commit is contained in:
2023-11-08 13:38:19 +11:00
commit 3735eea3c6
113 changed files with 11631 additions and 0 deletions

58
cinnamon_is_slow Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
log=/tmp/cin_slow.log
limit_cpu=60.0
limit_slow=6
pid=`pgrep -x cinnamon`
top=`top -b -n1 | grep -w $pid`
cpu=`echo $top | egrep -v '-' | awk '{ print $9; }'`
state=`echo $top | egrep -v '-' | awk '{ print $8; }'`
debug=1
if [ $debug == 1 ]; then
echo "STARTING at `date`" >> $log
echo "0: cpu $cpu -- from $top" >> $log
fi
cnt=1
sample=1
times_slow=0
while [ $cnt -le 50 ] && [ $sample -le 10 ]; do
top=`top -b -n1 | grep -w $pid`
cpu=`echo $top | egrep -v '-' | awk '{ print $9; }'`
if [ $debug == 1 ]; then
echo "$cnt: cpu $cpu -- from $top" >> $log
fi
if [ $state == "R" ] || [ $cpu != "0.0" ] ; then
cnt=`expr $cnt + 1`
sample=`expr $sample + 1`
else
if [ $debug == 1 ]; then
echo "$cnt: - consider this run as not relevant, seems cinammon was idle when we ran top" >> $log
fi
fi
if [ `echo "$cpu >= $limit_cpu" | bc` = 1 ]; then
times_slow=`expr $times_slow + 1`
if [ $debug == 1 ]; then
echo "$cnt: + We have a slow reading (so far: $times_slow from $sample)" >> $log
fi
fi
sleep 2
cnt=`expr $cnt + 1`
if [ $times_slow -gt $limit_slow ]; then
break
fi
done
if [ $debug == 1 ]; then
echo "From a sample of $sample measurements, cin* was slow $times_slow times" >> $log
wmctrl -l >> $log
fi
if [ $times_slow -gt $limit_slow ]; then
export DISPLAY=:0
zenity --info --text "I think cinammon is slow! Please manually restart it"
exit 0
fi