NRPEP (NetSaint Remote Plugin Executor/Perl)


(1)事前準備
NRPEPはNRPEと同じ機能を提供しますが、TripleDESを使い暗号化してデータのやり取りを行います。
そこで、次の2つのPerlモジュールが必要となります。

   Crypt-TripleDES
   Digest-MD5

RedHat Linux 7.3で、全てのパッケージをインストールした場合には、perl-Digest-MD5-2.20-1.i386.rpm がインストール済みです。(RedHat Linux 7.2では perl-Digest-MD5-2.13-1.i386.rpm )


これらのrpmファイルは、「 About Rpmfind.Net Server 」からダウンロードできますので、必要なファイルを入手してインストールしておいてください。
(キーワードとして、「perl-Crypt-TripleDES」、「perl-Digest-MD5」を使います。)



(2)コンパイル
ダウンロードしたnrpep-0.2.tar.gz を適当なディレクトリに展開します。
そして、それで終了です。
nrpe の場合のように ./configure や make all 等は不要です。
展開したディレクトリ( ./nrpep-0.2 )の中で必要なファイルは次の4つです。
   NetSaint Serverで使用 ・・・ check_nrpep   check_nrpep.cfg
   リモートホストで使用   ・・・
 nrpep           nrpep.cfg

左図のように、この nrpep をリモートホスト上で実行し、check_nrpep をNetSaintを稼動させているホスト上で実行することになります。

リモートホスト上でNetSaintを稼動させておく必要はありませんが、NetSaintのプラグイン(check_procs、check_disks、check_users、check_load等)が必要となりますので、リモートホストにもNetSaintをインストールしておくようにしましょう。

なお、nrpeのように、各々のマシンでコンパイルする必要はありません。




(3)インストール
nrpepのREADMEによれば、展開したディレクトリにあるMakefileをNetSaintサーバーとリモートホストにインストールするには自分の環境にあうように適宜修正し、
   NetSaintサーバーにインストールする場合  → make  install-client
   リモートホストにインストールする場合     → make  install-server
しなさい、となっています。

Makefileは、次のような内容となっていますので特に修正の必要はなさそうです。

#
# Nrpep Makefile
#

#
# Configuration Files
#

#
# What directory the server program (nrpep) should live in
#
nrpepserverdir = "/usr/sbin"

#
# What directory the plugin client should live in
#
nrpepplugindir = "/usr/local/netsaint/libexec"

#
# What user should own nrpep
#
nrpepowner = "root"

#
# What group should own nrpep
#
nrpepgroup = "root"

#
# What user should own check_nrpep
#
checknrpepowner = "netsaint"

#
# What group should own check_nrpep
#
checknrpepgroup = "netsaint"

#
# What directory should the nrpep config files go to
#
nrpepconfigdir = "/usr/local/netsaint/etc"

# ***************************************
# DO NOT CHANGE ANYTHING BELOW THIS POINT
# ***************************************

all:
cat README | more

install-client:
`if [ ! -d "$(nrpepplugindir)" ]; then \
mkdir -p $(nrpepplugindir); \
fi`
`if [ ! -d "$(nrpepconfigdir)" ]; then \
mkdir -p $(nrpepconfigdir); \
fi`
install -b -D -g $(checknrpepgroup) -o $(checknrpepowner) -m 755 check_nrpep $(nrpepplugindir);
install -b -D -g $(checknrpepgroup) -o $(checknrpepowner) -m 644 check_nrpep.cfg $(nrpepconfigdir);

install-server:
`if [ ! -d "$(nrpepserverdir)" ]; then \
mkdir -p $(nrpepserverdir); \
fi`
`if [ ! -d "$(nrpepconfigdir)" ]; then \
mkdir -p $(nrpepconfigdir); \
fi`
install -b -D -g $(nrpepgroup) -o $(nrpepowner) -m 755 nrpep $(nrpepserverdir);
install -b -D -g $(nrpepgroup) -o $(nrpepowner) -m 644 nrpep.cfg $(nrpepconfigdir);

uninstall-client:
rm $(nrpepplugindir)/check_nrpep
rm $(nrpepconfigdir)/check_nrpep.cfg

uninstall-server:
rm $(nrpepserverdir)/nrpep
rm $(nrpepconfigdir)/nrpep.cfg

