munin + nginx: não dynazoom em gráficos

6

Não consigo fazer com que o zoom dinâmico Munin funcione. Tenho certeza de que o problema tem algo a ver com a configuração do Nginx. Qualquer tentativa de gerar um gráfico ampliado aciona a seguinte entrada de erro no log nginx:

2015/02/22 13:26:01 [error] 4782#0: *2580 open() "/data/munin/usr/share/munin/cgi/munin-cgi-graph/bellaria/antergos1.bellaria/diskstats_latency/AntergosVG_AntergosRoot-pinpoint=1421756527,1424607727.png" failed (2: No such file or directory), client: 10.10.10.25, server: munin, request: "GET /usr/share/munin/cgi/munin-cgi-graph/bellaria/antergos1.bellaria/diskstats_latency/AntergosVG_AntergosRoot-pinpoint=1421756527,1424607727.png?&lower_limit=&upper_limit=&size_x=800&size_y=400 HTTP/1.1", host: "munin.bellaria", referrer: "http://munin.bellaria/static/dynazoom.html?cgiurl_graph=/usr/share/munin/cgi/munin-cgi-graph&plugin_name=bellaria/antergos1.bellaria/diskstats_latency/AntergosVG_AntergosRoot&size_x=800&size_y=400&start_epoch=1421756527&stop_epoch=1424607727"

Especificamente, suspeito que algo está errado com os parâmetros fastCGI. Que uma boa alma amiga dê uma olhada no meu servidor virtual Munin (veja abaixo) e me explique o que está errado? Está me enlouquecendo - mas tenho um palpite de que qualquer especialista identificará o problema em uma fração de segundo ...

# Munin server
server {
       listen 80;
    server_name munin munin.bellaria;
    root /data/munin;
    allow all;
    access_log logs/munin.access.log;
    error_log logs/munin.error.log;

    location / {
        index index.html index.htm index.php;
        }

    location ~ \.(php|html|html|cgi)$ {
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param   AUTH_USER $remote_user;
        fastcgi_param   REMOTE_USER $remote_user;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_index  index.php;
        include        fastcgi.conf;
        }


location ^~ /cgi-bin/munin-cgi-graph/ {
    access_log off;
    fastcgi_split_path_info ^(/cgi-bin/munin-cgi-graph)(.*);
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_pass unix:/var/run/munin/fcgi-graph.sock;
    include fastcgi_params;
    }

   }
    
por aag 22.02.2015 / 13:34

4 respostas

1

Encontrei isto enquanto procurava uma solução para o meu problema e boas notícias! Eu resolvi meu problema. Espero que isso ajude você a ter o Munin trabalhando na sua configuração também.

