How to install Munin monitoring on centos

Source: Internet
Author: User
Tags memcached centos git clone


I. Installation

Before installation, make sure that you have installed EPEL. If not, you can refer to centos to install EPEL to install Munin.

Yum -- enablerepo = epel install munin-common munin-node rrdtool
Through the installation prompt, we can find that munin mainly relies on perl to work.
After installation, the system will change as follows:

/Etc/munin. conf: the configuration file of the Munin master (server.
/Etc/cron. d/munin: Munin sets the crontab scheduler task file.
/Etc/httpd/conf. d/munin. conf: the configuration file of Munin Apache.
/Var/log/munin: Directory of the Munin log.
/Var/www/html/munin: Directory of the Munin website.
/Etc/munin/munin-node.conf: Munin Node configuration file (specifies which nodes are monitored ).
/Etc/munin/plugins. conf: configuration file of the Munin plugins plug-in.
/Etc/rc. d/init. d/munin-node: Munin startup script
/Etc/munin/plugin-conf.d/munin-node plug-in configuration.
II. Configure the monitoring end

Scheduled Tasks

The system has created a scheduled task for us.

Cat/etc/cron. d/munin

#
# Cron-jobs for munin
#

MAILTO = root

*/5 * munin test-x/usr/bin/munin-cron &/usr/bin/munin-cron
Configure monitoring options

Next we will tell the program that we need to monitor those hosts. The configuration file is located in/etc/munin. conf.

Vim/etc/munin. conf

# The localhost has been configured.
[Localhost]
Address 127.0.0.1
Use_node_name yes
[New domai]
Address 45.62.xxx.2xx
Use_node_name yes

# Use_node_name yes indicates that the name in [] is used as the host name of the current IP address.
Nginx service

Create a virtual host, bind the domain name munin.phpgao.com, and then bind the root object to/var/www/html/munin!

In order to ensure the normal service at the beginning, the old high commented on the auth segment configuration and will talk about how to use it later.
Server {
Server_name munin.phpgao.com;
# Restrict access
# Auth_basic "Restricted ";
# Auth_basic_user_file/var/www/html/munin/. htpasswd;
Location /{
Alias/var/www/html/munin/; # The path address is the path for configuring htmldir in munin. conf.
    }
}
File

The monitoring end generates four log files every day, and historical files are compressed under the/var/log/munin Directory:

Munin-graph.log
Munin-html.log
Munin-limits.log
Munin-update.log
Screenshot:

Monitoring files

III. Configure the monitored end

Configuration file

The monitored end only needs to install munin-node to generate logs for the monitoring end.

The monitoring end and the monitored end can be the same host or different.
Let's take a look at the node configuration file. The file is long and the part of the screenshot is explained.

Cat/etc/munin/munin-node.conf

Log_file/var/log/munin-node/munin-node.log # directory where logs are generated

Allow ^ 127 \. 0 \. 0 \. 1 $ # IP address whitelist. If it is not a monitoring host, change it to the IP address of the monitoring host.
Allow ^ 222 \. 222 \. 111 \. 111 $ # assume that the monitored IP address is 222.222.111.111

Port 4949 # The listening port, serving the monitoring end
Run

# Restart and start the service
Service munin-node restart

# Check whether enabled
Netstat-lapn | grep 4949

# Run netstat-lapn | grep 4949. perl listens to this port.
# Tcp 0 0: 4949: * LISTEN 22849/perl

# Add the boot script

Chkconfig -- level 35 munin-node on
IV. Waiting for data

After all the above configurations are completed, wait for a moment and data will appear in the background!

Munin background

V. Advanced Settings

Configure permissions

Do you still remember the verification feature used during nginx configuration? Centos is also used in the simple installation tutorial for building awstats.

This function uses the htpasswd command of apache. If bash prompts command not found, use yum install httpd to install it.

Create a verification file with the username phpgao and password hello.

Htpasswd-c/var/www/html/munin/. htpasswd phpgao
# Input hello twice to save the file.
Then we describe the nginx configuration.

Server {
Server_name munin.phpgao.com;
# Restrict access
Auth_basic "Restricted ";
Auth_basic_user_file/var/www/html/munin/. htpasswd;
Location /{
Alias/var/www/html/munin/; # The path address is the path for configuring htmldir in munin. conf.
    }
}
Finally, load nginx

Nginx-t
Service nginx reload
Nginx restart

Munin plugin

Take the memcached plug-in as an example. The plug-in homepage is Memcached-Munin-Plugin.

Download plug-ins
Cd/tmp
Git clone https://github.com/mhwest13/Memcached-Munin-Plugin.git
Copy to plug-in Directory
Cd Memcached-Munin-Plugin
Cp memcached_multi _/usr/share/munin/plugins/memcached_multi _
The following command can check whether the plug-in is successfully installed.

Munin-node-configure -- suggest | grep memcached_multi _

Edit The munin-node configuration file

Vim/etc/munin/plugin-conf.d/munin-node
Add the following content

[Memcached_multi _ *]
Env. host 127.0.0.1
Env. port 11211
Env. timescale 3
Env. cmds get set delete incr decr touch
Env. leitime-1
Create a soft connection
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_bytes'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_commands'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_conns'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_evictions'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_items'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_memory'
Ln-s '/usr/share/munin/plugins/memcached_multi _ ''/etc/munin/plugins/memcached_multi_unfetched'
Restart service
Service munin-node restart
So far, the plug-in configuration is complete. Wait a moment and there will be data!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.