
Não consigo fazer o zoom dinâmico do Munin funcionar. 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 do 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 esteja errado com os parâmetros fastCGI. Uma boa alma amiga pode dar uma olhada no meu servidor virtual Munin (veja abaixo) e me explicar o que há de errado? Isso está me deixando louco - mas tenho o 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;
}
}
Responder1
Encontrei isso enquanto procurava uma solução para o meu problema e boas notícias! Eu resolvi meu problema. Espero que isso ajude você a fazer com que Munin trabalhe em sua configuração também.
Requisitos:
- Clone ou baixe o zip em https://github.com/lighttpd/spawn-fcgi
- Prepare isso:
autoreconf -v -i
- Compilar e instalar:
./configure && make && sudo make install
#! /bin/sh ### INFORMAÇÕES DE INÍCIO # Fornece: munin-fastcgi # Início obrigatório: $remote_fs $network # Parada obrigatória: $remote_fs $network # Início padrão: 2 3 4 5 # Parada padrão: 0 1 6 # Breve descrição: inicia munin-fastcgi # Descrição: Soquetes Spawn Munin FCGI para acesso à Web ### FIM INFORMAÇÃO DE INÍCIO # # munin-fastcgi Script de inicialização para serviços Munin CGI # #chkconfig: -84 15 # description: Carregando serviços Munin CGI usando spawn-cgi # Arquivos HTML e CGI. # # Autor: Ryan Norbauer # Modificado: Geoffrey Grosenbach http://topfunky.com # Modificado: David Krmpotic http://davidhq.com # Modificado: Kun Xi http://kunxi.org # Modificado: http://drumcoder.co.uk/ # Modificado: http://uname.pingveno.net/ # Modificado: the_architecht http://iwbyt.com/ PATH=/usr/local/bin/:/usr/local/sbin:$PATH DAEMON=$(que 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-dados FCGI_USER=www-dados FCGI_GROUP=www-dados 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 para Gráfico e HTML" # Saia normalmente se o pacote tiver sido removido. teste -x $DAEMON || saída 0 teste -x $FCGI_SPAWN_GRAPH || saída 0 teste -x $FCGI_SPAWN_HTML || saída 0 começar() { $DAEMON -s $FCGI_GRAPH_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_GRAPH $FCGI_SPAWN_GRAPH 2> /dev/null || echo "Gráfico já em execução" $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 já em execução" } parar() { matar -QUIT `cat $PIDFILE_GRAPH` || echo "Gráfico não está rodando" matar -QUIT `cat $PIDFILE_HTML` || echo "HTML não está em execução" } reiniciar() { matar -HUP `cat $PIDFILE_GRAPH` || echo "Não é possível recarregar o gráfico" matar -HUP `cat $PIDFILE_HTML` || echo "Não é possível recarregar o HTML" } caso "$1" em começar) echo "Iniciando $DESC:" começar ;; parar) echo "Parando $DESC:" parar ;; reiniciar | recarregar) echo "Reiniciando $DESC:" parar # Um segundo pode não ser tempo suficiente para um daemon parar, # se isso acontecer, o d_start irá falhar (e o dpkg irá quebrar se # o pacote está sendo atualizado). Altere o tempo limite, se necessário # be, ou altere d_stop para que start-stop-daemon use --retry. # Observe que usar --retry retarda um pouco o processo de desligamento. dormir 1 começar ;; *) echo "Uso: $SCRIPTNAME {start|stop|restart|reload}" >&2 saída 3 ;; esac sair $?
Instale o acima /etc/init.d/munin-fcgi
com permissões755
/etc/nginx/conf.d/example.com.conf
, adicione isso no server { }
bloco. Você pode alterar os blocos de IP permitidos para se adequarem à sua configuração. Fiz isso em um servidor local e queria que os gráficos Munin estivessem disponíveis apenas localmente.
localização /munin { # alias /var/cache/munin/www; índice index.html; #include /etc/nginx/php.conf; # access_log off; permitir 127.0.0.1; permitir 192.168.0.0/16; negar tudo; } localização ^~ /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; inclua fastcgi_params; } localização ^~ /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; inclua fastcgi_params; }
/etc/init.d/munin-fcgi start
e recarregue o nginx, então você estará pronto.ps: vinculei a pasta html do munin à pasta do meu vhost: ln -s /var/cache/munin/www/ /var/www/example.com/munin -v
.
Responder2
Isso parece 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 é aí que reside o problema. A configuração do nginx parece correta, desde que as solicitações de gráficos ampliados comecem com /cgi-bin/munin-cgi-graph
. Não vejo /data/munin/...
de onde vem.
Tente executar em um ambiente onde 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.
Responder3
Eu tive um problema semelhante no Ubuntu 12.04 com o Munin 2.0.21.
Verifique onde o Dynazoom está tentando encontrar o munin-cgi-graph.
O wiki de Munin dizque você deve configurar seu gráfico nginx fcgi para
location ^~ /cgi-bin/munin-cgi-graph/
No meu caso, quando examino a página com a ferramenta de desenvolvedor do Chrome (guia Rede), descobri que o dynazoom estava tentando buscar o munin-cgi-graph de/munin-cgi/munin-cgi-gráfico/Não de/cgi-bin/munin-cgi-graph/e obtém erro 404 em vez do gráfico
Então, acabei de alterar 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: a localização do munin-cgi-graph está incorreta, então as solicitações do navegador vão root /data/munin
exatamente como o erro diz.
Responder4
Algo que eu queria acrescentar a esta conversa. As informações do the_architecht foram inestimáveis, 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 localizar:
/var/www/cgi-bin/munin-cgi-graph
/var/www/cgi-bin/munin-cgi-html
Tive que ir linha por linha no script inicial para comparar os 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", o que causou uma espécie de erro silencioso. Para resolver isso adicionei o usuário www-data ao grupo munin e chmod 664 os 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 concessão das permissões de arquivo envolveu oWiki Muninadicionando o -n no final do processo spawn-fcgi start e strace -s1024 que deu erro
write(2, "[Qui, 27 de abril 21:47:35 2017] munin-cgi-html: Não é possível abrir /var/log/munin/munin-cgi-html.log (permissão negada) em /usr/share/ perl5/vendor_perl/Log/Log4perl/Appender/File.pm linha 103.\n", 180[Qui 27 de abril 21:47:35 2017] munin-cgi-html: Não é possível abrir /var/log/munin/munin -cgi-html.log (Permissão negada) em /usr/share/perl5/vendor_perl/Log/Log4perl/Appender/File.pm linha 103.
Meu Nginx e spawn-fcgi finais 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 $?