From aa2d22c92a523efd26cd575320ab90df5c94e744 Mon Sep 17 00:00:00 2001 From: Soulou Date: Wed, 2 Nov 2016 00:09:43 +0100 Subject: Support CGI graphs --- .gitignore | 1 + CHANGELOG | 9 +++++++++ Dockerfile | 3 ++- VERSION | 5 ----- munin.conf | 10 +++++++--- nginx-munin | 13 +++++++++++-- nginx.conf | 30 ++++++++++++++++++++++++++++++ start-munin.sh | 2 ++ test/munin/.gitkeep | 0 test/start_test.sh | 19 +++++++++++++++++++ 10 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 .gitignore create mode 100644 CHANGELOG delete mode 100644 VERSION create mode 100644 nginx.conf create mode 100644 test/munin/.gitkeep create mode 100755 test/start_test.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bf10b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test/munin/* diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..b0c56a7 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,9 @@ +# v7 - 2 Nov 2016 + +* Add support for graph CGI + +# v5 - 30 Apr 2015 + +* Graceful shutdown +* Do not repeat configuration on restart +* Email for alerts diff --git a/Dockerfile b/Dockerfile index 738b909..498e213 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,14 @@ MAINTAINER Leo Unbekandt RUN adduser --system --home /var/lib/munin --shell /bin/false --uid 1103 --group munin RUN apt-get update -qq && RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive \ - apt-get install -y -qq cron munin munin-node nginx apache2-utils wget heirloom-mailx patch + apt-get install -y -qq cron munin munin-node nginx apache2-utils wget heirloom-mailx patch spawn-fcgi libcgi-fast-perl RUN rm /etc/nginx/sites-enabled/default && mkdir -p /var/cache/munin/www && chown munin:munin /var/cache/munin/www && mkdir -p /var/run/munin && chown -R munin:munin /var/run/munin VOLUME /var/lib/munin VOLUME /var/log/munin ADD ./munin.conf /etc/munin/munin.conf +AdD ./nginx.conf /etc/nginx/nginx.conf ADD ./nginx-munin /etc/nginx/sites-enabled/munin ADD ./start-munin.sh /munin ADD ./munin-graph-logging.patch /usr/share/munin diff --git a/VERSION b/VERSION deleted file mode 100644 index b348c1d..0000000 --- a/VERSION +++ /dev/null @@ -1,5 +0,0 @@ -# v5 - 30 Apr 2015 - -* Graceful shutdown -* Do not repeat configuration on restart -* Email for alerts diff --git a/munin.conf b/munin.conf index 66febbf..9dacba5 100644 --- a/munin.conf +++ b/munin.conf @@ -6,11 +6,15 @@ #staticdir /etc/munin/static includedir /etc/munin/munin-conf.d #graph_period second -#graph_strategy cron #munin_cgi_graph_jobs 6 -#cgiurl_graph /munin-cgi/munin-cgi-graph + +## html_strategy cron|cgi +html_strategy cron +## graph_strategy cron|cgi +graph_strategy cgi +cgiurl_graph /munin-cgi/munin-cgi-graph + #max_size_x 4000 #max_size_y 4000 -#html_strategy cron #max_processes 16 #rrdcached_socket /var/run/rrdcached.sock diff --git a/nginx-munin b/nginx-munin index 66bf1d1..d0f5da9 100644 --- a/nginx-munin +++ b/nginx-munin @@ -1,16 +1,25 @@ server { listen 8080 default_server; server_name munin; + access_log /var/log/nginx/munin-access.log; error_log /var/log/nginx/munin-server.log; + auth_basic "Munin Server"; + auth_basic_user_file "/etc/munin/htpasswd.users"; + location /munin { root /var/cache/munin/www; } + location ^~ /munin-cgi/munin-cgi-graph/ { + fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*); + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_pass unix:/var/run/munin/fcgi-graph.sock; + include fastcgi_params; + } + location / { - auth_basic "Munin Server"; - auth_basic_user_file "/etc/munin/htpasswd.users"; root "/var/cache/munin/www"; } } diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..baac5b6 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,30 @@ +user munin; +worker_processes 4; +pid /run/nginx.pid; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + gzip on; + gzip_disable "msie6"; + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} + + diff --git a/start-munin.sh b/start-munin.sh index 6df87cc..fda929c 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -114,6 +114,8 @@ fi /usr/sbin/munin-node echo "Using the following munin nodes:" echo $NODES +# start spawn-cgi to enable CGI interface with munin (dynamix graph generation) +spawn-fcgi -s /var/run/munin/fcgi-graph.sock -U munin -u munin -g munin /usr/lib/munin/cgi/munin-cgi-graph # start nginx /usr/sbin/nginx # show logs diff --git a/test/munin/.gitkeep b/test/munin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/start_test.sh b/test/start_test.sh new file mode 100755 index 0000000..7f81e69 --- /dev/null +++ b/test/start_test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ -z "$1" ] ; then + echo "usage: $0 " + exit 1 +fi + +basedir="$( cd -P "$( dirname "$0" )" && pwd )/munin" + +docker run -it \ + -p 8080:8080 \ + -v $basedir/log:/var/log/munin \ + -v $basedir/lib:/var/lib/munin \ + -v $basedir/run:/run/munin \ + -v $basedir/cache:/var/cache/munin \ + -e MUNIN_USER=user \ + -e MUNIN_PASSWORD=secret \ + -e NODES="172.17.0.1:$(hostname)" \ + $1 -- cgit v1.2.1