1.Установка и настройка Munin
1 |
# yum install munin munin-node |
1 |
# cp /etc/munin/munin.conf /etc/munin/munin.conf~ |
1 |
# nano /etc/httpd/conf.d/munin.conf |
1 2 3 4 5 6 7 8 9 |
Alias /munin /var/www/html/munin # Если нужно ограничить доступ к статистике по паролю <Directory /var/www/html/munin> AuthUserFile /etc/munin/munin-htpasswd AuthName "Munin" AuthType Basic Require valid-user </Directory> |
1 |
# htpasswd /etc/munin/munin-htpasswd munin |
Конфигурационный файл Munin-сервера /etc/munin/munin.conf
1 |
# cat /etc/munin/munin.conf | grep -v '#' | grep -v '^$' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
dbdir /var/lib/munin htmldir /var/www/html/munin logdir /var/log/munin rundir /var/run/munin tmpldir /etc/munin/templates staticdir /etc/munin/static includedir /etc/munin/conf.d graph_period second graph_strategy cron cgiurl_graph /munin-cgi/munin-cgi-graph html_strategy cron #определяем клиентов, с которых снимаем статистику # 127.0.0.1 – Munin-сервер также снимает статистику с себя. [lb01.kamaok.org.ua] address 127.0.0.1 use_node_name yes [lb02.kamaok.org.ua] address 192.168.1.62 use_node_name yes [app01.kamaok.org.ua] address 192.168.1.63 use_node_name yes [app02.kamaok.org.ua] address 192.168.1.64 use_node_name yes |
Логи для munin-сервера смотрим в
1 |
# tail -f /var/log/munin/munin-update.log |
Проверяем наличие задания в крон,которое автоматически добавляется при установке munin-сервера
1 |
# cat /etc/cron.d/munin |
1 2 |
MAILTO=root */5 * * * * munin test -x /usr/bin/munin-cron && /usr/bin/munin-cron |
Проверка работы munin-сервера
1 |
# su -m munin -c /usr/bin/munin-cron |
2.На клиентах, с которых будет сниматься статистика
1 |
# yum install munin-node |
1 |
# cat /etc/munin/munin-node.conf | grep -v '#' | grep -v '^$' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
log_level 4 log_file /var/log/munin-node/munin-node.log pid_file /var/run/munin/munin-node.pid background 1 setsid 1 user root group root ignore_file DEADJOE$ ignore_file \.bak$ ignore_file %$ ignore_file \.dpkg-(tmp|new|old|dist)$ ignore_file \.rpm(save|new)$ ignore_file \.pod$ allow ^127\.0\.0\.1$ allow ^::1$ allow ^192\.168\.1\.61$ # Ip-adress Munin-мастера, на котором смотрим всю статистику host * port 4949 |
1 |
# /etc/init.d/munin-node start |
1 |
# chkconfig --level 2345 munin-node on |
Логи на клиентах смотрим в
1 |
# tail -f /var/log/munin-node/munin-node.log |
3.Снятие статистики с Nginx в Munin
Проверка поддержки модуля stub_status
1 |
# nginx –V |
1 2 |
………………. --with-http_stub_status_module |
1 |
# nano /etc/nginx/nginx.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
listen 80 default_server; server_name _; location / { root /var/www/html; try_files $uri $uri/ /index.php; } location /nginx_status { stub_status on; access_log on; allow 127.0.0.1; allow 192.168.1.0/24; deny all; } |
1 |
# nginx -t |
1 |
# /etc/init.d/nginx restart |
Проверяем доступность статистики в браузере
1 |
http://<IP-address>/nginx_status |
Настройка модуля Nginx
1 |
# nano /etc/munin/plugin-conf.d/munin-node |
1 2 |
[nginx*] env.url http://localhost/nginx_status |
Подключаем плагины Munin для снятия статистики с Nginx
1 |
# ln -s /usr/share/munin/plugins/nginx_request /etc/munin/plugins/ -v |
1 |
# ln -s /usr/share/munin/plugins/nginx_status /etc/munin/plugins/ -v |
Отсюда качаем скрипт для мониторинга памяти
https://github.com/munin-monitoring/contrib/tree/master/plugins/nginx
1 |
# nano /usr/share/munin/plugins/nginx_memory |
1 |
# chmod +x /usr/share/munin/plugins/nginx_memory |
1 |
# ln -s /usr/share/munin/plugins/nginx_memory /etc/munin/plugins/ |
1 |
# munin-run nginx_memory |
1 |
# /etc/init.d/munin-node restart |
4.Снятие статистики с MySQL в Munin
1 |
# yum install perl-Cache perl-Cache-Cache |
1 |
# yum install perl-IPC-ShareLite perl-DBD-MySQL |
Настройка модуля MySQL
1 |
# nano /etc/munin/plugin-conf.d/mysql |
1 2 3 4 5 6 7 8 9 10 |
[mysql_innodb] env.mysql /usr/bin/mysql env.mysqlopts --user=root --password=123456789 --host=localhost [mysql*] env.mysqlopts -u root -p123456789 env.mysqladmin /usr/bin/mysqladmin env.mysqlshow /usr/bin/mysqlshow env.mysqluser root env.mysqlpassword 123456789 |
1 |
# ls -al /usr/share/munin/plugins/ | grep mysql |
1 2 3 4 5 6 7 |
# ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/ -v # ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/ -v |
5.Снятие статистики PHP-FPM в Munin
1 |
# yum install git |
1 |
# cd /usr/share/munin/plugins |
1 |
# git clone git://github.com/tjstein/php5-fpm-munin-plugins.git |
1 |
# chmod +x php5-fpm-munin-plugins/phpfpm_* |
1 2 3 4 5 |
# ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_average /etc/munin/plugins/phpfpm_average # ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_connections /etc/munin/plugins/phpfpm_connections # ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_memory /etc/munin/plugins/phpfpm_memory # ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_status /etc/munin/plugins/phpfpm_status # ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_processes /etc/munin/plugins/phpfpm_processes |
1 |
# nano /etc/php-fpm.d/www.conf |
1 2 |
pm.status_path = /status ping.path = /ping |
1 |
# nano /etc/nginx/conf.d/default.conf |
1 2 3 4 5 6 7 8 9 10 |
location ~ ^/(status|ping)$ { fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; access_log off; allow 127.0.0.1; allow XXX.XXX.XXX.XXX; deny all; } |
1 |
# /etc/init.d/php-fpm configtest |
1 |
# /etc/init.d/php-fpm reload |
1 |
# /etc/init.d/nginx configtest |
1 |
# /etc/init.d/nginx reload |
1 |
# /etc/init.d/munin-node restart |
Источник:
https://github.com/tjstein/php5-fpm-munin-plugins
http://tjstein.com/articles/php-fpm-plugin-suite-for-munin/
Построение графиков по пулам PHP-FPM в Munin
1 |
# cd /usr/share/munin/plugins/ |
1 |
# wget -O php-fpm https://raw.github.com/MorbZ/munin-php-fpm/master/php-fpm.php |
1 |
# chmod +x php-fpm |
1 2 3 4 |
# ln -s -v /usr/share/munin/plugins/php-fpm /etc/munin/plugins/php-fpm-cpu # ln -s -v /usr/share/munin/plugins/php-fpm /etc/munin/plugins/php-fpm-count # ln -s -v /usr/share/munin/plugins/php-fpm /etc/munin/plugins/php-fpm-time # ln -s -v /usr/share/munin/plugins/php-fpm /etc/munin/plugins/php-fpm-memory |
1 |
# /etc/init.d/munin-node restart |
1 |
# tail -f /var/log/munin-node/munin-node.log |
Источник:
https://github.com/MorbZ/munin-php-fpm/blob/master/README.md
6. Снятие статистики с Memcached в Munin
1 |
# yum install perl-Cache-Memcached |
1 2 3 |
# ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_rates # ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_bytes # ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_counters |
1 |
# nano /etc/munin/plugin-conf.d/memcached |
1 2 3 |
[memcached_*] env.host 127.0.0.1 env.port 11211 |
1 |
# munin-run memcached_bytes |
1 |
# munin-run memcached_counters |
1 |
# munin-run memcached_rates |
1 |
# /etc/init.d/munin-node restart |
7. Снятие статистики с Redis в Munin
1 |
# wget -O /usr/share/munin/plugins/redis_ http://munin-monitoring.org/export/HEAD/munin-contrib/plugins/redis/redis_ |
1 |
# chmod 755 /usr/share/munin/plugins/redis_ |
1 2 3 |
# ln -s /usr/share/munin/plugins/redis_ /etc/munin/plugins/redis_connected_clients # ln -s /usr/share/munin/plugins/redis_ /etc/munin/plugins/redis_per_sec # ln -s /usr/share/munin/plugins/redis_ /etc/munin/plugins/redis_used_memory |
1 |
# nano /etc/munin/plugin-conf.d/redis |
1 2 3 |
[redis_*] env.host 127.0.0.1 env.port 6379 |
1 |
# /etc/init.d/munin-node restart |
1 |
# munin-run redis_connected_clients |
1 |
# munin-run redis_per_sec |
1 |
# munin-run redis_used_memory |
8. Снятие статистики с Elasticsearch в Munin
1 |
# nano /etc/munin/plugin-conf.d/elasticsearch |
1 2 3 4 5 6 7 8 |
[elasticsearch_*] env.host localhost env.port 9200 [elasticsearch_open_files] user root env.host localhost env.port 9200 |
1 |
# cd /tmp |
1 |
# git clone https://github.com/y-ken/munin-plugin-elasticsearch.git |
1 |
# cd munin-plugin-elasticsearch/ |
1 |
# cp elasticsearch_* /usr/share/munin/plugins/ |
1 |
# rm -rf /tmp/munin-plugin-elasticsearch |
1 |
# ln -s /usr/share/munin/plugins/elasticsearch_* /etc/munin/plugins/ |
1 |
# yum install perl-JSON |
1 |
# munin-node-configure | grep elasticsearch |
1 2 3 4 5 6 7 8 9 |
# munin-run elasticsearch_cluster_shards # munin-run elasticsearch_cache # munin-run elasticsearch_docs # munin-run elasticsearch_index_size # munin-run elasticsearch_index_total # munin-run elasticsearch_jvm_memory # munin-run elasticsearch_jvm_threads # munin-run elasticsearch_open_files # munin-run elasticsearch_translog_size |
1 |
# /etc/init.d/munin-node restart |
Источник:
https://github.com/y-ken/munin-plugin-elasticsearch
Полезные мелочи
1 |
# telnet localhost 4949 |
Просмотр установленных модулей Munin
1 |
# list |
Проверка работоспособности модуля(например, cpu)
1 |
# fetch cpu |
Просмотр состояния плагинов Munin
1 |
# munin-node-configure --suggest |
Просмотр используемых(активных) плагинов
1 |
# munin-node-configure --suggest | grep yes |
Проверка работоспособности плагина cpu
1 |
# munin-run cpu |