Tuesday, April 28, 2015

Install Munin 2.0.25 on CentOS 7

Munin will not be found in base repositories, hence we add EPEL repository to install Munin.

Install EPEL and additional repositories on CentOS and Red Hat:

# yum install wget
# yum install epel-release

Note: for more information https://fedoraproject.org/wiki/EPEL

# yum install munin munin-node

Uncomment the following lines:

# vim /etc/munin/munin.conf

dbdir /var/lib/munin
htmldir /var/www/html/munin
logdir /var/log/munin
rundir  /var/run/munin

# a simple host tree
[localhost]
    address 127.0.0.1
    use_node_name yes

Comment out all lines in /etc/httpd/conf.d/munin.conf:

# vim /etc/httpd/conf.d/munin.conf

Note: the reason why we comment out all the lines in munin.conf file is because we are going to move these lines under the VirtualHost block in httpd-vhosts.conf file.

Edit httpd-vhosts.conf, and add your IP address to the Allow from line:

# vim /etc/httpd/conf.d/httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/var/www/html/munin"
    ServerName munin.mydomain.com

    <directory /var/www/html/munin>
        AuthUserFile /etc/munin/munin-htpasswd
        AuthName "Munin"
        AuthType Basic
        require valid-user

        # This next part requires mod_expires to be enabled.
        #
        # We could use <IfModule mod_expires> around here, but I want it to be
        # as evident as possible that you either have to load mod_expires _or_
        # you coment out/remove these lines.

        # Set the default expiery time for files 5 minutes 10 seconds from
        # their creation (modification) time.  There are probably new files by
        # that time.

        ExpiresActive On
        ExpiresDefault M310

        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 192.168.0.0/24
    </directory>

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

    ErrorLog "/var/log/httpd/munin.mydomain.com-error_log"
    CustomLog "/var/log/httpd/munin.mydomain.com-access_log" common
</VirtualHost>

Make sure the permission:

# chown -R munin:munin /var/www/html/munin/

# ls -dlaZ /var/www/html/munin/

drwxr-xr-x. munin munin system_u:object_r:httpd_munin_content_t:s0 /var/www/html/munin/

To verify the Apache configuration file:

# httpd -t

Syntax OK

Create the munin admin account:

# htpasswd -c /etc/munin/munin-htpasswd Munin

Note: you don't have to use -c parameter if you want to add additional users.

Make sure the permission:

# chown root:apache /etc/munin/munin-htpasswd
# chmod 640 /etc/munin/munin-htpasswd

If you would like to change the admin's name, edit:

# vim /etc/httpd/conf.d/munin.conf

AuthName "Munin"

Enable munin on system boot:

# systemctl enable munin-node

or

# chkconfig --add munin-node
# chkconfig munin-node on

Start munin:

# systemctl restart munin-node

Restart Apache:

# systemctl restart httpd

Wait for a couple of minutes or reboot your system to allow munin to create necessary files/folders automatically on your apache root folder.

http://munin.mydomain.com

Reference:

http://www.unixmen.com/install-munin-monitoring-tool-centos-rhel-scientific-linux-6-56-46-3/

No comments: