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

nagios监控安装及使用1

[复制链接]

尚未签到

发表于 2019-1-14 11:12:55 | 显示全部楼层 |阅读模式
  1 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好。
  [root@server1 nagios]#yum install gd-devel -y
  [root@server1 nagios]#yum install gcc automake autoconf libtool make(安装make)
  [root@server1 nagios]#yum install gcc gcc-c++ (安装g++)
  2 部署lamp环境
  [root@server1 nagios]# yum install httpd mysql mysql-server php php-mysql -y
  3 安装主程序nagios
  [root@server1 nagios]# tar fvxz nagios.tar.gz
  [root@server1 nagios]# ./configure --prefix=/usr/local/nagios
  [root@server1 nagios]# useradd nagios(注意添加一个用户nagios)
  [root@server1 nagios]# make all
  [root@server1 nagios]# make install
  
  make install
  - This installs the main program, CGIs, and HTML files
  make install-init
  - This installs the init script in /et c/rc.d/init.d
  make install-commandmode
  - This installs and configures permissions on the
  directory for holding the external command file
  make install-config
  - This installs *SAMPLE* config files in /usr/local/nagios/etc
  You'll have to modify these sample files before you can
  use Nagios. Read the HTML documentation for more info
  on doing this. Pay particular attention to the docs on
  object configuration files, as they determine what/how
  things get monitored!
  make install-webconf
  - This installs the Apache config file for the Nagios
  web interface
  4在apache中添加监控用户nagios
  vim /etc/httpd/conf/httpd.conf
  User nagios
  Group nagios
  重新启动apache
  service httpd restart
  service nagios start(重启nagios服务)
  生成用户(现在就可以登陆http://localhost/nagios看到nagios软件了)但是需要账号和密码
  5创建登陆nagios密码
  root@server1 nagios-3.2.0]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
  New password:
  Re-type new password:
  Adding password for user nagios
  给nagios
  6用户开权限,让他能够查看信息!
  [root@server1 nagios-3.2.0]# vim /usr/local/nagios/etc/cgi.cfg
  :%s/\(nagios\)admin/&,\1/
  在所有的nagiosadmin后面添加nagios
  本机为什么是down的状态???
  监控分析控制台  ---------------主程序
  插件
  --------------被监控主机
  [root@server1 libexec]# pwd
  /usr/local/nagios/libexec
  [root@server1 libexec]# ls
  [root@server1 libexec]#
  插件目录下什么没有有阿!
  7安装插件
  [root@server1 nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios/
  可选的选项--with-gnutls --with-openssl --enable-extra-opts --enable-perl-modules
  make
  make install
  8怎样监控的更多!???
  [root@server1 etc]# pwd
  /usr/local/nagios/etc
  [root@server1 etc]# vim nagios.cfg
  编辑主配置文件
  cfg_file=/usr/local/nagios/etc/objects/commands.cfg
  cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
  cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
  cfg_file=/usr/local/nagios/etc/objects/templates.cfg
  通过上面的语句来调用那些配置文件
  [root@server1 objects]# pwd
  /usr/local/nagios/etc/objects
  1)时间timeperiods.cfg
  define timeperiod{
  timeperiod_name 24x7
  alias      24 Hours A Day, 7 Days A Week
  sunday     00:00-24:00
  monday     00:00-24:00
  tuesday     00:00-24:00
  wednesday    00:00-24:00
  thursday    00:00-24:00
  friday     00:00-24:00
  saturday    00:00-24:00
  }
  2)插件commands.cfg
  define command{
  command_name check-host-alive
  command_line  $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
  }
  3)监控谁localhost.cfg
  define host {
  host_name    fudong
  alias  test
  address     192.168.18.50
  check_command  check-host-alive
  notification_options  d,u,r
  check_interval 1
  max_check_attempts   2
  contact_groups admins
  notification_interval  10
  notification_period   24x7
  }
  4)联系人contacts.cfg
  define contact {
  contact_name kyo
  alias      kyo
  host_notification_period    24x7
  host_notification_options    d,u,r
  service_notification_period 24x7
  service_notification_options  w,u,c,r
  service_notification_commands  notify-service-by-email
  host_notification_commands   notify-host-by-email
  email  root@163.com
  }
  define contactgroup{
  contactgroup_name    admins
  alias          Nagios Administrators
  members         nagiosadmin,kyo
  }
  5)检查错误 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  6)定义服务
  define service {
  host_name    fudong
  service_description   apache
  check_period  24x7
  normal_check_interval  2
  retry_check_interval  1
  max_check_attempts   5
  notification_period   24x7
  notification_options  w,u,c,r
  check_command  check_http
  }
  到此,一个完整的nagios就完全建立完了


运维网声明 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-663128-1-1.html 上篇帖子: nagios 插件脚本监控esxi 存储磁盘 小意外 下篇帖子: nagios 报CHECK_NRPE: Error
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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