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

[经验分享] How to Install a Production Ready Naemon Monitoring Server-Arnold

[复制链接]

尚未签到

发表于 2018-10-20 11:50:13 | 显示全部楼层 |阅读模式
  Naemon is the new monitoring suite that aims to be fast, stable and innovative while giving you a clear view of the state of your network and applications.This is a replacement for nagios server and very stable and uses an amazing dashboard called thruk. Setting up naemon is very easy and has live status inbuild .In this tutorial, I will show you how to install and configure naemon in a production environment along with pnp4nagios for graphs. Naemon is very stable, I will show you how to maintain the configs in a large scale environment.
  In this tutorial, I will be using four Servers

  •   192.168.1.170 - Naemon Server - centos 7
  •   192.168.1.21 - nrpe client - centos 6
  •   192.168.1.182 - nrpe client - ubuntu
  •   192.168.1.75 - nscp client - windows server 2012R2
Installation of Naemon Server
  I am using a CentOS 7 host with a minimal installation, SELinux disabled and firewalld enabled.
[root@naemon ~]# sestatus  
SELinux status:                 disabled
  
[root@naemon ~]#
  Installing the repo:
  [root@naemon ~]# yum -y install https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
  enabling the epel repo:
  yum -y install epel-release
  Installing the Naemon package:
  [root@naemon ~]# yum install naemon*
  Naemon uses the same Nagios plugin and nrpe to monitor hosts. We will now install them:
  [root@naemon ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -y
  We will add the firewall rules:
   [root@naemon ~]# firewall-cmd --add-service=http --permanent  
success
  
[root@naemon ~]# firewall-cmd --add-service=https --permanent
  
success
  
[root@naemon ~]# firewall-cmd --reload
  
success
  
[root@naemon ~]# firewall-cmd --list-all
  
public (active)
  
  target: default
  
  icmp-block-inversion: no
  
  interfaces: eno16777736
  
  sources:
  
  services: dhcpv6-client http https ssh
  
  ports:
  
  protocols:
  
  masquerade: no
  
  forward-ports:
  
  sourceports:
  
  icmp-blocks:
  
  rich rules:
  

  
[root@naemon ~]#
  Installation of pnp4nagios.
  yum install gcc-c++ rrdtool perl-Time-HiRes perl-rrdtool php-gd php php-cli wget
  Downloading pnp4nagios.
[root@naemon ~]# wget https://svwh.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz  
    [root@naemon ~]# tar -zxvf pnp4nagios-0.6.25.tar.gz
  
    [root@naemon ~]# cd pnp4nagios-0.6.25/
  
[root@naemon pnp4nagios-0.6.25]# ./configure --with-nagios-user=naemon --with-nagios-group=naemon
  
[root@naemon pnp4nagios-0.6.25]# make all
  
[root@naemon pnp4nagios-0.6.25]# make fullinstall
  
[root@naemon pnp4nagios-0.6.25]# make install-webconf
  
[root@naemon pnp4nagios-0.6.25]# make install-config
  
[root@naemon pnp4nagios-0.6.25]# make install-init
  Restarting and enabling the service.
    [root@naemon ~]# systemctl enable httpd && systemctl restart httpd  
[root@naemon ~]# systemctl enable naemon && systemctl restart naemon
  
[root@naemon ~]# systemctl enable thruk && systemctl restart thruk
  
[root@naemon ~]# systemctl enable npcd && systemctl restart npcd
  you should be able to access the URL from http://192.168.1.170/thruk
DSC0000.jpg

  The default username is thrukadmin, password is thrukadmin.
  In case you want to change the thrukadmin password, run:
  [root@naemon ~]# htpasswd /etc/thruk/htpasswd thrukadmin
Installation of Monitoring Client to monitor the nodes
  Installation of nrpe clients for monitoring Linux hosts
192.168.1.21 - nrpe client - centos 6
  Installation of the Nagios plugin and nrpe client:
  [root@centos6 ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -y
  Take a backup of the nrpe.cfg:
  [root@centos6 ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkp
  Replace the content of the nrpe.conf file with the below content:
[root@centos6 ~]# cat /etc/nagios/nrpe.cfg  
log_facility=daemon
  
pid_file=/var/run/nrpe/nrpe.pid
  
nrpe_user=nrpe
  
nrpe_group=nrpe
  
allowed_hosts=127.0.0.1,192.168.1.170
  
dont_blame_nrpe=1
  
debug=0
  
command_timeout=60
  
connection_timeout=300
  
include_dir=/etc/nrpe.d/
  

  
[root@centos6 ~]#
  Under allowed_host add the naemon server ipaddress here it is 192.168.1.170.
  Now we need to restart the nrpe service:
[root@centos6 ~]# service nrpe restart  [root@centos6 ~]# chkconfig nrpe on
192.168.1.182 - nrpe client - ubuntu
  root@ubuntu:~# apt-get install nagios-nrpe-server nagios-plugins -y
  Take a backup of the nrpe.cfg:
  [root@ubuntu ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkp
  Replace the content of the nrpe.conf file with the below content:
root@ubuntu:~# cat /etc/nagios/nrpe.cfg  
log_facility=daemon
  
pid_file=/var/run/nagios/nrpe.pid
  
nrpe_user=nagios
  
nrpe_group=nagios
  
allowed_hosts=127.0.0.1,192.168.1.170
  
dont_blame_nrpe=1
  
debug=0
  
command_timeout=60
  
connection_timeout=300
  
include_dir=/etc/nagios/nrpe.d/
  
root@ubuntu:~#
  Now we need to restart the nrpe service:
root@ubuntu:~# systemctl restart nagios-nrpe-server.service  root@ubuntu:~# systemctl enable nagios-nrpe-server.service
  Installation of Nscp on Windows
192.168.1.75 - nscp client - windows server 2012R2
  Download nscp from this website:
  https://www.nsclient.org/download/
  Once downloaded, please follow the installation screenshots
DSC0001.jpg

  Choose generic.
DSC0002.jpg

  Choose complete:
DSC0003.jpg

  Choose the default path:
DSC0004.jpg

  Now, under allowed hosts, please add the naemon host. Here in our setup it is 192.168.1.170.
  Make sure you give a complex password. For this example, I have used the password as "howtoforge". Next check enable nsclient and nrpe.
DSC0005.jpg

DSC0006.jpg

  Once the installation is complete, please make sure the service is up and running.
  We will now validate from naemon host, to make sure we are able to reach it.
Validate nrpe and nscp from Naemon Server to check the connectivity
[root@naemon ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.182  
NRPE v2.15
  
[root@naemon ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.21
  
NRPE v2.15
  
[root@naemon ~]#
[root@naemon ~]# /usr/lib64/nagios/plugins/check_nt -H 192.168.1.75 -p 12489 -v CLIENTVERSION -s 'howtoforge'  
NSClient++ 0.5.0.62 2016-09-14
  
[root@naemon ~]#
Monitoring of Servers
  We will monitor the server's performance in this tutorial.
  In a production environment, we will need to monitor the CPU , memory and harddisk utilization, along with the host alive check.
  Adding the following lines in nrpe conf /etc/nrpe.d/base.cfg
192.168.1.21 - nrpe client - centos 6
  [root@centos6 ~]# cat /etc/nrpe.d/base.cfg  
command[check_disks]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
  
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -X nfs -X cifs -X none -X tmpfs -w $ARG1$ -c $ARG2$
  
command[memory]=/usr/lib64/nagios/plugins/check_memory -w $ARG1$ -c $ARG2$
  
command[load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
  
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$
  
command[check_procs_c]=/usr/lib64/nagios/plugins/check_procs -c $ARG1$ -C $ARG2$
  
command[check_procs_a]=/usr/lib64/nagios/plugins/check_procs -c $ARG1$ -a $ARG2$
  Save and restart the file, then restart nrpe.
[root@centos6 ~]# /etc/init.d/nrpe restart  
Shutting down nrpe:                                        [FAILED]
  
Starting nrpe:                                             [  OK  ]
  
[root@centos6 ~]#
  Memory plugin will not be available as default plugin. We will use the below plugin.
[root@centos6 ~]# cd  /usr/lib64/nagios/plugins/  
[root@centos6 plugins]# vim check_memory
  Add the below content.
#! /usr/bin/perl -w  
##Included Perf data
  
#The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
  
#copies of the plugins under the terms of the GNU General Public License.
  
#
  
use strict;
  
use Getopt::Long;
  

  
my ($opt_f, $opt_h, $opt_c, $opt_w);
  
my ($result, $message, $ram_percent);
  

  
my $PROGNAME="check_memory";
  

  
$opt_f = "";
  

  
Getopt::Long::Configure('bundling');
  
GetOptions(
  
        "h"   => \$opt_h, "help"        => \$opt_h,
  
        "c=s" => \$opt_c, "Warning_Percentage"  => \$opt_c,
  
        "w=s" => \$opt_w, "Critical_Percentage" => \$opt_w,
  
);
  

  
if ($opt_h) {
  
        &print_help();
  
        exit 0;
  
}
  

  
$opt_w = shift unless ($opt_w);
  
$opt_c = shift unless ($opt_c);
  

  
if (! $opt_c && ! $opt_w) {
  
        print "Warning and Critical must be specified\n";
  
        exit 3;
  
}
  
if ($opt_c  $opt_c){
  
print "Memory usage is: CRITICAL: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n";
  
exit 2;
  
}elsif ($ram_percent > $opt_w) {
  
print "Memory usage is: WARNING: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n";
  
exit 1;
  
}
  
else{
  
print "Memory usage is: $result: ${ram_percent}% used | used=$ram_percent;$opt_w;$opt_c\n";
  
exit 0;
  
}
  

  
sub print_usage () {
  
        print "Usage:\n";
  
        print "  $PROGNAME -f\n";
  
        print "  $PROGNAME -c\n";
  
        print "  $PROGNAME -w\n";
  
        print "  $PROGNAME [-h | --help]\n";
  
        print "  $PROGNAME [-V | --version]\n";
  
}
  

  
sub print_help () {
  
        print

运维网声明 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-624035-1-1.html 上篇帖子: 添加Sql作业时报错:c001f011-Fly 下篇帖子: zabbix报zabbix server is not runing the information displayed may not be current-
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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