Created
February 13, 2015 17:13
-
-
Save odony/d7a85df79a186c3f117f to your computer and use it in GitHub Desktop.
Sample Munin plugin for min/avg Odoo 8.0 RPC calls
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
| #!/bin/sh | |
| #%# family=manual | |
| #%# capabilities=autoconf suggest | |
| 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 | |
| LINE_RANGE=60000 | |
| TIME_RANGE='5 min ago' | |
| LOGFILE=/tmp/log | |
| result=$(tail -$LINE_RANGE $LOGFILE | grep "openerp.http.rpc.request.*time" | sed -e 's/\([0-9: ]*\)[A-Za-z].*\(time:.*\)/\1 \2/' | awk "BEGIN{sum=0;count=0} (\$1 \" \" \$2) >= \"`date +'%F %H:%M:%S' -ud \"$TIME_RANGE\" `\" {split(\$4,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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment