Forked from odony/munin plugin for monitoring Odoo 9 or 10 request times
Created
July 16, 2018 16:37
-
-
Save akhdaniel/9c9dd3a12efd8560aa4ea2b007369eec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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