監視サーバー · 10 min read · Nov 02, 2025
本番環境に適したNaemon監視サーバーのインストール方法
Naemonは、ネットワークとアプリケーションの状態を明確に把握しながら、迅速で安定した革新的な監視スイートです。これはnagiosサーバーの代替であり、非常に安定しており、thrukという素晴らしいダッシュボードを使用しています。naemonの設定は非常に簡単で、ライブステータスが組み込まれています。このチュートリアルでは、pnp4nagiosを使用してグラフを作成しながら、本番環境でnaemonをインストールおよび構成する方法を示します。Naemonは非常に安定しており、大規模環境での設定を維持する方法も示します。
このチュートリアルでは、4台のサーバーを使用します。
- 192.168.1.170 - Naemonサーバー - centos 7
- 192.168.1.21 - nrpeクライアント - centos 6
- 192.168.1.182 - nrpeクライアント - ubuntu
- 192.168.1.75 - nscpクライアント - windows server 2012R2
Naemonサーバーのインストール
私はSELinuxを無効にし、firewalldを有効にした最小インストールのCentOS 7ホストを使用しています。
[root@naemon ~]# sestatus
SELinux status: disabled
[root@naemon ~]#リポジトリのインストール:
[root@naemon ~]# yum -y install https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpmepelリポジトリを有効にする:
yum -y install epel-releaseNaemonパッケージのインストール:
[root@naemon ~]# yum install naemon*Naemonは、ホストを監視するために同じNagiosプラグインとnrpeを使用します。これらをインストールします:
[root@naemon ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -yファイアウォールルールを追加します:
[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 ~]#
pnp4nagiosのインストール。
yum install gcc-c++ rrdtool perl-Time-HiRes perl-rrdtool php-gd php php-cli wgetpnp4nagiosをダウンロードします。
[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
サービスを再起動して有効にします。
[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
http://192.168.1.170/thrukからURLにアクセスできるはずです。

デフォルトのユーザー名はthrukadmin、パスワードはthrukadminです。
thrukadminのパスワードを変更したい場合は、次のコマンドを実行します:
[root@naemon ~]# htpasswd /etc/thruk/htpasswd thrukadminノードを監視するための監視クライアントのインストール
Linuxホストを監視するためのnrpeクライアントのインストール
192.168.1.21 - nrpeクライアント - centos 6
Nagiosプラグインとnrpeクライアントのインストール:
[root@centos6 ~]# yum install nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe -ynrpe.cfgのバックアップを取ります:
[root@centos6 ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkpnrpe.confファイルの内容を以下の内容に置き換えます:
[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 ~]#
allowed_hostの下にnaemonサーバーのIPアドレスを追加します。ここでは192.168.1.170です。
次に、nrpeサービスを再起動する必要があります:
[root@centos6 ~]# service nrpe restart
[root@centos6 ~]# chkconfig nrpe on
192.168.1.182 - nrpeクライアント - ubuntu
root@ubuntu:~# apt-get install nagios-nrpe-server nagios-plugins -ynrpe.cfgのバックアップを取ります:
[root@ubuntu ~]# cp /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.bkpnrpe.confファイルの内容を以下の内容に置き換えます:
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:~#
次に、nrpeサービスを再起動する必要があります:
root@ubuntu:~# systemctl restart nagios-nrpe-server.service
root@ubuntu:~# systemctl enable nagios-nrpe-server.service
WindowsにNscpをインストール
192.168.1.75 - nscpクライアント - windows server 2012R2
このウェブサイトからnscpをダウンロードします:
https://www.nsclient.org/download/
ダウンロードが完了したら、インストールのスクリーンショットに従ってください。

一般を選択します。

完全を選択します:

デフォルトのパスを選択します:

allowed hostsの下にnaemonホストを追加してください。ここでは192.168.1.170です。
複雑なパスワードを設定してください。この例では、パスワードとして”howtoforge”を使用しました。次に、nsclientとnrpeを有効にしてください。


インストールが完了したら、サービスが稼働していることを確認してください。
次に、naemonホストから接続できることを確認します。
Naemonサーバーからnrpeとnscpの接続性を確認
[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 ~]#
サーバーの監視
このチュートリアルでは、サーバーのパフォーマンスを監視します。
本番環境では、CPU、メモリ、ハードディスクの使用率を監視し、ホストの生存確認も行う必要があります。
nrpe conf /etc/nrpe.d/base.cfgに以下の行を追加します。
192.168.1.21 - nrpeクライアント - 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$
ファイルを保存して再起動し、nrpeを再起動します。
[root@centos6 ~]# /etc/init.d/nrpe restart
Shutting down nrpe: [FAILED]
Starting nrpe: [ OK ]
[root@centos6 ~]#
メモリプラグインはデフォルトのプラグインとしては利用できません。以下のプラグインを使用します。
[root@centos6 ~]# cd /usr/lib64/nagios/plugins/
[root@centos6 plugins]# vim check_memory以下の内容を追加します。
#! /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_w){
print "Critical must be greater than Warning CRITICAL: \$opt_c WARNING: \$opt_w\n";
exit 3;
}
$result = 'OK';
open(FREE_M, "free -m|");
while (my $line = ){
if ($line =~ /^Mem/){
my ($junk,$total_mem,$used_mem,$free_mem,$shared_mem,$buffered_mem,$cached_mem)=split(/\s+/,$line);
$ram_percent=int((\$total_mem-(\$free_mem+\$cached_mem+\$buffered_mem))/\$total_mem*100*100)/100;
}
}
close(FREE_M);
if (\$ram_percent > \$opt_c){
print "Memory usage is: CRITICAL: \${ram_percent}% used | used=\$ram_percent;\$opt_w;\$opt_c\n";
exit 2;
}elseif (\$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 << EOF;
\$PROGNAME v1.0.01
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
EOF
&print_usage();
print "\n";
exit 3;
}
check_memoryプラグインのダウンロードリンク
ファイルに実行権限を与える必要があります:
[root@centos6 plugins]# chmod 755 check_memorynrpe conf /etc/nagios/nrpe.d/base.cfgに以下の行を追加します。
192.168.1.182 - nrpeクライアント - ubuntu
ここではファイルパスが異なります: プラグインフォルダーはlibであり、lib64ではありません。
root@ubuntu:~# cat /etc/nagios/nrpe.d/base.cfg
command[check_disks]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_disk]=/usr/lib/nagios/plugins/check_disk -X nfs -X cifs -X none -X tmpfs -w $ARG1$ -c $ARG2$
command[memory]=/usr/lib/nagios/plugins/check_memory -w $ARG1$ -c $ARG2$
command[load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$
command[check_procs_c]=/usr/lib/nagios/plugins/check_procs -c $ARG1$ -C $ARG2$
command[check_procs_a]=/usr/lib/nagios/plugins/check_procs -c $ARG1$ -a $ARG2$
同じcheck_memoryスクリプトを/usr/lib/nagios/pluginsに追加します。
root@ubuntu:~# vim /usr/lib/nagios/plugins/check_memory
root@ubuntu:~# chmod 755 /usr/lib/nagios/plugins/check_memory
root@ubuntu:~# systemctl restart nagios-nrpe-server.service
root@ubuntu:~#
Naemonサーバーの設定
naemonユーザーとしてログインします:
[root@naemon ~]# su - naemon
Last login: Thu Mar 9 17:11:39 CET 2017 on pts/0
-sh-4.2$
/etc/naemon/naemon.cfgで管理者メールを変更します。
........
........
[email protected]
[email protected]
........
............次に、/etc/naemon/conf.dでチェックを行うためのカスタムコマンドを構成します。
custom_commands.cfgというカスタムコマンドを作成し、以下の内容を追加します。
$ vim /etc/naemon/conf.d/custom_commands.cfg## ホスト生存確認 ##
# command 'check_icmp Host Alive'
define command{
command_name host_alive
command_line $USER1$/check_icmp -H $HOSTADDRESS$ -n 1 -w 3000.00,80% -c 5000.00,100%
}
### サービスコマンド ##
# command 'check_nrpe_disks'
define command{
command_name check_nrpe_disks
command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c check_disks -a $ARG1$ $ARG2$ $ARG3$
}
# command 'nrpe'
define command{
command_name nrpe
command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c $ARG1$
}
# NRPE With Arguements
define command{
command_name check_nrpe_a
command_line $USER1$/check_nrpe -t 55 -u -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$
}
#####################################
# Windows NSClient++ Checks
# command 'check_nt'
define command{
command_name nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ -s $USER4$
}
安全のため、/etc/naemon/resource.cfgにnscpクライアントのパスワードを保存します。
...........
...........
$USER4$=howtoforge
...........
............次に、ホスト構成を定義する必要があります。
linux.cfgというファイルを作成します。
$ vim /etc/naemon/conf.d/linux.cfgdefine host {
host_name centos6.sunil.cc
alias Centos
address 192.168.1.21
use linux-server
hostgroups linux-servers
}
define host {
host_name ubuntu.sunil.cc
alias Ubuntu
address 192.168.1.182
use linux-server
hostgroups linux-servers
}
Windowsホストについても同様の設定を行います。
$ vim /etc/naemon/conf.d/windows.cfgdefine host {
host_name ad.sunil.cc
alias My Windows Server
address 192.168.1.75
use windows-server
}
define hostgroup {
hostgroup_name windows-servers
alias Windows Servers
}
次に、サービス構成を定義する必要があります。
$ vim linux_services.cfgdefine service {
service_description Disks Status
hostgroup_name linux-servers
use generic-service
check_command check_nrpe_a!check_disk!15%!5%
}
define service{
use generic-service
hostgroup_name linux-servers
service_description Load Average
check_command check_nrpe_a!load!30,25,20!45,40,35
}
define service{
use generic-service
hostgroup_name linux-servers
service_description Memory Usage
check_command check_nrpe_a!memory!80!90
}
Windowsについても同様の設定を行います。
$ vim window_services.cfgdefine service{
use generic-service
hostgroup_name windows-servers
service_description Disk - C:
check_command nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
hostgroup_name windows-servers
service_description Load Average
check_command nt!CPULOAD!-l 60,90,95
}
define service{
use generic-service
hostgroup_name windows-servers
service_description Memory Usage
check_command nt!MEMUSE!-w 90 -c 95
}
次に、連絡先のメールアドレスを変更します。
$ vim contacts.cfgdefine contact {
contact_name naemonadmin ; Short name of user
alias Naemon Admin ; Full name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
email [email protected] ; <<*** CHANGE THIS TO YOUR EMAIL ADDRESS ****
}
不要な設定を削除します。
$ mv switch.cfg switch.cfg.bkp$ mv printer.cfg printer.cfg.bkp設定を検証します。
$ naemon -v /etc/naemon/naemon.cfg
Naemon Core 1.0.6-pkg
Copyright (c) 2013-present Naemon Core Development Team and Community Contributors
Copyright (c) 2009-2013 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
License: GPL
Website: http://www.naemon.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 20 services.
Checked 4 hosts.
Checked 1 contacts.
Checked 2 host groups.
Checked 0 service groups.
Checked 1 contact groups.
Checked 29 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 4 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
-sh-4.2$
rootとしてログインし、naemonサービスを再起動します。
[root@naemon conf.d]# systemctl restart naemon
[root@naemon conf.d]# systemctl status naemon
? naemon.service - Naemon Monitoring Daemon
Loaded: loaded (/usr/lib/systemd/system/naemon.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-03-09 19:14:36 CET; 7s ago
Docs: http://naemon.org/documentation
Process: 5112 ExecStart=/usr/bin/naemon --daemon /etc/naemon/naemon.cfg (code=exited, status=0/SUCCESS)
Process: 5110 ExecStartPre=/usr/bin/chown -R naemon:naemon /var/run/naemon/ (code=exited, status=0/SUCCESS)
Process: 5108 ExecStartPre=/usr/bin/mkdir /var/run/naemon (code=exited, status=1/FAILURE)
Main PID: 5114 (naemon)
CGroup: /system.slice/naemon.service
??5114 /usr/bin/naemon --daemon /etc/naemon/naemon.cfg
??5115 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
??5116 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
??5117 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
??5118 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
??5119 /usr/bin/naemon --daemon /etc/naemon/naemon.cfg
Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Starting Naemon Monitoring Daemon...
Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Failed to read PID from file /var/run/naemon/naemon.pid: Invalid argument
Mar 09 19:14:36 naemon.sunil.cc systemd[1]: Started Naemon Monitoring Daemon.
[root@naemon conf.d]#
ダッシュボードにログインすると、サービスが稼働しているのが確認できます。
Ubuntuホストのサービスが失敗しているのが確認できます。
Ubuntu用にコンパイルされたnrpeパッケージは、セキュリティの脆弱性のために引数を無効にしてコンパイルされているため、失敗しています。引数を有効にするためにパッケージを再コンパイルする必要があります。naemonからのチューニングを管理するために。
以下のリンクに、再コンパイルする方法が示されています。このサイトには、引数を有効にした状態で既にコンパイルされたパッケージもあります。このチュートリアルでは、このプリコンパイルされたパッケージを使用します。
https://www.claudiokuenzler.com/blog/626/nrpe-debian-jessie-command-ags-arguments-not-working-errorroot@ubuntu:~# wget https://www.claudiokuenzler.com/downloads/nrpe/nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.debパッケージをインストールします。
root@ubuntu:~# dpkg -i nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.deb
(Reading database ... 79576 files and directories currently installed.)
Preparing to unpack nagios-nrpe-server_2.15-1ubuntu2_amd64.xenial.deb ...
Unpacking nagios-nrpe-server (2.15-1ubuntu2) over (2.15-1ubuntu1) ...
Setting up nagios-nrpe-server (2.15-1ubuntu2) ...
Processing triggers for systemd (229-4ubuntu16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
root@ubuntu:~#NRPEを再起動します。
root@ubuntu:~# systemctl restart nagios-nrpe-server.serviceこれで、naemonを使用してすべてのホストを監視しています。
pnp4nagiosの設定
パフォーマンスグラフのためにpnp4nagiosを設定する必要があります。
同じ認証方法をthrukダッシュボードと使用します。最初にファイルのバックアップを取り、以下の行を変更します。
[root@naemon conf.d]# cd /etc/httpd/conf.d/
[root@naemon conf.d]# cp pnp4nagios.conf pnp4nagios.conf.bkp
[root@naemon share]# cat /etc/httpd/conf.d/pnp4nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
Alias /pnp4nagios "/usr/local/pnp4nagios/share"
AllowOverride None
Order allow,deny
Allow from all
#
# Use the same value as defined in nagios.conf
#
AuthName "Thruk Access"
AuthType Basic
AuthUserFile /etc/thruk/htpasswd
Require valid-user
# Turn on URL rewriting
RewriteEngine On
Options symLinksIfOwnerMatch
# Installation directory
RewriteBase /pnp4nagios/
# Protect application and system files from being viewed
RewriteRule "^(?:application|modules|system)/" - [F]
# Allow any files or directories that exist to be displayed directly
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
# Rewrite all other URLs to index.php/URL
RewriteRule "^.*$" "index.php/$0" [PT]
[root@naemon share]#
[root@naemon conf.d]# systemctl restart httpd.service
次に、設定ページを変更する必要があります。
[root@naemon share]# cd /usr/local/pnp4nagios/share/
[root@naemon share]# mv install.php install.php.txt
次に、pnp4nagiosの設定ファイルを変更します。
設定ファイル内のnagiosをnaemonに変更します。
[root@naemon conf.d]# vi /usr/local/pnp4nagios/etc/config_local.php
............................
................................
$conf['nagios_base'] = "/naemon/cgi-bin";
..................................
............................パフォーマンスデータを0から1に変更します。
[root@naemon conf.d]# vi /etc/naemon/naemon.cfg
.....................
.....................
process_performance_data=1
......................
......................naemon.confの最後に以下の行を追加します。
[root@naemon conf.d]# vi /etc/naemon/naemon.cfg#
# service performance data
#
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::\$TIMET$\tHOSTNAME::\$HOSTNAME$\tSERVICEDESC::\$SERVICEDESC$\tSERVICEPERFDATA::\$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::\$SERVICECHECKCOMMAND$\tHOSTSTATE::\$HOSTSTATE$\tHOSTSTATETYPE::\$HOSTSTATETYPE$\tSERVICESTATE::\$SERVICESTATE$\tSERVICESTATETYPE::\$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file
#
#
#
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::\$TIMET$\tHOSTNAME::\$HOSTNAME$\tHOSTPERFDATA::\$HOSTPERFDATA$\tHOSTCHECKCOMMAND::\$HOSTCHECKCOMMAND$\tHOSTSTATE::\$HOSTSTATE$\tHOSTSTATETYPE::\$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
次に、custom_commands.confに以下の行を追加します。
[root@naemon conf.d]# vim /etc/naemon/conf.d/custom_commands.cfg
define command{
command_name process-service-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.\$TIMET$
}
define command{
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.\$TIMET$
}
次に、ホストパフォーマンスとサービスパフォーマンスグラフのテンプレートを作成します。
$ cd /etc/naemon/conf.d/templates/
$ cat pnp.cfg
define host {
name host-pnp
process_perf_data 1
action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=\$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name service-pnp
process_perf_data 1
action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME$&srv=\$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=\$HOSTNAME$&srv=\$SERVICEDESC$
register 0
}
サービスのパフォーマンスグラフにアクセスするには、service.cfgファイルを更新する必要があります。
$ cat linux_services.cfg
define service {
service_description Disks Status
hostgroup_name linux-servers
use generic-service,service-pnp ; Name of service template to use
check_command check_nrpe_a!check_disk!15%!5%
}
define service{
use generic-service,service-pnp
hostgroup_name linux-servers
service_description Load Average
check_command check_nrpe_a!load!30,25,20!45,40,35
}
define service{
use generic-service,service-pnp
hostgroup_name linux-servers
service_description Memory Usage
check_command check_nrpe_a!memory!80!90
}
$ cat window_services.cfg
define service{
use generic-service,service-pnp
hostgroup_name windows-servers
service_description Disk - C:
check_command nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service,service-pnp
hostgroup_name windows-servers
service_description Load Average
check_command nt!CPULOAD!-l 60,90,95
}
define service{
use generic-service,service-pnp
hostgroup_name windows-servers
service_description Memory Usage
check_command nt!MEMUSE!-w 90 -c 95
}
ホストグラフを確認するには、以下のファイルに含める必要があります。
$ cat linux.cfg
define host {
host_name centos6.sunil.cc
alias Centos
address 192.168.1.21
use linux-server,host-pnp
hostgroups linux-servers
}
define host {
host_name ubuntu.sunil.cc
alias Ubuntu
address 192.168.1.182
use linux-server,host-pnp
hostgroups linux-servers
}
$ cat windows.cfg
define host {
host_name ad.sunil.cc
alias My Windows Server
address 192.168.1.75
use windows-server,host-pnp
}
define hostgroup {
hostgroup_name windows-servers
alias Windows Servers
}
設定を検証します。
$ naemon -v /etc/naemon/naemon.cfg
Naemon Core 1.0.6-pkg
Copyright (c) 2013-present Naemon Core Development Team and Community Contributors
Copyright (c) 2009-2013 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
License: GPL
Website: http://www.naemon.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 20 services.
Checked 4 hosts.
Checked 1 contacts.
Checked 2 host groups.
Checked 0 service groups.
Checked 1 contact groups.
Checked 31 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 4 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
サービスを再起動します。
[root@naemon ~]# systemctl enable npcd
npcd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig npcd on
[root@naemon ~]# systemctl restart npcd
[root@naemon ~]# systemctl restart naemon

新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。

