参考博文: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. Java学习第一篇 — 字符串

    package StringTest; public class TestString { public static void main(String[] args){ // String str= ...

  2. 通过IEnumerable接口遍历数据

    使用IEnumerable接口遍历数据,这在项目中会经常的用到,这个类型呢主要是一个枚举器. 1.首先需要让该类型实现一个名字叫IEnumerable的接口,实现该接口的主要目的是为了让当前类型中增加 ...

  3. JS实现抽奖(方形)

    展示: HTML: <div id="table"></div> <div id="btn"> <button onc ...

  4. java获取文件路径

    情况:工程项目没有放到tomcat下,在eclipse运行 1.获取项目根目录,根据在哪里运行 2. 3.从最终生成的.class文件为着手点 4.在controller下

  5. 1145.cn 百度MIP适配实例

    MIP,全称Mobile Instant Pages(移动端即时页面),是百度推出的一套移动端网页开放技术标准.网站移动端页面统计MIP改造,能实现页面缓存,从而达到移动网页加速效果. 百度官方已经明 ...

  6. 使用node.js进行API自动化回归测试

    概述 传统的QA自动化测试通常是基于GUI的,比如使用Selenium,模拟用户在界面上操作.但GUI测试的开发.维护成本和运行的稳定性一直是测试界的老大难问题.投入大量的人力物力开发.维护.运行,却 ...

  7. Javascript异步编程之三Promise: 像堆积木一样组织你的异步流程

    这篇有点长,不过干货挺多,既分析promise的原理,也包含一些最佳实践,亮点在最后:) 还记得上一节讲回调函数的时候,第一件事就提到了异步函数不能用return返回值,其原因就是在return语句执 ...

  8. Tomcat 8默认工具manager管理页面访问配置

    Tomcat 8默认工具manager管理页面访问配置 1. 分配相关的角色权限 需要配置的配置文件是${catalina.home}/conf/tomcat-users.xml先给Tomcat访问相 ...

  9. k-means算法之见解(一)

    k-menas算法之见解 主要内容: 一.引言 二.k-means聚类算法 一.引言: 先说个K-means算法很高大上的用处,来开始新的算法学习.美国竞选总统,选票由公民投出,总统由大家决定.在20 ...

  10. Spark程序数据结构优化

    场景: 1.scala中的对象:对象头是16个字节(包含指向对象的指针等源数据信息),如果对象中只有一个int的属性,则会占用20个字节,也就是说对象的源数据占用了大部分的空间,所以在封装数据的时候尽 ...