Requisitos:

  • spawnfcgi:
    1. Clone ou faça o download do zip em https://github.com/lighttpd/spawn-fcgi
    2. Prepare:
      autoreconf -v -i
    3. Compile e instale:
      ./configure && make && sudo make install

  • Scripts de inicialização (não faço systemd para descobrir como criar um serviço):
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          munin-fastcgi
    # Required-Start:    $remote_fs $network
    # Required-Stop:     $remote_fs $network
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts munin-fastcgi
    # Description:       Spawn Munin FCGI sockets for Web access
    ### END INIT INFO
    
    #
    # munin-fastcgi     Startup script for Munin CGI services
    #
    # chkconfig: - 84 15
    # description: Loading Munin CGI services using spawn-cgi
    #              HTML files and CGI.
    #
    # Author:  Ryan Norbauer 
    # Modified:     Geoffrey Grosenbach http://topfunky.com
    # Modified:     David Krmpotic http://davidhq.com
    # Modified:     Kun Xi http://kunxi.org
    # Modified:     http://drumcoder.co.uk/
    # Modified:     http://uname.pingveno.net/
    # Modified:     the_architecht http://iwbyt.com/
    PATH=/usr/local/bin/:/usr/local/sbin:$PATH
    DAEMON=$(which spawn-fcgi)
    FCGI_GRAPH_SOCK=/var/run/munin/fastcgi-munin-graph.sock
    FCGI_HTML_SOCK=/var/run/munin/fastcgi-munin-html.sock
    WWW_USER=www-data
    FCGI_USER=www-data
    FCGI_GROUP=www-data
    FCGI_SPAWN_GRAPH=/usr/lib/munin/cgi/munin-cgi-graph
    FCGI_SPAWN_HTML=/usr/lib/munin/cgi/munin-cgi-html
    PIDFILE_GRAPH=/var/run/munin/fastcgi-munin-graph.pid
    PIDFILE_HTML=/var/run/munin/fastcgi-munin-html.pid
    DESC="Munin FCGI for Graph and HTML"
    
    # Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0
    test -x $FCGI_SPAWN_GRAPH || exit 0
    test -x $FCGI_SPAWN_HTML || exit 0
    
    start() {
      $DAEMON -s $FCGI_GRAPH_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_GRAPH $FCGI_SPAWN_GRAPH 2> /dev/null || echo "Graph Already running"
      $DAEMON -s $FCGI_HTML_SOCK  -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_HTML $FCGI_SPAWN_HTML 2> /dev/null || echo "HTML Already running"
    }
    
    stop() {
      kill -QUIT 'cat $PIDFILE_GRAPH' || echo "Graph not running"
      kill -QUIT 'cat $PIDFILE_HTML' || echo "HTML Not running"
    }
    
    restart() {
      kill -HUP 'cat $PIDFILE_GRAPH' || echo "Can't reload Graph"
      kill -HUP 'cat $PIDFILE_HTML' || echo "Can't reload HTML"
    }
    
    case "$1" in
      start)
        echo "Starting $DESC: "
        start
      ;;
      stop)
        echo "Stopping $DESC: "
        stop
      ;;
      restart|reload)
        echo "Restarting $DESC: "
        stop
        # One second might not be time enough for a daemon to stop,
        # if this happens, d_start will fail (and dpkg will break if
        # the package is being upgraded). Change the timeout if needed
        # be, or change d_stop to have start-stop-daemon use --retry.
        # Notice that using --retry slows down the shutdown process somewhat.
        sleep 1
        start
      ;;
      *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
        exit 3
      ;;
    esac
    
    exit $?
    

    Instale o acima em /etc/init.d/munin-fcgi com permissões 755

  • No seu vhost, por exemplo /etc/nginx/conf.d/example.com.conf , adicione isso no bloco server { } . Você pode alterar os blocos de IP permitidos para ajustar sua configuração. Eu fiz isso em um servidor local e queria que os gráficos munin estivessem disponíveis apenas localmente.
    location /munin {
    #    alias /var/cache/munin/www;
        index index.html;
    #    include /etc/nginx/php.conf;
    #    access_log off;
        allow 127.0.0.1;
        allow 192.168.0.0/16;
        deny all;                                
    }
    
    location ^~ /munin-cgi/munin-cgi-graph/ {
    #   if ($uri ~ /munin-cgi/munin-cgi-graph/([^/]*)) { set $path $1; }
        fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*);
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/var/run/munin/fastcgi-munin-graph.sock;
        include fastcgi_params;
    }
    location  ^~ /munin-cgi/munin-cgi-html/ {
    #   if ($uri ~ /munin-cgi/munin-cgi-html/([^/]*)) { set $path $1; }
        fastcgi_split_path_info ^(/munin-cgi/munin-cgi-html)(.*);
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/var/run/munin/fastcgi-munin-html.sock;
        include fastcgi_params;
    }
    

  • Inicie o /etc/init.d/munin-fcgi start e recarregue o nginx, então você está pronto.
  • Eu fiz link da pasta html de munin para a pasta do meu vhost: ln -s /var/cache/munin/www/ /var/www/example.com/munin -v .

        
    por 25.12.2015 / 17:22
    0

    Isso soa como um problema com as definições em static/dynazoom.html . Em nossa instalação, temos

    form.cgiurl_graph.value = qs.get("cgiurl_graph", "/munin-cgi/munin-cgi-graph");
    

    Eu suspeito que você tenha

    form.cgiurl_graph.value = qs.get("cgiurl_graph", "/usr/share/munin/cgi/munin-cgi-graph");
    

    Embora deva ser

    form.cgiurl_graph.value = qs.get("cgiurl_graph", "/cgi-bin/munin-cgi-graph");
    

    Ainda estou convencido de que é mais ou menos onde está o problema. A configuração do nginx parece correta, desde que as solicitações de gráficos com zoom iniciem com /cgi-bin/munin-cgi-graph . Não vejo de onde /data/munin/... está vindo.

    Tente executar em um ambiente em que você possa monitorar as solicitações enviadas pelo navegador (fiddler, chrome dev tools) e ver o que realmente está sendo enviado.

    Tem certeza de que está editando a cópia correta do dynazoom? Tente fazer uma alteração visível trivial apenas para verificar isso.

        
    por 03.03.2015 / 22:58
    0

    Eu tive problema semelhante no Ubuntu 12.04 com munin 2.0.21.
    Verifique onde o dynazoom está tentando encontrar o munin-cgi-graph. O wiki do Munin diz que você deve configurar o seu nginx fcgi -grafo para

    location ^~ /cgi-bin/munin-cgi-graph/
    

    No meu caso, quando examino a página com a ferramenta de desenvolvimento do Chrome (guia Rede), descobri que o dynazoom tenta buscar o munin-cgi-graph de / munin-cgi / munin-cgi-graph / de / cgi-bin / munin-cgi-graph / e obtém 404 erorr em vez de grafo

    Então eu mudei este local na configuração do nginx:

        location ^~ /munin-cgi/munin-cgi-graph/ {
            access_log off;
            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;
     }
    

    Parece que você tem o mesmo problema que a sua localização do munin-cgi-graph está incorreta, portanto, as solicitações do navegador vão para root /data/munin , assim como o erro diz.

        
    por 11.08.2015 / 18:58
    0

    Algo que gostaria de adicionar a esta conversa. A informação do the_architecht era bastante inestimável, mas algo que estava faltando, pelo menos para mim.

    Usando o CentOS 6.8 aqui:

    -

    1) Caminhos para os arquivos CGI alterados, eles podem ser encontrados via locate:

    /var/www/cgi-bin/munin-cgi-graph
    /var/www/cgi-bin/munin-cgi-html
    

    Eu tive que ir linha por linha no script de início para comparar locais e quebrar as linhas iniciais do daemon para ver o que estava errado, o que me permitiu rastrear as diferenças no caminho do arquivo.

    -

    2) As permissões para os logs foram definidas para o usuário "munin" que causou um tipo de erro silencioso. Para resolver isso, adicionei o usuário www-data ao grupo munin e o chmod 664 aos arquivos de log:

    -rw-rw-r-- 1 munin munin 0 Apr 27 20:35 /var/log/munin/munin-cgi-graph.log
    -rw-rw-r-- 1 munin munin 0 Apr 27 20:35 /var/log/munin/munin-cgi-html.log
    

    A doação para as permissões de arquivo envolveu o wiki do Munin adicionando o -n no final do spawn -fcgi processa start e strace -s1024 que deu erro

    write(2, "[Thu Apr 27 21:47:35 2017] munin-cgi-html: Can't open /var/log/munin/munin-cgi-html.log (Permission denied) at /usr/share/perl5/vendor_perl/Log/Log4perl/Appender/File.pm line 103.\n", 180[Thu Apr 27 21:47:35 2017] munin-cgi-html: Can't open /var/log/munin/munin-cgi-html.log (Permission denied) at /usr/share/perl5/vendor_perl/Log/Log4perl/Appender/File.pm line 103.

    Meu Nginx final e o spawn-fcgi estão abaixo com minhas modificações:

    server {
    
            listen $IP;
            server_name $host.example.com;
    
                    access_log      /var/log/nginx/domlogs/munin-access.log;
                    error_log       /var/log/nginx/domlogs/munin-error.log;
    
        root /var/www/html/munin/;
        index   index.html;
    
    
    location / {
            auth_basic            "Restricted";
           # Create the htpasswd file with the htpasswd tool.
            auth_basic_user_file  /etc/nginx/htpasswd/munin;
    
    }
    
    location ^~ /munin-cgi/munin-cgi-graph/ {
    #   if ($uri ~ /munin-cgi/munin-cgi-graph/([^/]*)) { set $path $1; }
        fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*);
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/var/run/munin/fastcgi-munin-graph.sock;
        include fastcgi_params;
    }
    location  ^~ /munin-cgi/munin-cgi-html/ {
    #   if ($uri ~ /munin-cgi/munin-cgi-html/([^/]*)) { set $path $1; }
        fastcgi_split_path_info ^(/munin-cgi/munin-cgi-html)(.*);
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass unix:/var/run/munin/fastcgi-munin-html.sock;
        include fastcgi_params;
    }
    
    }
    
    #! /bin/bash
    ### BEGIN INIT INFO
    # Provides:          munin-fastcgi
    # Required-Start:    $remote_fs $network
    # Required-Stop:     $remote_fs $network
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts munin-fastcgi
    # Description:       Spawn Munin FCGI sockets for Web access
    ### END INIT INFO
    
    #
    # munin-fastcgi     Startup script for Munin CGI services
    #
    # chkconfig: - 84 15
    # description: Loading Munin CGI services using spawn-cgi
    #              HTML files and CGI.
    #
    # Author:  Ryan Norbauer 
    # Modified:     Geoffrey Grosenbach http://topfunky.com
    # Modified:     David Krmpotic http://davidhq.com
    # Modified:     Kun Xi http://kunxi.org
    # Modified:     http://drumcoder.co.uk/
    # Modified:     http://uname.pingveno.net/
    # Modified:     the_architecht http://iwbyt.com/
    # Modified:     Jame Scott - NeCr0mStR
    
    DESC="Munin FCGI for Graph and HTML"
    
    SCRIPTNAME="$(tput setaf 1)Munin-FastCGI$(tput sgr0)"
    
    PATH=/usr/local/bin/:/usr/local/sbin:$PATH
    DAEMON=$(which spawn-fcgi)
    FCGI_GRAPH_SOCK=/var/run/munin/fastcgi-munin-graph.sock
    FCGI_HTML_SOCK=/var/run/munin/fastcgi-munin-html.sock
    WWW_USER=www-data
    FCGI_USER=www-data
    FCGI_GROUP=www-data
    FCGI_SPAWN_GRAPH=/var/www/cgi-bin/munin-cgi-graph
    FCGI_SPAWN_HTML=/var/www/cgi-bin/munin-cgi-html
    PIDFILE_GRAPH=/var/run/munin/fastcgi-munin-graph.pid
    PIDFILE_HTML=/var/run/munin/fastcgi-munin-html.pid
    
    # Gracefully exit if the package has been removed.
    
        test -x $DAEMON || exit 0
        test -x $FCGI_SPAWN_GRAPH || exit 0
        test -x $FCGI_SPAWN_HTML || exit 0
    
    
    start_graph() {
        if [[ $(/bin/ps ax | awk '/munin-cgi-graph$/ {print $1}') ]];then
            local   RUNNING_PID_GRAPH=$(/bin/ps ax | awk '/munin-cgi-graph$/ {print $1}')
        fi
    
    
        if [[ -s ${PIDFILE_GRAPH} && ${RUNNING_PID_GRAPH} = $(cat ${PIDFILE_GRAPH}) ]];then
            echo -e "\nMunin-Graph already running"
        elif [[ -n ${RUNNING_PID_GRAPH} && ${RUNNING_PID_GRAPH} != $(cat ${PIDFILE_GRAPH}) && -S ${FCGI_GRAPH_SOCK} ]];then
            echo -e "\nMunin-Graph PID mismatch :: Cleaning up and starting Munin-Graph"
            kill -QUIT ${RUNNING_PID_GRAPH}
            sleep 1
                $DAEMON -s $FCGI_GRAPH_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_GRAPH $FCGI_SPAWN_GRAPH > /dev/null 2>&1
        else     
                $DAEMON -s $FCGI_GRAPH_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_GRAPH $FCGI_SPAWN_GRAPH > /dev/null 2>&1
                echo -e "Starting Munin-Graph\n"
        fi
    }
    
    start_html() {
        if [[ $(/bin/ps ax | awk '/munin-cgi-html$/ {print $1}') ]];then
            local   RUNNING_PID_HTML=$(/bin/ps ax | awk '/munin-cgi-html$/ {print $1}')
        fi
    
    
        if [[ -s ${PIDFILE_HTML} && ${RUNNING_PID_HTML} = $(cat ${PIDFILE_HTML}) ]];then
            echo -e "\nMunin-HTML already running"
        elif [[ -n ${RUNNING_PID_HTML} && ${RUNNING_PID_HTML} != $(cat ${PIDFILE_HTML}) && -S ${FCGI_HTML_SOCK} ]];then
                echo -e "\nMunin-HTML PID mismatch :: Cleaning up and starting Munin-HTML"
                kill -QUIT ${RUNNING_PID_HTML}
                    sleep 1
                    $DAEMON -s $FCGI_HTML_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_HTML $FCGI_SPAWN_HTML > /dev/null 2>&1
        else       
                    $DAEMON -s $FCGI_HTML_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_HTML $FCGI_SPAWN_HTML > /dev/null 2>&1
                    echo -e "Starting Munin-HTML\n"
        fi
    }
    
    stop_graph() {
        if [[ $(/bin/ps ax | awk '/munin-cgi-graph$/ {print $1}') ]];then
            local   RUNNING_PID_GRAPH=$(/bin/ps ax | awk '/munin-cgi-graph$/ {print $1}')
        fi
    
        if [[ -s ${PIDFILE_GRAPH} && $(cat ${PIDFILE_GRAPH}) = ${RUNNING_PID_GRAPH} ]];then
            kill -QUIT $(cat ${PIDFILE_GRAPH})
                echo -e "\nMunin-Graph stopped"
            elif [[ -z ${RUNNING_PID_GRAPH} && -s ${PIDFILE_GRAPH} ]];then
                    echo -e "\nGraph PID not found :: Cleaning up PID file"
                    rm ${PIDFILE_GRAPH}
            elif [[ -s ${PIDFILE_GRAPH} && $(cat ${PIDFILE_GRAPH}) != ${RUNNING_PID_GRAPH} ]];then
                    kill -QUIT ${RUNNING_PID_GRAPH}
                    rm ${PIDFILE_GRAPH}
                    echo -e "\nMunin-Graph stopped :: Cleaning up PID file"
        else 
                    echo -e "\nNo Munin-Graph process found"
        fi
    }
    
    stop_html() {
        if [[ $(/bin/ps ax | awk '/munin-cgi-html$/ {print $1}') ]];then
            local   RUNNING_PID_HTML=$(/bin/ps ax | awk '/munin-cgi-html$/ {print $1}')
        fi
    
        if [[ -s ${PIDFILE_HTML} && $(cat ${PIDFILE_HTML}) = ${RUNNING_PID_HTML} ]];then
            kill -QUIT $(cat ${PIDFILE_HTML})
                echo -e "\nMunin-HTML stopped"
            elif [[ -z ${RUNNING_PID_HTML} && -s ${PIDFILE_HTML} ]];then
                echo -e "\nHTML PID not found :: Cleaning up PID file"
                    rm ${PIDFILE_HTML}
            elif [[ -s ${PIDFILE_HTML} && $(cat ${PIDFILE_HTML}) != ${RUNNING_PID_HTML} ]];then
                    kill -QUIT ${RUNNING_PID_HTML}
                    rm ${PIDFILE_HTML}
                    echo -e "\nMunin-HTML stopped :: Cleaning up PID file"
            else 
                    echo -e "\nNo Munin-HTML process found"
        fi
    }
    
    
    case "$1" in
        start)
            echo "Starting $DESC: "
            start_graph
            start_html
            ;;
        start_graph)
            echo "Starting Munin-Graph"
            start_graph
            ;;
        start_html)
            echo "Starting Munin-HTML"
            start_html
            ;;
        stop_graph)
            echo "Stopping Munin_Graph"
            stop_graph
            ;;
        stop_html)
            echo "Stopping Munin-HTML"
            stop_html
            ;;
        stop)
            echo "Stopping $DESC: "
            stop_graph
            stop_html
            ;; 
        restart|reload)
            echo "Restarting $DESC: "
            stop_html
            stop_graph
    
    # One second might not be time enough for a daemon to stop,
    # if this happens, d_start will fail (and dpkg will break if
    # the package is being upgraded). Change the timeout if needed
    # be, or change d_stop to have start-stop-daemon use --retry.
    # Notice that using --retry slows down the shutdown process somewhat.
    
            sleep 5
            start_graph
            start_html
            ;;
        *)
            echo "$(tput setaf 2)Usage: $SCRIPTNAME $(tput setaf 7)$(tput setab 0){start_graph|start_html|stop_graph|stop_html|start|stop|restart|reload}$(tput sgr0) " >&2
            exit 3
            ;;
    esac
    
    exit $?
    
        
    por 28.04.2017 / 04:29