参考博文: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. [日常] Go语言圣经-字节切片与字符串

    1.一个字符串是一个不可改变的字节序列2.文本字符串通常被解释为采用UTF8编码的Unicode码点(rune)序列3.内置的len函数可以返回一个字符串中的字节数目4.第i个字节并不一定是字符串的第 ...

  2. 使用Swagger2时遇到的问题

    Swagger2使用起来很简单,加一个@EnableSwagger2注解,并引入如下依赖就ok了 <dependency> <groupId>io.springfox</ ...

  3. spring boot 之 Mybatis 配置

    ############################## mybatis配置 ######################################mybatis.configuration ...

  4. iomanip的作用 C++

    c++程序里面经常见到下面的头文件 #include <iomanip> 这里面iomanip的作用比较多: 主要是对cin,cout之类的一些操纵运算子,比如setfill,setw,s ...

  5. SVN多项目并行版本管理解决方案

    1.背景 随着公司业务拓展,各业务部门频繁的需求变更,导致系统集成冲突的问题日益突出. 2.现状 基于SVN版本管理模式,多分支版本并行,分支合并主干交付.多分支开发存在依赖关系且有交付的先后顺序, ...

  6. 【读书笔记】iOS-设计简单的Frenzic式益智游戏

    如果你决定用UIView动画或Core Animation,一定要编写一些测试用例,模拟游戏可能遇到的要求最高的动画,另外不要忘记播放声音.不要等到最后才增加声音,因为在iPhone上播放音乐和音效确 ...

  7. Nginx 负载均衡原理简介与负载均衡配置详解

    Nginx负载均衡原理简介与负载均衡配置详解   by:授客  QQ:1033553122   测试环境 nginx-1.10.0 负载均衡原理 客户端向反向代理发送请求,接着反向代理根据某种负载机制 ...

  8. 理解ES6中的Promise

    一.Promise的作用 在ajax请求数据的过程中,我们可以异步拿到我们想要的数据,然后在回调中做相应的数据处理. 这样做看上去并没有什么麻烦,但是如果这个时候,我们还需要做另外一个ajax请求,这 ...

  9. Scrum敏捷开发沉思录

    计算机科学的诞生,是世人为了用数字手段解决实际生活中的问题.随着时代的发展,技术的进步,人们对于现实世界中的问题理解越来越深刻,描述也越来越抽象,于是对计算机软件的需求也越来越高,越来越复杂,变化也越 ...

  10. mybatis学习系列--逆向工程简单使用及mybatis原理

    2逆向工程简单测试(68-70) SqlSessionFactory sqlSessionFactory=getSqlSessionFactory(); SqlSession session = sq ...