Ubuntu 17.04服务器上安装并配置Munin监控工具

介绍

Munin是一个监控工具,可以帮助分析资源趋势,通过Web界面在图形中显示信息。而且安装时就已经有大量的插件可用。

正如Munin官方网页上所述,“使用Munin,您可以轻松监控您的计算机,网络,SANs,应用程序,天气测量以及任何你能想到的性能。当性能问题出现时,可以很容易地确定“今天有什么不同”。。

Munin围绕客户端 - 服务器架构进行设计,可以配置为监视其安装的机器(称为Munin主机)和/或任意数量的客户机(也称为Munin节点)。

入门

安装Apache Web Server

首先,我们需要一个运行的Web服务器。 Munin可以运行许多网络服务器,如Nginx和Lighttpd,但默认情况下,它是用Apache运行的。今天我们将安装和使用Apache。 Apache在Ubuntu存储库中可用,因此执行以下apt命令来访问它:

#apt-get install -y apache2 apache2-utils

关于Munin的好处是它以图形格式显示信息。那些想要放大生成图形的人必须确保dynazoom功能正常工作。这意味着我们需要安装以下软件包:

 
# apt-get install -y libcgi-fast-perl libapache2-mod-fcgid

一旦安装过程完成,我们就必须确保启用了fcgid模块。使用以下命令检查:

$ /usr/sbin/apachectl -M | grep -i cgi

输出应如下所示:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

fcgid_module (shared)

第一行只是一个警告。 您可以忽略该消息。 事实上,Apache将与Munin一起工作,即使有这个“问题”。

如果没有看到fcgid_module(共享)部分,这意味着该模块被禁用,因此,通过执行以下命令启用它:

扫描二维码关注公众号,回复: 2008995 查看本文章
# a2enmod fcgid

安装并配置 Munin

Apache正确安装并运行。 您可以使用systemctl检查其状态:

# systemctl status apache2

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: 
  Drop-In: /lib/systemd/system/apache2.service.d
           apache2-systemd.conf
   Active: active (running) 

安装 Munin

现在是在Munin大师上安装和配置Munin的时候了。 我们将通过执行apt来安装Ubuntu存储库中的版本:

# apt-get install munin

配置Munin

Munin配置文件存储在/etc/munin目录中。 使用文本编辑器打开主配置文件(munin.conf):

# $EDITOR /etc/munin/munin.conf

该文件的结构与全局部分和一个(或更多,这取决于您的配置)主机部分。 搜索以下行:

#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

更改这行如下:

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

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

保存并退出。

创建/var/www/munin目录,如下所示:

# mkdir -p /var/www/munin

更改其所有者,如下所示:

# chown munin:munin /var/www/munin/

重新打开Munin主配置文件/etc/munin/munin.conf并查找以下行:

[localhost.localdomain]
    address 127.0.0.1
    use_node_name yes

用MasterServerMunin替换localhost.localdomain。
保存并退出。

在 /etc/munin目录中,编辑apache.conf文件:

# $EDITOR /etc/munin/apache.conf

在那里,编辑第一行如下:

Alias /munin /var/www/munin

接下来,搜索并编辑以下模块:

<Directory /var/www/munin>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1
        #Options None

        Require all granted
         Options FollowSymLinks SymLinksIfOwnerMatch
.............................................
        
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault M310
    </IfModule>

</Directory>

接下来编辑以下两个模块:

<Location /munin-cgi/munin-cgi-graph>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1
        # AuthUserFile /etc/munin/munin-htpasswd
        # AuthName "Munin"
        # AuthType Basic
        # require valid-user
        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

        <IfModule mod_fcgid.c>
            SetHandler fcgid-script
        </IfModule>
        <IfModule !mod_fcgid.c>
            SetHandler cgi-script
        </IfModule>
</Location>

ScriptAlias /munin-cgi/munin-cgi-html /usr/lib/munin/cgi/munin-cgi-html
<Location /munin-cgi/munin-cgi-html>
        #Order allow,deny
        #Allow from localhost 127.0.0.0/8 ::1
        # AuthUserFile /etc/munin/munin-htpasswd
        # AuthName "Munin"
        # AuthType Basic
        # require valid-user
        
        Require all granted
        Options FollowSymLinks SymLinksIfOwnerMatch

        <IfModule mod_fcgid.c>
            SetHandler fcgid-script
        </IfModule>
        <IfModule !mod_fcgid.c>
            SetHandler cgi-script
        </IfModule>
</Location>

保存并退出。

 

重新启动Apache和Munin:

# systemctl restart apache2
# systemctl restart munin-node

现在,通过使用Web浏览器访问URL http://your-domain-or-ip-address/munin,您可以访问Munin Web界面。

总结

使用Munin,监控系统变得更加容易,特别是由于用于显示数据的图形输出系统。 本教程演示了Munin主机的安装,但是如介绍中所述,还可以添加和监视Munin节点并监视远程系统。

猜你喜欢

转载自www.linuxidc.com/Linux/2017-07/145700.htm