Code plus compact

darcs-hash:20070922173056-72cb0-01a91ee69a35d71f1357d855f1afcc0538ca48f3.gz
This commit is contained in:
salles 2007-09-22 19:30:56 +02:00
parent 7cf991a219
commit 9a32467db7

View file

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
LOGDIR="/var/log/munin/"
LOGBASE=$LOGDIR"munin-"
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
echo 'graph_category system' echo 'graph_category system'
@ -14,6 +17,8 @@ if [ "$1" = "config" ]; then
echo 'graph.draw STACK' echo 'graph.draw STACK'
echo 'html.label html' echo 'html.label html'
echo 'html.draw STACK' echo 'html.draw STACK'
echo 'nagios.label nagios'
echo 'nagios.draw STACK'
echo 'total.label Total' echo 'total.label Total'
echo 'max.label Maximum' echo 'max.label Maximum'
echo 'total.warning 0:300' echo 'total.warning 0:300'
@ -21,37 +26,17 @@ if [ "$1" = "config" ]; then
exit 0 exit 0
fi fi
LOGDIR="/var/log/munin/" total=0
LOGBASE=$LOGDIR"munin-"
# Munin-update for log in update limits graph html nagios
echo -n "update.value " do
time_update=$(grep -i finished $LOGBASE"update.log" | tail -n 1 | awk -F '(' '{print $2}' | awk '{print $1}' | bc -l) echo -n $log".value "
echo $time_update time=$(grep -E -i "Starting|finished" $LOGBASE$log".log" | grep -B1 "finished" | tail -n 2 | awk '{print "date -d \""$1" "$2" "$3"\" +%s"}' | sh | xargs | awk '{if($2) {print $2"-"$1} else {print "0"}}' | bc -l) || 0
echo $time
total=$(echo $time"+"$total | bc -l)
done
begin_limits=$(grep -i finished /var/log/munin/munin-update.log | tail -n 1 | awk '{print "date -d \""$1" "$2" "$3"\" +%s"}' | sh) echo "total.value "$total
# Munin-limits
echo -n "limits.value "
end_limits=$(grep -i finished $LOGBASE"limits.log" | tail -n 1 | awk '{print "date -d \""$1" "$2" "$3"\" +%s"}' | sh)
time_limits=$(echo $end_limits"-"$begin_limits | bc -l)
echo $time_limits
# Munin-graph
echo -n "graph.value "
time_graph=$(grep -i finished $LOGBASE"graph.log" | tail -n 1 | awk -F '(' '{print $2}' | awk '{print $1}' | bc -l)
echo $time_graph
begin_html=$(grep -i finished /var/log/munin/munin-graph.log | tail -n 1 | awk '{print "date -d \""$1" "$2" "$3"\" +%s"}' | sh)
# Munin-html
echo -n "html.value "
end_html=$(grep -i finished $LOGBASE"html.log" | tail -n 1 | awk '{print "date -d \""$1" "$2" "$3"\" +%s"}' | sh)
time_html=$(echo $end_html"-"$begin_html | bc -l)
echo $time_html
echo -n "total.value "
echo $time_update"+"$time_limits"+"$time_graph"+"$time_html | bc -l
# Le temps de rafraîchissement de munin est de 5 minutes # Le temps de rafraîchissement de munin est de 5 minutes
echo "max.value 300" echo "max.value 300"