版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/X__Alone/article/details/80499930
下载nagios的相关安装包 将下载的包放到该目录下 cd /usr/local/src
wget http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz wget http://nagios-plugins.org/download/nagios-plugins-1.4.16.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar zxvf nagios-3.5.0.tar.gz
cd nagios
./configure --prefix=/usr/local/install/nagios --with-group=nagios --with-user=nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
make all
make install
make install-init
make install-config
make install-commandmode
PS: make install 用于安装主要的程序、CGI及HTML文件 make install-init 用于生成init启动脚本 make install-config 用于安装示例配置文件 make install-commandmode 用于设置相应的目录权限 修改/usr/local/install/nagios/etc/objects/contacts.cfg 更改nagiosadmin 的联系人定义信息中的 Email 信息为你的 Email 以接收报警内容。 PS: bin–Nagios执行程序所在目录,其中的nagios文件即为主程序。 etc–Nagios配置文件位置 sbin–Nagioscgi文件所在目录,也就是执行外部命令所需文件所在的目录 Share–Nagios网页文件所在的目录 var–Nagios日志文件、spid 等文件所在的目录 var/archives–日志归档目录 var/rw–用来存放外部命令文件
cd /usr/local/src
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --prefix=/usr/local/install/nagios --with-nagios-user=nagios --with-nagios-group=nagcmd
make &&make install
这里make &&make install可能会出这种错误
按提示说的找到删除stdio.in.h文件,可以使用find命令查找。然后删除提示说的 _GL_WARN_ON_USE (gets, “gets is a security hole - use fgets instead”)这一行。可使用命令sed -i ‘/gets is a security/d‘ gl/stdio.in.h删除 验证Nagios插件是否正确安装 ls /usr/local/install/nagios/libexec #显示安装的插件文件
配置Apache配置文件:/usr/local/apache2.4/conf/httpd.conf 将user和group改为nagios
增加代码段:
ScriptAlias /nagios/cgi-bin "/usr/local/install/nagios/sbin"
<Directory "/usr/local/install/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
# Require valid-user
</Directory>
Alias /nagios "/usr/local/install/nagios/share"
<Directory "/usr/local/install/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
# Require valid-user
</Directory>
检查nagios配置文件有没有问题 /usr/local/install/nagios/bin/nagios -v /usr/local/install/nagios/etc/nagios.cfg
重启Apache和nagios /usr/local/apache2.4/bin/apachectl restart service nagios start
打开页面遇到的问题:、 1. 页面出现乱码 在Apache的配置文件中httpd.conf,把这两个注释去掉