Browse Source

Support CGI graphs

Soulou 7 years ago
parent
commit
aa2d22c92a
9 changed files with 76 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 4 0
      CHANGELOG
  3. 2 1
      Dockerfile
  4. 7 3
      munin.conf
  5. 11 2
      nginx-munin
  6. 30 0
      nginx.conf
  7. 2 0
      start-munin.sh
  8. 0 0
      test/munin/.gitkeep
  9. 19 0
      test/start_test.sh

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+test/munin/*

+ 4 - 0
VERSION → CHANGELOG

@@ -1,3 +1,7 @@
+# v7 - 2 Nov 2016
+
+* Add support for graph CGI
+
 # v5 - 30 Apr 2015
 
 * Graceful shutdown

+ 2 - 1
Dockerfile

@@ -5,13 +5,14 @@ MAINTAINER Leo Unbekandt <leo@scalingo.com>
 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

+ 7 - 3
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

+ 11 - 2
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";
   }
 }

+ 30 - 0
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/*;
+}
+
+

+ 2 - 0
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

+ 0 - 0
test/munin/.gitkeep


+ 19 - 0
test/start_test.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if [ -z "$1" ] ; then
+  echo "usage: $0 <id of docker image>"
+  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