Monitor Linux server performance with Munin

Source: Internet
Author: User

Monitoring the performance of LINUX Hosts is a complex operation, which depends on command line tools and centralized data. Analysis may be very difficult, and a large amount of data is required to establish a relationship to draw a conclusion. Fortunately, we can use some existing tools to build a model for this process, making data analysis easier. Next, we can see a tool called Munin, which represents the memory and the name of a crow of the Odin God ).

Munin is a tool that collects data and graphical data through the client-server architecture. Munin allows you to track the running records of your host, that is, the so-called 'node', and then send them to the central server, where you can then display them as images. Here you can see an example of displaying disk IO information in the Munin graphic interface:

Munin can be quickly and easily installed on most Linux systems through the installation package. In red hat and Ubuntu/Debian, you need a combination of Munin, munin-node, and munin-common installation packages. Suppose you still need to monitor the server.) take red hat as an example:

$ yum install munin munin-common munin-node

Install Munin and put its configuration file under the/etc/munin directory. Let's start with configuring the munin server. The main server configuration file is munin. conf, which controls server settings and configuration information for each node. In most cases, you can use the default settings, but you should also know the other options: dbdir, htmldir, logdir, and rundir.

The Dbdir setting determines the directory in which munin stores the collected RRD statistics. In the Red Hat and ubuntu systems, the data is stored in the/var/lib/munin directory by default.

The Htmldir setting controls the location of the output data of munin. It displays the graphic interface in html files. In the Red Hat system, the files are stored in the/var/www/html/munin directory by default, while those in ubuntu are stored in the/var/cache/munin/www directory. This directory is the directory we generally use for Web server services, such as Apache. One of the best operations is to use the Apache Virtual Host to create a virtual host that can be used to visually display the node status:

<VirtualHost *:80>     ServerAdmin webmaster@localhost     ServerName   munin.example.com     DocumentRoot /var/www/html/munin     <Directory />         Options FollowSymLinks         AllowOverride None     </Directory>     LogLevel notice     CustomLog /var/log/apache2/munin.access.log combined     ErrorLog /var/log/apache2/munin.error.log     ServerSignature On</VirtualHost>

Logdir and rundir settings control the location of the munin log files and pid files.

Finally, we must define all node hosts that will send reports to the server in the munin. conf file. The command is:

[hostname.example.com]  address 10.0.0.1  use_node_name yes [hostname2.example.com]  address 10.0.0.2  use_node_name yes

The name of each node is in brackets, followed by its IP address. The use_node_name command controls the way munin naming nodes. If yes is followed by the value in parentheses, if no, a DNS query is executed. In addition, you can use the includedir option to name a separate directory. munin will load all the files here, for example:

includedir /etc/munin/munin-conf.d/

I often use puppet to export resources to manage munin configurations. First, create an independent file on each puppet client, and then use munin to load node information in the file.

In this step, the server has been configured. Next we need to configure the node. Install the munin-node package on each node and configure the munin-node.conf file under the/etc/munin directory. Most configuration information does not need to be changed, but you need to change the allow option, which controls which host can access munin and retrieve statistics. We use an IP address to configure the munin server. For example:

allow ^10\.0\.0\.100$

As you can see, IP addresses must be entered in common perl formats. If you have more than one munin server, you can use multiple lines to allow commands to define them.

Each munin node uses tcp port 4949 to communicate with the munin server, so you must ensure that this port is opened on the host firewall, in addition, data can pass through any firewall between nodes and servers. You can define this port number in the port option in the munin-node.conf file.

In addition to the basic settings, we also need to specify the node data to be collected. Munin uses the plug-in program architecture to define monitoring content. For example, there are plug-ins dedicated to CPU monitoring, as well as various plug-ins that monitor loads, memory, and other content. The list of all Munin plug-ins can be found in the/etc/munin/plugins directory, which are displayed in the form of sym-links linked to the plug-in. The process of adding a plug-in to munin is to write the link of the plug-in file to the/etc/munin/plugins directory. If the plug-in requires a configuration, for example, to define the user required to run the plug-in, you can find the configuration file in the/etc/munin/plugins. conf. d directory.

Munin contains a lot of content by default. You may not need to change the Initial Basic settings because they already provide sufficient data collection. Munin also provides a large number of useful plug-ins, and you can find many plug-ins that others can communicate with in the community. You can easily develop new plug-ins in a language you are familiar.

Finally, run the munin-node init script to start the munin server and node.

$ sudo /etc/init.d/munin-node start

In this way, you can start munin monitoring and collect the required data. The munin control periodically views the data of each node and then uploads it to the munin server. Then you can view the result data through the Web Service controlled by munin.

That's all about it. Now you can view the behavior status of your server in a graphical interface, and detect performance trends and possible problems. If you think munin is not suitable for you, you can also consider using another tool called collected, which is similar to munin. It is written in C language and provides better functions than munin. It requires the installation of additional software to obtain these features, but it is also a good platform for reference.

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.