Nagiosgraph 组件安装

官方介绍:

https://exchange.nagios.org/directory/Addons/Graphing-and-Trending/nagiosgraph/details#_ga=1.41004834.1827091096.1474275709

 

下载地址:

http://nagiosgraph.sourceforge.net/

 

下载Nagiosgraph

[root@vnagios tmp]# wget http://nchc.dl.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz

解压

[root@vnagios tmp]# tar vzxf nagiosgraph-1.5.2.tar.gz

按照readme安装环境软件包

[root@vnagios nagiosgraph-1.5.2]# yum install perl-rrdtool perl-GD

检查环境

[root@vnagios nagiosgraph-1.5.2]# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.26
  CGI... ***FAIL***
  Data::Dumper...2.145
  Digest::MD5... ***FAIL***
  File::Basename...2.84
  File::Find...1.20
  MIME::Base64...3.13
  POSIX...1.30
  RRDs...1.4008
  Time::HiRes...1.9725
checking optional PERL modules
  GD...2.49
  Nagios::Config... ***FAIL***
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd

*** one or more problems were detected!

第一个错误
CGI… ***FAIL***

直接yum 安装

[root@vnagios nagiosgraph-1.5.2]# yum -y install perl-CGI

再次运行检查

[root@vnagios nagiosgraph-1.5.2]# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.26
  CGI...3.63                                     /修复
  Data::Dumper...2.145
  Digest::MD5... ***FAIL***
  File::Basename...2.84
  File::Find...1.20
  MIME::Base64...3.13
  POSIX...1.30
  RRDs...1.4008
  Time::HiRes...1.9725
checking optional PERL modules
  GD...2.49
  Nagios::Config... ***FAIL***
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd

*** one or more problems were detected!

接下来修复

Digest::MD5... ***FAIL***
[root@vnagios nagiosgraph-1.5.2]# yum install perl-Digest-MD5

再次检查下:

[root@vnagios nagiosgraph-1.5.2]# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.26
  CGI...3.63
  Data::Dumper...2.145
  Digest::MD5...2.52
  File::Basename...2.84
  File::Find...1.20
  MIME::Base64...3.13
  POSIX...1.30
  RRDs...1.4008
  Time::HiRes...1.9725
checking optional PERL modules
  GD...2.49
  Nagios::Config... ***FAIL***
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd

还有一个错误

Nagios::Config... ***FAIL***

参考文档:http://superuser.com/questions/744152/nagiosgraph-installation-error

先运行yum -y install perl-CPAN
然后运行cpan Nagios::Config

发现无法成功,查询文档先要运行

cpan Module::Build

再次检查

[root@vnagios nagiosgraph-1.5.2]# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.26
  CGI...3.63
  Data::Dumper...2.145
  Digest::MD5...2.52
  File::Basename...2.84
  File::Find...1.20
  MIME::Base64...3.13
  POSIX...1.30
  RRDs...1.4008
  Time::HiRes...1.9725
checking optional PERL modules
  GD...2.49
  Nagios::Config...36
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd

已经没有错误了,可以进行下一步了

 

将nagiosgraph 安装到/usr/local/nagiso目录

 

[root@vnagios nagiosgraph-1.5.2]# ./install.pl --prefix=/usr/local/nagios

Nagios 监控windows 主机

之前我们装完nagios core ,我们查看host 页面只有一个主机,就是nagios 服务器本身

nagios3

 

现在我们来让nagios 监控window 主机
1. 编辑nagios 配置文件

vi /usr/local/nagios/etc/nagios.cfg

找到

#cfg_file=/usr/local/nagios/etc/objects/windows.cfg

去掉前面的”#”

2.编辑被监控主机的监控配置文件

vi /usr/local/nagios/etc/objects/windows.cfg

找到

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       winserver       ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         192.168.146.1   ; IP address of the host
        }

修改IP地址以及主机名

3. 主机上安装agent NSClient++
下载地址:
https://sourceforge.net/projects/nscplus/

下载完成后双击安装。

4.配置nsclient++

找到配置文件nsclient.ini
找到并且编辑正确的IP地址
; ALLOWED HOSTS – A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 192.168.146.136

5.重启nagios服务

[root@vnagios ~]# /etc/init.d/nagios restart
Restarting nagios (via systemctl):                         [  OK  ]
[root@vnagios ~]#

刷新页面可以看到已经可以看到windows 主机了

nagios4

Nagios Core 安装

Nagios

Nagios

 

 

 

 

 

 

 

参考官方安装文档

安装系统Centos7

[root@vnagios ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

1. 安装需要用到的软件包:

yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip

2. 下载nagios

cd /tmp
wget http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.2.3/nagios-4.2.3.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.1.4.tar.gz

3.添加用户以及组

[root@vnagios ~]# useradd nagios
[root@vnagios ~]# groupadd nagcmd
[root@vnagios ~]# usermod -a -G nagcmd nagios
[root@vnagios ~]# usermod -a -G nagios,nagcmd apache

4. 解压nagios core安装包

[root@vnagios tmp]# tar vzxf nagios-4.2.3.tar.gz
[root@vnagios tmp]# tar vzxf nagios-plugins-2.1.4.tar.gz

5. 编译安装

[root@vnagios nagios-4.2.3]# ./configure --with-command-group=nagcmd
make all
make install 
make install-init 
make install-config 
make install-commandmode 
make install-webconf 
[root@vnagios nagios-4.2.3]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@vnagios nagios-4.2.3]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

检查下:

[root@vnagios nagios-4.2.3]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

启动nagios

[root@vnagios nagios-4.2.3]# /etc/init.d/nagios start
Reloading systemd:                                         [  OK  ]
Starting nagios (via systemctl):                           [  OK  ]
启动apache
[root@vnagios nagios-4.2.3]# service httpd start
Redirecting to /bin/systemctl start  httpd.service

设置访问密码账号
.
[root@vnagios nagios-4.2.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

配置nagios plugin

[root@vnagios nagios-4.2.3]# cd /tmp/nagios-plugins-2.1.4
[root@vnagios nagios-plugins-2.1.4]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
make 
make install

配置 nagios 服务

chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --level 35 httpd on

尝试访问下:
http:///nagios

这里地址为:http://192.168.146.136/nagios/

 

nagios2