2024. április 20., szombat

Gyorskeresés

A Munin rendszer monitorozó telepítése és használata mysql-el

Írta: | Kulcsszavak: munin . szerver . linux . apache . html . cgi . install . debian . monitorozás

[ ÚJ BEJEGYZÉS ]

A rendszerem Debian 9, erre telepítettem fel a Munin rendszermonitorozó rendszert.

Terminálban adjuk ki a következő parancsokat, feltételezve hogy a szükésges függőségek már telepítve vannak (Pl egy Apache2 webszerver)
apt-get update
apt-get upgrade
apt-get install munin munin-node munin-plugins-extra

A MySQL-hez:
cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/mysql_ mysql_
ln -s /usr/share/munin/plugins/mysql_bytes mysql_bytes
ln -s /usr/share/munin/plugins/mysql_innodb mysql_innodb
ln -s /usr/share/munin/plugins/mysql_isam_space_ mysql_isam_space_
ln -s /usr/share/munin/plugins/mysql_queries mysql_queries
ln -s /usr/share/munin/plugins/mysql_slowqueries mysql_slowqueries
ln -s /usr/share/munin/plugins/mysql_threads mysql_threads

Sajnos ezzel még mindig nem fog működni a MySQL monitorozása. Módosítanunk kell az /etc/munin/plugin-conf.d/munin-node féjlt.
Keressük meg a [mysql*] részt és írjuk át erre:
[mysql*]
user root
group wheel
env.mysqladmin /usr/bin/mysqladmin
env.mysqlopts -u munin -pp4ssw0rd

Természetesen ehhez létre kell hozni a munin usert egy jelszóval.

munin-run mysql_queries terminál parancsal ellenőrizhetjük, hogy sikerült e a fenti beállítás. Ha kiírja a select, insert, update, replace értékeket, akkor működik.

Van itt még pár leírás a Munin MySQL-hez, de ez nem oldotta meg a kapcsolódási gondom:
https://sysadmin.xyz/main/2017/12/29/graph-mysql-munin/
https://mensfeld.pl/2012/02/making-munin-work-with-mysql-on-debian/

nano /etc/munin/munin.conf /etc/munin/munin.conf fájl szerkesztése:
# kivétele a dbdir /var/lib/munin htmldir /var/cache/munin/www logdir /var/log/munin rundir /var/run/munin sorok elől

# Example configuration file for Munin, generated by 'make build'

# The next three variables specifies where the location of the RRD
# databases, the HTML output, logs and the lock/pid files. They all
# must be writable by the user running munin-cron. They are all
# defaulted to the values you see here.
#
dbdir /var/lib/munin
htmldir /var/cache/munin/www
logdir /var/log/munin
rundir /var/run/munin

# Where to look for the HTML templates
#
tmpldir /etc/munin/templates

# Where to look for the static www files
#
#staticdir /etc/munin/static

# temporary cgi files are here. note that it has to be writable by
# the cgi user (usually nobody or httpd).
#
# cgitmpdir /var/lib/munin/cgi-tmp

# (Exactly one) directory to include all files from.
includedir /etc/munin/munin-conf.d
[...]
# a simple host tree
[server1.example.com]
address 127.0.0.1
use_node_name yes
[...]

Az Apache konfigurásása
cd /etc/apache2/conf-enabled/
ln -s /etc/munin/apache24.conf munin.conf
service apache2 restart

nano /etc/munin/apache24.conf /etc/munin/apache24.conf módosítása, ha azt szeretnénénk, hogy ne csak localhoston legyen elérhető:

Alias /munin /var/cache/munin/www
<Directory /var/cache/munin/www>
# Require local
Require all granted
Options FollowSymLinks SymLinksIfOwnerMatch
Options None
</Directory>

ScriptAlias /munin-cgi/munin-cgi-graph /usr/lib/munin/cgi/munin-cgi-graph
<Location /munin-cgi/munin-cgi-graph>
# Require local
Require all granted
Options FollowSymLinks SymLinksIfOwnerMatch
<IfModule mod_fcgid.c>
SetHandler fcgid-script
</IfModule>
<IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Location>

Újraindítások
service apache2 restart
service munin-node restart

Ha jelszó védelmet is akarunk:
htpasswd -c /etc/munin/munin-htpasswd admin
nano /etc/munin/apache24.conf
Alias /munin /var/cache/munin/www
<Directory /var/cache/munin/www>
# Require local
# Require all granted
AuthUserFile /etc/munin/munin-htpasswd
AuthName "Munin"
AuthType Basic
Require valid-user
Options None
</Directory>

ScriptAlias /munin-cgi/munin-cgi-graph /usr/lib/munin/cgi/munin-cgi-graph
<Location /munin-cgi/munin-cgi-graph>
# Require local
# Require all granted
AuthUserFile /etc/munin/munin-htpasswd
AuthName "Munin"
AuthType Basic
Require valid-user
<IfModule mod_fcgid.c>
SetHandler fcgid-script
</IfModule>
<IfModule !mod_fcgid.c>
SetHandler cgi-script
</IfModule>
</Location>

Opcionális pluginok állapotának megtekintése:
munin-node-configure --suggest

A pluginok ki be kapcsolgatása az /usr/share/munin/plugins/ könyvtárból az /etc/munin/plugins könyvtárba való linkeléssel történik. Pl:
cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/apache_accesses
ln -s /usr/share/munin/plugins/apache_processes
ln -s /usr/share/munin/plugins/apache_volume

Ha minden beállítást elvégeztünk, indítsuk újra a szolgáltatást:
service munin-node restart

Copyright © 2000-2024 PROHARDVER Informatikai Kft.