Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save odony/45a283f3de2992642f0d69d81a423042 to your computer and use it in GitHub Desktop.
Save odony/45a283f3de2992642f0d69d81a423042 to your computer and use it in GitHub Desktop.
# Enable request logging in Odoo using one of the following:
# * pass --log-level=debug_rpc
# * or pass --log-handler=odoo.http.rpc.request:DEBUG (to only debug request times)
# * or set the equivalent config option in the Odoo config file
# Then save the following as a munin plugin to monitor the last 5 minutes of your Odoo config file
# Be sure to set the correct path for the Odoo log file, and adjust the variables as needed
#!/bin/bash
#%# family=manual
# Odoo log file location
LOGFILE=/var/log/odoo.log
# How many lines to scan at the end of the log (should contain last 5 minutes)
LINE_RANGE=60000
[[ -e $LOGFILE ]] || exit 0
case $1 in
config)
echo graph_title Odoo requests time
echo graph_category odoo
echo "avg_request_time.label Average request time (s)"
echo avg_request_time.warning 1
echo avg_request_time.critical 3
exit 0
;;
esac
# watch out for the time zone of the logs => use date -u for UTC timestamps
# also exclude longpolling requests which are meant to last 50s
avg=$(tail -n $LINE_RANGE $LOGFILE | grep "http.rpc.request.*time" | grep -v "http.rpc.request: poll:" | awk -v threshold="`date -u +'%F %H:%M:%S' -d '5 min ago'`" 'threshold < $1 " " $2 { split($10,t,":"); sum += t[2]; n++; } END { if(n > 0) print sum/n}')
echo -n "avg_request_time.value "
echo ${avg:-0}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment