NSCA 似乎注册了该连接,就像在系统日志中一样,但由于未知的原因(至少对我来说)没有将其写入 icinga.cmd,或者至少没有读取它。
这是系统日志。
Jun 27 08:24:58 Mcentral nsca[13720]: Connection from 10.61.34.151 port 23204
Jun 27 08:24:58 Mcentral nsca[13720]: Handling the connection...
Jun 27 08:24:58 Mcentral nsca[13720]: End of connection...
Jun 27 08:24:59 Mcentral nsca[13721]: Connection from 10.61.34.151 port 23460
Jun 27 08:24:59 Mcentral nsca[13721]: Handling the connection...
Jun 27 08:24:59 Mcentral nsca[13721]: End of connection...
这是我的 nsca.cfg
####################################################
# Sample NSCA Daemon Config File
# Written by: Ethan Galstad ([email protected])
#
# Last Modified: 04-03-2006
####################################################
# PID FILE
# The name of the file in which the NSCA daemon should write it's process ID
# number. The file is only written if the NSCA daemon is started by the root
# user as a single- or multi-process daemon.
pid_file=/var/run/nsca.pid
# PORT NUMBER
# Port number we should wait for connections on.
# This must be a non-priveledged port (i.e. > 1024).
server_port=5667
# SERVER ADDRESS
# Address that NSCA has to bind to in case there are
# more as one interface and we do not want NSCA to bind
# (thus listen) on all interfaces.
#server_address=192.168.1.1
# NSCA USER
# This determines the effective user that the NSCA daemon should run as.
# You can either supply a username or a UID.
#
# NOTE: This option is ignored if NSCA is running under either inetd or xinetd
nsca_user=nagios
# NSCA GROUP
# This determines the effective group that the NSCA daemon should run as.
# You can either supply a group name or a GID.
#
# NOTE: This option is ignored if NSCA is running under either inetd or xinetd
nsca_group=nogroup
# NSCA CHROOT
# If specified, determines a directory into which the nsca daemon
# will perform a chroot(2) operation before dropping its privileges.
# for the security conscious this can add a layer of protection in
# the event that the nagios daemon is compromised.
#
# NOTE: if you specify this option, the command file will be opened
# relative to this directory.
#nsca_chroot=/var/run/nagios/rw
# DEBUGGING OPTION
# This option determines whether or not debugging
# messages are logged to the syslog facility.
# Values: 0 = debugging off, 1 = debugging on
debug=1
# COMMAND FILE
# This is the location of the Nagios command file that the daemon
# should write all service check results that it receives.
# Note to debian users: nagios 1.x and nagios 2.x have
# different default locations for this file. this is the
# default location for nagios 1.x:
#command_file=/var/run/nagios/nagios.cmd
# and this is the default location for nagios2:
#command_file=/var/lib/nagios2/rw/nagios.cmd
# and this is the default location for nagios3:
command_file=/var/lib/icinga/rw/icinga.cmd
# ALTERNATE DUMP FILE
# This is used to specify an alternate file the daemon should
# write service check results to in the event the command file
# does not exist. It is important to note that the command file
# is implemented as a named pipe and only exists when Nagios is
# running. You may want to modify the startup script for Nagios
# to dump the contents of this file into the command file after
# it starts Nagios. Or you may simply choose to ignore any
# check results received while Nagios was not running...
alternate_dump_file=/var/run/nagios/nsca.dump
# AGGREGATED WRITES OPTION
# This option determines whether or not the nsca daemon will
# aggregate writes to the external command file for client
# connections that contain multiple check results. If you
# are queueing service check results on remote hosts and
# sending them to the nsca daemon in bulk, you will probably
# want to enable bulk writes, as this will be a bit more
# efficient.
# Values: 0 = do not aggregate writes, 1 = aggregate writes
aggregate_writes=0
# APPEND TO FILE OPTION
# This option determines whether or not the nsca daemon will
# will open the external command file for writing or appending.
# This option should almost *always* be set to 0!
# Values: 0 = open file for writing, 1 = open file for appending
append_to_file=0
# MAX PACKET AGE OPTION
# This option is used by the nsca daemon to determine when client
# data is too old to be valid. Keeping this value as small as
# possible is recommended, as it helps prevent the possibility of
# "replay" attacks. This value needs to be at least as long as
# the time it takes your clients to send their data to the server.
# Values are in seconds. The max packet age cannot exceed 15
# minutes (900 seconds). If this variable is set to zero (0), no
# packets will be rejected based on their age.
max_packet_age=30
# DECRYPTION PASSWORD
# This is the password/passphrase that should be used to descrypt the
# incoming packets. Note that all clients must encrypt the packets
# they send using the same password!
# IMPORTANT: You don't want all the users on this system to be able
# to read the password you specify here, so make sure to set
# restrictive permissions on this config file!
#password=
# DECRYPTION METHOD
# This option determines the method by which the nsca daemon will
# decrypt the packets it receives from the clients. The decryption
# method you choose will be a balance between security and performance,
# as strong encryption methods consume more processor resources.
# You should evaluate your security needs when choosing a decryption
# method.
#
# Note: The decryption method you specify here must match the
# encryption method the nsca clients use (as specified in
# the send_nsca.cfg file)!!
# Values:
#
# 0 = None (Do NOT use this option)
# 1 = Simple XOR (No security, just obfuscation, but very fast)
#
# 2 = DES
# 3 = 3DES (Triple DES)
# 4 = CAST-128
# 5 = CAST-256
# 6 = xTEA
# 7 = 3WAY
# 8 = BLOWFISH
# 9 = TWOFISH
# 10 = LOKI97
# 11 = RC2
# 12 = ARCFOUR
#
# 14 = RIJNDAEL-128
# 15 = RIJNDAEL-192
# 16 = RIJNDAEL-256
#
# 19 = WAKE
# 20 = SERPENT
#
# 22 = ENIGMA (Unix crypt)
# 23 = GOST
# 24 = SAFER64
# 25 = SAFER128
# 26 = SAFER+
#
decryption_method=1
我可以通过 telnet 连接到它,但是得到的结果如下:
�2��잿����1�q��"�)����I�Q�%*��R���a�f�`��W$�o+)9QS�ci�-C�55-��+���iI֎!E�K �Ln�kؗ�c�Q��gA�fSzc��9K�1�>_^X
只是胡言乱语。
我的操作系统是 ubuntu 12.04,我正在尝试从另一个 Linux 机器读取一些被动检查,我使用的是 icinga 1.9.1 和 icinga-web。
答案1
如果 NSCA 不起作用,您应该尝试以下操作:
检查您的 nagios.log,看看它是否显示 NSCA 已提交命令,但主机名/服务名错误
确保 NSCA 对 Nagios 命令管道文件具有写入权限
var/rw/nagios.cmd
确保 nagios.cfg 指定处理外部命令
check_external_commands=1
确保 Nagios 在 nagios.cfg 中具有合理的命令处理间隔
command_check_interval=-1
检查 NSCA 是否配置为接受来自远程发送者的命令 - 如果您对 NSCA 使用 Xinetd,那么它将在文件中
xinetd.d/nsca
,如果您将 NSCA 作为守护进程运行,则应该查看您的nsca.conf
文件。检查本地主机防火墙,确保它不会丢弃入站 NSCA 连接。