しかし、実際に make install-client とすると
# make install-client
`if [ ! -d ""/usr/local/netsaint/libexec"" ]; then \
mkdir -p "/usr/local/netsaint/libexec"; \
fi`
`if [ ! -d ""/usr/local/netsaint/etc"" ]; then \
mkdir -p "/usr/local/netsaint/etc"; \
fi`
install -b -D -g "netsaint" -o "netsaint" -m 755 check_nrpep "/usr/local/netsaint/libexec";
install: cannot overwrite directory `/usr/local/netsaint/libexec' with non-directory
make: *** [install-client] エラー 1

となってインストールできませんでした。(ーー;)

どうも「 install 」のオプション「 -b -D 」がまずいようです。
そこで、私の場合、この「 -b -D 」のオプションを削除して、make install-client と make install-server を実行しました。(~_~;) ( 「 -b -D 」の意味については、man install で調べてみてくださいね。)

Makefileがやっていることは、それぞれのファイルをオーナー、グループ、パーミッション、インストールするディレクトリを指定してコピーしているだけのことですので、ここは手動で一つ一つやることも可能です。

なお、NetSaintサーバーで「 check_nrpep.cfg 」をデフォルトの「 /usr/local/netsaint/etc 」以外のディレクトリにインストールした場合、「 check_nrpep 」の62行目
   &Get_Configs("/usr/local/netsaint/etc/check_nrpep.cfg");

を修正することも必要となります。



(4)リモートホストでの各種設定
それでは、リモートホスト上でnrpep をxinetd の下で実行するのに必要な各種設定を行います。

まず、インストールした nrpep.cfg の内容を見てみましょう。

#
# Shared secret definition - should be the same as the one contained in
# check_nrpep.cfg
#
secret=changeme

# The following is completley stolen from the nrpe program by Ethan Galstad.
#
# COMMAND DEFINITIONS
#
# Command definitions that this daemon will run. Definitions
# are in the following format:
#
# command[<command_name>]=<command_line>
#
# When the daemon receives a request to return the results of <command_name>
# it will execute the command specified by the <command_line> argument.
#
# Unlike NetSaint, the command line cannot contain macros - it must be
# typed exactly as it should be executed.
#
# Note: Any plugins that are used in the command lines must reside
# on the machine that this daemon is running on! The examples below
# assume that you have plugins installed in a /usr/local/netsaint/libexec
# directory.

command[check_users]=/usr/local/netsaint/libexec/check_users 0 1
command[check_load]=/usr/local/netsaint/libexec/check_load 5 10 15 20 25 30
command[check_disk1]=/usr/local/netsaint/libexec/check_disk 80 95 /dev/hda1
command[check_disk2]=/usr/local/netsaint/libexec/check_disk 80 95 /dev/hdb1
command[check_zombie_procs]=/usr/local/netsaint/libexec/check_procs 5 10 Z
command[check_zombie_procs_old_man_please]=/usr/local/netsaint/libexec/check_procs 5 10 Z
command[check_total_procs]=/usr/local/netsaint/libexec/check_procs 150 200

最後のところで、具体的なプラグインのフォーマットが記述されていますが、必要に応じてインストールしたリモートホストで使えるように修正しましょう。

各プラグインの引数については、
   #  /usr/local/netsaint/libexec/check_users  --help
とすれば意味が表示されるので参考にしてください。
私の場合、check_users の引数が「0」と「1」になっていますので、ここを「5」と「10」に変えました。


さて、nrpep は 8086番のポートを使用し、TCPを使ってデータのやりとりをおこないます。
そこで、リモートホストの /etc/services のファイルに次の内容を追加します。
   nrpep      8086/TCP      # NRPEP


次に、下記の内容で nrpep というファイルを /etc/xinetd.d/ ディレクトリに作成します。
オプションの値などが nrpeと微妙に違っていますので注意してください。

   #  default: on
   #  description: NRPEP
   service  nrpep
   {
        disable          =  no
        flags             =  REUSE
        socket_type   =  stream
        wait              =  no
        user              =  root
        server           =  /usr/sbin/nrpep
        server_args    =  -c  /usr/local/netsaint/etc/nrpep.cfg
        log_on_failure  +=  USERID
        only_from       =  NetSaint ServerのIPまたはドメイン
   }

以上で、リモートホスト上の設定が終了しましたので、xinetd をリスタートさせます。
   # /etc/init.d/xinetd restart


なお、xinetd でなく inetd を使用している場合には、/etc/inetd.conf ファイルに次の内容を追加します。
   nrpep  stream  tcp  nowait root /usr/sbin/tcpd
                               /usr/sbin/nrpep  -c  /usr/local/netsaint/etc/nrpep.cfg
                                          (実際には、1行で記入します。)
また、etc/hosts.deny に次の内容を追加します。
   nrpe:      ALL  EXCEPT NetSaint ServerのIPまたはドメイン



(5)NetSaint側(ローカルホスト)の設定
まずは、check_nrpep というコマンドの登録です。
/usr/local/netsaint/etc/hosts.cfg の「COMMAND CONFIGURATION」のところに、以下の行を追加します。

command[check_nrpep]=/usr/local/netsaint/libexex/check_nrpe -h $HOSTADDRESS$ -c $ARG1$

nrpeでは「 -h 」のオプションが必要なかったのですが、nrpepでは必要としますので注意してください。

次に、「SERVICE CONFIGURATION」のところで、ターゲットとなるリモートホストに対して実行するローカルプラグインを定義します。
以下に例を示します。

service[remote]=Users;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_users
service[remote]=CPU;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_load
service[remote]=HDA1;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_disk1
service[remote]=HDB1;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_disk2
service[remote]=Total Proc;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_total_procs
service[remote]=Zombie Proc;0;24x7;3;5;1;admins;120;24x7;0;0;0;;check_nrpep!check_zombie_procs

以上でNetSaint側の準備もできました。
新しい設定を有効にするためにNetSaintを再起動させれば完了です。

実際には、稼動しているNetSaintを一旦ストップし、起動テスト( pre-flight check )を行ってから、スタートさせましょう。



back HOME