参考博文:https://www.howtoing.com/ubuntu-nagios/

该博文真实有效可供参考,按照步骤,基本可以成功

一.安装的先决条件

sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip

二.用户和组配置

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data

三.安装nagios

1.下载提取Nagios核心

cd ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz
tar -xzf nagios*.tar.gz
cd nagios-4.2.0

2.编译nagios

./configure --with-nagios-group=nagios --with-command-group=nagcmd

make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf

并将evenhandler目录复制到nagios目录中:

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

3.安装Nagios插件

下载提取nagios插件:

cd ~
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
tar -xzf nagios-plugins*.tar.gz
cd nagios-plugin-2.1.2/

以下命令安装nagios插件:

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install

4.配置nagios

安装阶段完成后,您可以在/ usr / local / nagios /中找到Nagios的默认配置。

我们将配置Nagios和Nagios联系人。

使用vim编辑默认的nagios配置:

vim /usr/local/nagios/etc/nagios.cfg

取消注释线路51为主机监视器配置。

cfg_dir=/usr/local/nagios/etc/servers

保存并退出。

添加名为servers的新文件夹:

mkdir -p /usr/local/nagios/etc/servers

可以在contact.cfg文件中配置Nagios联系人。 打开它使用:

vim /usr/local/nagios/etc/objects/contacts.cfg

然后用您自己的电子邮件替换默认电子邮件。

四、配置Apache

1. 启用Apache模块

sudo a2enmod rewrite
sudo a2enmod cgi

您可以使用htpasswd命令为nagios Web界面配置用户nagiosadmin:

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

并输入密码

2. 启用Nagios虚拟主机

sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/

3.启动Apache和Nagios

service apache2 restart
service nagios start

当Nagios启动时,您可能会看到以下错误:

Starting nagios (via systemctl): nagios.serviceFailed

cd /etc/init.d/
cp /etc/init.d/skeleton /etc/init.d/nagios vim /etc/init.d/nagios 并添加以下代码:
DESC="Nagios"
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS="-d /usr/local/nagios/etc/nagios.cfg"
PIDFILE=/usr/local/nagios/var/$NAME.lock 使其可执行并启动Nagios: chmod +x /etc/init.d/nagios
service apache2 restart
servuce nagios start 五、测试Nagios服务器

在我的情况下,请打开浏览器并访问Nagios服务器ip: http : //192.168.126.130/nagios 。

 Nagios用apache htpasswd登录

用户名默认为nagiosadmin
密码就是你之前通过执行该 sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 命令输入的密码 六、添加主机监控
在我的另外IP:192.168.126.128
连接我的另外主机 1. 连接到ubuntu主机
ssh root@192.168.126.128
2.安装NRPE服务
sudo apt-get install nagios-nrpe-server nagios-plugins
3.配置NRPE
vim /etc/nagios/nrpe.cfg
并将nagios server IP 192.168.126.130添加到server_aaddress server_address = 192.168.126.130
4.重新启动NRPE
service nagios-nrpe-server restart
5.将Ubuntu主机添加到Nagios服务器
请连接到Nagios服务器:
ssh root@192.168.126.130 然后为/ usr / local / nagios / etc / servers /中的主机配置创建一个新文件。
vim /usr/local/nagios/etc/servers/ubuntu_host.cfg
添加如下内容:
# Ubuntu Host configuration file

define host {
use linux-server
host_name ubuntu_host
alias Ubuntu Host
address 192.168.1.10
register 1
} define service {
host_name ubuntu_host
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
} define service {
host_name ubuntu_host
service_description Check Users
check_command check_local_users!20!50
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
} define service {
host_name ubuntu_host
service_description Local Disk
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
} define service {
host_name ubuntu_host
service_description Check SSH
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
} define service {
host_name ubuntu_host
service_description Total Process
check_command check_local_procs!250!400!RSZDT
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}

您可以在/usr/local/nagios/etc/objects/commands.cfg文件中找到许多check_command 。 如果您想添加更多的服务,如DHCP,POP等,请参阅

现在检查配置:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

6.重新启动所有服务

在Ubuntu主机上启动NRPE服务:

service nagios-nrpe-server restart

...在Nagios服务器上,启动Apache和Nagios:

service apache2 restart
service nagios restart

7.测试Ubuntu主机

从浏览器打开Nagios服务器,并查看受监控的ubuntu_host。

Ubuntu主机在受监控的主机上可用。

 

