Skip to content

Instantly share code, notes, and snippets.

@killerbees19
Created October 25, 2021 19:50
Show Gist options
  • Save killerbees19/48829034e2f5a7ed01c786dfbb99e5b2 to your computer and use it in GitHub Desktop.
Save killerbees19/48829034e2f5a7ed01c786dfbb99e5b2 to your computer and use it in GitHub Desktop.
Munin plugin to monitor Nginx HTTP protocols
/var/log/nginx/misc/protocol.log {
daily
missingok
rotate 0
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}
log_format protocol '$server_protocol';
access_log /var/log/nginx/misc/protocol.log protocol;
#!/bin/bash
if [[ "$1" == "autoconf" ]]
then
echo "no"
exit 1
elif [[ "$1" != "config" ]]
then
sort /var/log/nginx/misc/protocol.log | uniq -c | sort -k 2 | \
awk '{ k=gensub(/[^a-z0-9_]/, "_", "g", tolower($2)); print k".value "$1; }'
exit $?
fi
cat << EOF
graph_title Nginx HTTP protocols
graph_vlabel Requests per \${graph_period}
graph_args --base 1000 --lower-limit 0
graph_category nginx
_.label Unknown
_.colour COLOUR7
_.draw AREA
_.type DERIVE
_.min 0
http_1_0.label HTTP/1.0
http_1_0.colour COLOUR3
http_1_0.draw STACK
http_1_0.type DERIVE
http_1_0.min 0
http_1_1.label HTTP/1.1
http_1_1.colour COLOUR1
http_1_1.draw STACK
http_1_1.type DERIVE
http_1_1.min 0
http_2_0.label HTTP/2.0
http_2_0.colour COLOUR0
http_2_0.draw STACK
http_2_0.type DERIVE
http_2_0.min 0
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment