设为首页 收藏本站
查看: 1019|回复: 0

Nagios监控基础配置(一)

[复制链接]

尚未签到

发表于 2019-1-12 11:53:31 | 显示全部楼层 |阅读模式
  一、搭建Nagios监控服务器
1、部署运行环境LAMP
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl enable httpd
  [root@localhost ~]# yum -y install mariadb-server mariadb
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# mysqladmin -hlocalhost -u root password "123456"
[root@localhost ~]# yum -y install php-mysql php
  2、安装准备:编译工具  创建用户和组
[root@monitor21 /]# rpm -q gcc gcc-c++
[root@monitor21 /]# useradd nagios
[root@monitor21 /]# groupadd nagcmd
[root@monitor21 /]# usermod -G nagcmd nagios
  3、安装源码包   
1)   解包
[root@monitor21 /]# tar -zxf nagios-4.2.4.tar.gz
[root@monitor21 /]# cd nagios-4.2.4/
[root@monitor21 nagios-4.2.4]# ./configure --help | more                          >分页查看帮助信息
[root@monitor21 nagios-4.2.4]# ./configure
  --with-nagios-user=nagios \                      所有者
--with-nagios-group=nagcmd \                从属组
--with-command-user=nagios \                软件执行者
--with-command-group=nagcmd             软件执行的组
  2)  编译
[root@monitor21 nagios-4.2.4]# make all                                         >编译主程序    #做完这步,最好开两个终端方便查看安装
[root@monitor21 nagios-4.2.4]# make install                                 >安装程序
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/                            >主配置文件
[root@monitor21 nagios-4.2.4]# make install-init                               >安装控制脚本
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
   Init script installed
  [root@monitor21 nagios-4.2.4]# cat /etc/rc.d/init.d/nagios                         >系统的脚本文件
  3、【安装】
[root@monitor21 nagios-4.2.4]# make install-commandmode                   >设置文件权限
[root@monitor21 nagios-4.2.4]# make install-config                                  >安装配置
[root@monitor21 nagios-4.2.4]# make install-webconf                              >部署网站配置
[root@monitor21 nagios-4.2.4]# make install-exfoliation                        >页面风格
  4、 查看安装目录及配置文件说明
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/
bin/     etc/     libexec/ sbin/    share/   var/
  [root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/bin/     
nagios                              >验证配置信息
nagiostats                                  >命令行显示监控信息
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/etc/                            >主配置文件目录
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/libexec/                      >监控插件目录   (默认为空)
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/sbin/                          >编译好的脚本文件(二进制)
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/share/                        >网页文件目录
[root@monitor21 nagios-4.2.4]#ls /usr/local/nagios/var/                            >日志目录
  5、安装监控插件
[root@monitor21 nagios-plugins-2.1.4]# tar -zxf /nagios-plugins-2.1.4.tar.gz                      >解包
[root@monitor21 nagios-plugins-2.1.4]# cd /nagios-4.2.4/nagios-plugins-2.1.4/                 >进入目录
[root@monitor21 nagios-plugins-2.1.4]# ./configure && make && make install                    > 源码安装
[root@monitor21 nagios-4.2.4]# ls /usr/local/nagios/libexec/                                               >查看安装的插件
  6、启动nagios监控服务
设置访问监控页面的用户名(nagiosadmin)和密码(自定义)                                            >名字为默认值
  [root@monitor21 nagios-4.2.4]# vim /etc/httpd/conf.d/nagios.conf
52   AuthUserFile /usr/local/nagios/etc/htpasswd.users                                                       >存储访问的用户名和密码
  [root@monitor21 nagios-4.2.4]# which htpasswd                                                        >查看是否有这个命令
/usr/bin/htpasswd
[root@monitor21 nagios-4.2.4]# rpm -qf /usr/bin/htpasswd                                                 >查询那个包提供的
httpd-tools-2.4.6-40.el7.x86_64
  [root@monitor21 nagios-4.2.4]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin     >建web管理用户
New password: 111111                        >输入密码
Re-type new password: 111111                        >验证密码
-c  选项
[root@monitor21 nagios-4.2.4]# cat /usr/local/nagios/etc/htpasswd.users                                                    >查看生成的文件
nagiosadmin:$apr1$UGaLKGiO$GNSYq.O2T6qVQab6aKTWR/
  [root@monitor21 nagios-4.2.4]# systemctl restart httpd                                                                            >重起网站服务
[root@monitor21 nagios-4.2.4]# /etc/rc.d/init.d/nagios start                                                                          >开启nagios服务
[root@monitor21 nagios-4.2.4]# /etc/rc.d/init.d/nagios status                                                                        >查看状态
nagios (pid 3883) is running...
  7、访问监控网页
[root@room1pc33 桌面]# firefox http://192.168.4.21/nagios

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
【下面是主页面】

  三、配置nagios服务
  (默认不用任何配置 就监控本机)
services   监控信息
Current Load                   cpu负载
Current Users                   登入系统的用户数
HTTP                    网站服务运行状态
Root Partition                   根分区
SSH                         监控ssh服务
Swap Usage              交换分区
Total Processes         总的进程数量

  Host Status Totals           监控主机
Service Status Totals      监控资源
  OK                                   正常
WARNING                       警告  
Unknown                         不知道
Critical                       严重错误
Pending                          监控中
[img]http://blog.运维网.com/13560729/





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662336-1-1.html 上篇帖子: centos安装nagios服务(测试可用) 下篇帖子: Nagios监控基本配置(二)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表