ubuntu16.04安装配置nagios的更多相关文章

  1. Ubuntu16.04安装配置和使用ctags

    Ubuntu16.04安装配置和使用ctags by ChrisZZ ctags可以用于在vim中的函数定义跳转.在ubuntu16.04下默认提供的ctags是很老很旧的ctags,快要发霉的版本( ...

  2. Ubuntu16.04安装配置Caffe教程(GPU版)

    推荐博客:https://www.linuxidc.com/Linux/2017-11/148629.htmhttps://blog.csdn.net/yggaoeecs/article/detail ...

  3. Ubuntu16.04 安装配置Caffe

    Caffe已经是第三次安装配置了,为什么是第三次呢?因为我实在是低估了深度学习对于硬件的要求.第一次我在自己笔记本上配置的单核,CPU only ...  结果是,样例数据跑了4小时,这还怎么玩?第二 ...

  4. Ubuntu16.04安装配置sublime text3

    1.安装Sublime Text 3 首先添加sublime text 3的仓库: sudo add-apt-repository ppa:webupd8team/sublime-text-3 根据提 ...

  5. ubuntu16.04 安装配置matlab+python +cuda8.0+cudnn+opencv3.1的caffe环境

    网络上有很多ubuntu上caffe配置环境的帖子,本人照着其中的许多进行了参考,都出现了或多或少的错误,很多地方也有差异. 于是自己整理了下自己的安装过程,成功进行了测试,跑通了faster-rcn ...

  6. Ubuntu16.04安装配置Eclipse 以及opencv的使用

    安装配置http://www.oracle.com下载与自己电脑系统对应的JDK.我下载的是jdk-8u101-linux64.tar.gz 解压:sudo tar -zxvf jdk-8u101-l ...

  7. ubuntu16.04安装配置mysql数据库,分割视频为帧图像

    参考http://wiki.ubuntu.org.cn/MySQL%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97 版本为5.7 一.安装 安装命令sudo apt-get i ...

  8. Ubuntu16.04安装Redis并配置

    Ubuntu16.04安装Redis并配置 2018年05月22日 10:40:35 Hello_刘 阅读数:29146   Ubuntu16.04安装Redis并配置 1):安装: 1:终端命令下载 ...

  9. Ubuntu16.04安装后开发环境配置和常用软件安装

    Ubuntu16.04安装后1.安装常用软件搜狗输入法+编辑器Atom+浏览器Chome+视频播放器vlc+图像编辑器GIMP Image Editor安装+视频录制软件RcordMyDesktop安 ...

随机推荐

  1. scala中的isInstanceOf和asInstanceOf

    如果实例化了子类的对象,但是将其赋予了父类类型的变量, 在后续的过程中,又需要将父类类型的变量转换为子类类型的变量,应该如何做? Ø  首先,需要使用isInstanceOf 判断对象是否为指定类的对 ...

  2. Java学习笔记之——冒泡排序

    冒泡排序:解决数组的排序问题,比如从大到小或者从小到大 原理:两两比较 案例:

  3. power of the test

    https://www.youtube.com/watch?v=UApFKiK4Hi8

  4. javascript基于对象的弹出框封装

    先睹为快,移动端:戳这里,打开页面后点击投票查看效果.PC端测试直接切换body的overflow属性:hidden和auto一样可以,比下面相对简化,又有人说这样偶尔不行..如果你知道优缺点欢迎给出 ...

  5. python爬虫简单代码爬取郭德纲单口相声

    搜索老郭的单口相声,打开检查模式,刷新 没有什么有价值的东东, 不过....清掉内容, 点击一个相声,再看看有些什么 是不是发现了些什么 我们来点击这个看看, 首先看一下headers, 这个url是 ...

  6. 百度地图坐标偏移,微信小程序地图偏移问题,腾讯地图坐标偏移

    解决方案: 如果用百度的地图获取的坐标点,在微信小程序内使用,就会出现偏移 算法(lat和lng是经纬度,球面坐标): To_B是转到百度,To_G是转到GCJ-02(谷歌,高德,腾讯) var TO ...

  7. canvas处理压缩照片并回显:https://cengjingdeshuige.oss-cn-beijing.aliyuncs.com/20180512/cannovs%E5%AD%A6%E4%B9%A0.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. lfs(systemd版本)学习笔记-第4页

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! lfs(systemd版本)学习笔记-第3页 的地址:https://www.cnblogs.com/renren-study- ...

  9. create pdf file using Spire.Pdf or iTextSharp or PdfSharp

    Spire.Pdf: 注:pdf 显示中文一定要设置相应的中文字体,其他外文类似.否则显示为乱码( 如果繁体的服务器上生成的中文内容PDF文档,在简体操作系统保存或并传给简体系统上查看,会存在乱码问题 ...

  10. [工作总结]jQuery在工作开发中常用代码片段集锦(1-10)

    1.jQuery,JS实现tab切换 原生JS实现 HTML代码如下: <div class="wrap"> <ul id="tag"> ...