34 lines
606 B
Bash
34 lines
606 B
Bash
|
|
#!/bin/bash
|
||
|
|
#
|
||
|
|
LOGFILE=/sllocal/log/mongodb.log
|
||
|
|
if [ ! -e "${LOGFILE}" ]; then
|
||
|
|
LOGFILE=/sl/logs/mongodb.log
|
||
|
|
if [ ! -e "${LOGFILE}" ]; then
|
||
|
|
echo "No mongodb.log file in /sllocal/log or /sl/logs"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
echo "-- Using log file: ${LOGFILE} --"
|
||
|
|
|
||
|
|
tail -f "${LOGFILE}" | awk '
|
||
|
|
BEGIN { maxop=0; }
|
||
|
|
/op_query/ {
|
||
|
|
#print $0;
|
||
|
|
idx=match($0, "op_query ");
|
||
|
|
ms=substr($0, idx+9);
|
||
|
|
sub("ms", "", ms)
|
||
|
|
#print ms;
|
||
|
|
ms = 0 + ms;
|
||
|
|
if (ms > maxop){
|
||
|
|
maxop = 0+ms;
|
||
|
|
print "-- New max " maxop "ms"
|
||
|
|
print $0;
|
||
|
|
} else if (ms >= 1000){
|
||
|
|
print "-- Slow query " ms "ms"
|
||
|
|
print $0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
'
|
||
|
|
|
||
|
|
exit 0
|