Skip to content

Instantly share code, notes, and snippets.

@dreispt
Last active April 17, 2023 09:10
Show Gist options
  • Save dreispt/5d21790a0119d8648162 to your computer and use it in GitHub Desktop.
Save dreispt/5d21790a0119d8648162 to your computer and use it in GitHub Desktop.
Munin plugins for Odoo
#!/bin/sh
#%# family=manual
#%# capabilities=autoconf suggest
# Munin plugin for transactions/minute
case $1 in
autoconf)
exit 0
;;
suggest)
exit 0
;;
config)
echo graph_category openerp
echo graph_title openerp rpc request count
echo graph_vlabel num requests/minute in last 5 minutes
echo requests.label num requests
exit 0
;;
esac
# watch out for the time zone of the logs => using date -u for UTC timestamps
result=$(tail -60000 /var/log/odoo/odoo-server.log | grep "object.execute_kw time" | awk "BEGIN{count=0} (\$1 \" \" \$2) >= \"`date +'%F %H:%M:%S' -ud '5 min ago'`\" { count+=1; } END{print count/5}")
echo "requests.value ${result}"
exit 0
#!/bin/sh
#%# family=manual
#%# capabilities=autoconf suggest
# Munin plugin for response time
case $1 in config)
echo graph_category openerp echo
graph_title openerp rpc requests min/average response time
echo graph_vlabel seconds
echo graph_args --units-exponent -3
echo min.label min
echo min.warning 1
echo min.critical 5
echo avg.label average
echo avg.warning 1
echo avg.critical 5
exit 0
;;
esac
# watch out for the time zone of the logs => using date -u for UTC timestamps
result=$(tail -60000 /var/log/odoo/odoo-server.log | grep "object.execute_kw time" | awk "BEGIN{sum=0;count=0} (\$1 \" \" \$2) >= \"`date +'%F %H:%M:%S' -ud '5 min ago'`\" {split(\$8,t,\":\");time=0+t[2];if (min==\"\") { min=time}; sum += time; count+=1; min=(time>min)?min:time } END{print min, sum/count}")
echo -n "min.value "
echo ${result} | cut -d" " -f1
echo -n "avg.value "
echo ${result} | cut -d" " -f2
exit 0
@max3903
Copy link

max3903 commented Jun 29, 2018

👍 for a repo

@adekock11
Copy link

adekock11 commented Nov 18, 2022

In case anybody needs it for newer Odoo versions:

Requests:

tail -60000 /var/log/odoo/odoo-server.log | grep "odoo.http.rpc.request" | awk "BEGIN{count=0;} (\$1 \" \" \$2) >= \"`date +'%F %H:%M:%S' -ud '5 min ago'`\" {count+=1;} END{print count/5;}"

Response:

tail -60000 /var/log/odoo/odoo-server.log | grep "odoo.http.rpc.request" | awk "BEGIN{sum=0; count=0;} (\$1 \" \" \$2) >= \"`date +'%F %H:%M:%S' -ud '5 min ago'`\" {gsub(\"time:\",\"\",\$10); time=0+\$10; sum+=time; count+=1;} END{print sum/count;}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment