如何在Ubuntu和Debian中修改Nagios的前端

时间:2019-08-20 17:58:12  来源:igfitidea点击:

安装下面的步骤安装Nagios VShell

安装php apc

sudo su -

apt-get install php-apc

下载最新的Nagios V Shell

wget http://assets.nagios.com/downloads/exchange/nagiosvshell/vshell.tar.gz

提取vshell.tar.gz

tar -xvzf vshell.tar.gz

切换到提取目录vshell,修改install.php文件

TARGETDIR设置为vshell的路径,/usr/local/vshell。

APACHECONF设置为apache的配置路径(存放vshell.conf的位置).
在Ubuntu和debian中,apache的默认路径是/etc/apache2/conf.d。

cd vshell

vi install.php

define('TARGETDIR',"/usr/local/vshell");

define('APACHECONF',"/etc/apache2/conf.d");

运行脚本install.php

root@ip1019621483:~/vshell# ./install.php
Copying apache configuration file...
Copying vshell configuration file...
Creating web directory...
Copying files...
Cleaning up...
Restarting apache...
* Restarting web server apache2
... waiting ...done.
Checking for file locations...
NOTICE: Objects file found at: /var/cache/nagios3/objects.cache
***Update this location in your /etc/vshell.conf file***
NOTICE: Status file found at: /var/cache/nagios3/status.dat
***Update this location in your /etc/vshell.conf file***
NOTICE: cgi.cfg file found at: /etc/nagios3/cgi.cfg
***Update this location in your /etc/vshell.conf file***
NOTICE: Nagios cmd file found at: /var/lib/nagios3/rw/nagios.cmd
***Update this location in your /etc/vshell.conf file***
Script Complete!

根据nagios的安装,服务器中的文件路径可能不同。

备份vshell.conf文件。

cp -p /etc/vshell.conf  /etc/vshell.conf.`date +%F`.orig

编辑vshell.conf

根据我们的nagios进行设置

BASEURL= "vshell"
COREURL=“nagios3” (这是Nagios仪表板的URL路径)
STATUSFILE=“/var/cache/nagios3/status.dat“
OBJECTSFILE=/var/cache/nagios3/objects.cache“
CGICFG=“/etc/nagios3/cgi.cfg“
NAGCMD=“/var/lib/nagios3/rw/nagios.cmd“
NAGLOCK=“/usr/local/nagios/var” (如果目录不存在,则创建一个)

vshell.conf文件由install.php创建。

root@ip-10-196-214-83:~# cat /etc/apache2/conf.d/vshell.conf 
#modify this file to fit your apache configuration 

Alias /vshell "/usr/local/vshell"

<Directory " usr local vshell">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all

#  Allow from 127.0.0.1

#use the below lines for Nagios XI  
 # AuthName "Nagios Monitor XI"
 #  AuthType Basic
 # AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users
 
 
#Use the below lines for a typical Nagios Core installation  
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   
   
   Require valid-user
</Directory>
root@ip-10-196-214-83:~#

为vshell创建一个新的htpasswd文件

通过该文件可以对vshell进行用户/密码身份验证。

为用户nagiosadmin创建新的htpasswd文件

mkdir -p /usr/local/nagios/etc

htpasswd -m -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

重启apache

/etc/init.d/apache2 restart

打开浏览器,输入vshell的URL

http://nagios服务器IP/nagios3