Installation (Server side)
Installing Packages need
yum install nrpe perl-Nagios-Plugin policycoreutils-python -y
Create plugin
- check_mount.pl 원 제작자 홈페이지 : http://blog.binfalse.de/software/nagios/check_mount-pl/
- 여기서 사용된 플러그인은 일부 라이브러리 사용관련 항목을 수정하였음
/usr/local/bin/check_mount.pl
#!/usr/bin/perl -w
###################################
#
# written by Martin Scharm
# see https://binfalse.de
# editted by DaeHyung Lee(daehyung@gmail.com)
#
###################################
use warnings;
use strict;
use Getopt::Long qw(:config no_ignore_case);
use lib '/usr/lib64/nagios/plugins';
use Nagios::Plugin qw(%ERRORS);
my $MOUNT = undef;
my $TYPE = undef;
sub how_to
{
print "USAGE: $0\n\t-m MOUNTPOINT\twich mountpoint to check\n\t[-t TYPE]\toptionally check whether it's this kind of fs-type\n\n";
}
GetOptions (
'm=s' => \ $MOUNT,
'mountpoint=s' => \ $MOUNT,
't=s' => \ $TYPE,
'type=s' => \ $TYPE
);
unless (defined ($MOUNT))
{
print "Please define mountpoint\n\n";
how_to;
exit $ERRORS{'CRITICAL'};
}
my $erg = `/bin/mount | /bin/grep $MOUNT`;
if ($erg)
{
if (defined ($TYPE))
{
if ($erg =~ m/type $TYPE /)
{
print $MOUNT . " is mounted! Type is " . $TYPE . "\n";
exit $ERRORS{'OK'};
}
else
{
print $MOUNT . " is mounted! But type is not " . $TYPE . "\n";
exit $ERRORS{'WARNING'};
}
}
print $MOUNT . " is mounted!\n";
exit $ERRORS{'OK'};
}
else
{
print $MOUNT . " is not mounted!\n";
exit $ERRORS{'CRITICAL'};
}
Setting Permission
chmod +x /usr/local/bin/check_mount.pl
chown nagios: /usr/local/bin/check_mount.pl
semanage fcontext -a -t nagios_unconfined_plugin_exec_t '/usr/local/bin/check_mount.pl'
restorecon -v /usr/local/bin/check_mount.pl
NRPE Configuration
/etc/nagios/nrpe.cfg
log_facility=daemon
pid_file=/var/run/nrpe/nrpe.pid
server_port=5666
nrpe_user=nrpe
nrpe_group=nrpe
allowed_hosts=127.0.0.1,192.168.188.236
dont_blame_nrpe=1
allow_bash_command_substitution=0
debug=0
command_timeout=60
connection_timeout=300
include_dir=/etc/nrpe.d/
command[check_users]=/usr/lib64/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
command[check_load]=/usr/lib64/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
command[check_mount]=/usr/local/bin/check_mount.pl -m $ARG1$
dont_blame_nrpe를 1로 설정하여 Icinga로부터 인자값을 받을 수 있도록 설정하였다.
Adding service info. into the Internet network services list
/etc/services
...생략...
nrpe 5666/tcp # NRPE
...생략...
Settings Firewall for NRPE
...생략...
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
Restart Firewall & NRPE
service iptables restart
chkconfig nrpe on
service nrpe start
Testing on Icinga
as a icinga
[icinga@icinga libexec]$ ./check_nrpe -H 192.168.188.203 -c check_mount -a /mnt/WORK
/mnt/WORK is mounted!
Icinga Configuration
다른 NRPE 관련 페이지 참조...
No comments:
Post a Comment