banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận hệ điều hành *nix Problem với event_handler của Nagios  XML
  [Question]   Problem với event_handler của Nagios 09/12/2008 06:57:33 (+0700) | #1 | 161745
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]
Tui đã rà soát lại toàn bộ cấu hình, theo như hướng dẫn, nhưng không hiểu sao event_handler vẫn không được gọi (monitor vẫn tốt).
Trong windows.cfg, gọi command restart-autoupdate:

define service{
use generic-service
host_name winserver
service_description Automatic Updates
max_check_attempts 1
check_command check_nt!SERVICESTATE! -d SHOWALL -l wuauserv
event_handler restart-autoupdate
}
 


Trong commands.cfg, định nghĩa restart-autoupdate, với đường dẫn tới autoupdate:

define command{
command_name restart-autoupdate
command_line $USER2$/autoupdate $HOSTADDRESS$
}
 

Cấu hình resource.cfg:
Code:
$USER2$=/usr/local/nagios/libexec/event_handlers

folder event_handlers và file autoupdate đã được set permission cho read, execute, write.

Trong script autoupdate, tui add 1 log:
Code:
LOGFILE=/usr/local/nagios/libexec/event_handlers/log.txt
echo "Restart Automatic Updates" >$LOGFILE
echo $1 >>$LOGFILE
echo $2 >>$LOGFILE


Cấu hình của Nagios.cfg:
Code:
log_event_handlers=1
enable_event_handlers=1


Khi service wuauserv (Automatic Updates) bị tắt, Nagios nhận biết trạng thái service bị tắt nhưng không thực thi script autoupdate lên (log.txt không được tạo). Và trong nagios.log cũng không thấy event_handler được tạo.

Nếu sử dụng lệnh check_nrpe thì service wuauserv sẽ được restart:
Code:
/usr/local/nagios/libexec/check_nrpe -H $HOSTNAME -c autoupdate

Như vậy, từ server gọi đến host vẫn tốt, chỉ là tại sao cái event nó không được gọi thôi.

Có bác nào có kinh nghiệm vụ này không?
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 00:04:10 (+0700) | #2 | 161817
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]
Hic hic, 39 views, chưa ai bị như tui hả smilie
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 00:50:43 (+0700) | #3 | 161825
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]

LeVuHoang wrote:
Khi service wuauserv (Automatic Updates) bị tắt, Nagios nhận biết trạng thái service bị tắt nhưng không thực thi script autoupdate lên (log.txt không được tạo). Và trong nagios.log cũng không thấy event_handler được tạo. 

Có khả năng bác phải xem lại permission trên cái script đó.
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:06:50 (+0700) | #4 | 161827
[Avatar]
tranhuuphuoc
Moderator

Joined: 05/09/2004 06:08:09
Messages: 865
Location: Lầu Xanh
Offline
[Profile] [PM] [WWW]
Lão mở file NsClient ++ post lên đây xem thử (NSC.INI)

Thử dùng
#./check_nrpe -H 127.0.0.1 -c check_users

#./check_nrpe -H RemoteIPAddress -c check_users

Nếu nó báo lổi connection refused thì .... smilie

Lão đang thí nghiệm mô hình server là *nix và remote là Windows để thử nghiệm á . Ping đến host nào đó, nếu nó sống thì chẳng giải quyết được vấn đề dùng nmap , netstat cho nó lẹ smilie

Tui chưa dùng Nagios để monitor bao giờ, chỉ bậy lão ráng chịu smilie
P/S : Hôm qua có mặt ở SG muốn rũ lão uống cà phê và anh em HVA 1 chút nhưng tiếc quá smilie

[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:11:32 (+0700) | #5 | 161828
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]

Có khả năng bác phải xem lại permission trên cái script đó.
 

Login vào user nagios và execute cái script đó, file log.txt vẫn tạo ra được lão. Nên tui nghĩ vấn đề ở đây không phải là permission. Ngoài ra, trong Nagios.log cũng không có log nói là đã execute cái script autoupdate.


#./check_nrpe -H RemoteIPAddress -c check_users

Nếu nó báo lổi connection refused thì ....
 

Từ server gởi lệnh qua host thì ok lão, nhưng vấn đề không phải ờ chỗ từ server -> client. Mà ở ngay server, cái script gởi lệnh không chịu thực thi (autoupdate). Tức nếu chạy ./check_nrpe bằng tay thì ok. Nhưng quan trọng là cái script execute check_nrpe tại sao nó lại không chạy, event_handler không thực thi smilie. Chỉ cần làm sao thằng nagios execute cái script đó là được.


Lão đang thí nghiệm mô hình server là *nix và remote là Windows để thử nghiệm á . Ping đến host nào đó, nếu nó sống thì chẳng giải quyết được vấn đề dùng nmap , netstat cho nó lẹ
 

Tui định monitor các service và tự động restart lại bị chết.

Thêm cái hình cho nó hoàng tráng.



Điệu này chắc phải mời bác conmale vào châm chít quá smilie smilie

P/S : Hôm qua có mặt ở SG muốn rũ lão uống cà phê và anh em HVA 1 chút nhưng tiếc quá
 

Anh em còn nhiều dịp mà, tui chưa.. chít liền đâu, lão đừng sợ smilie
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:30:43 (+0700) | #6 | 161832
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
@LeVuHoang: còn cái này bác ơi:

tranhuuphuoc wrote:
Lão mở file NsClient ++ post lên đây xem thử (NSC.INI)  
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:39:43 (+0700) | #7 | 161833
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]
Ngoài ra, tui set permission cho cái script autoupdate là 777 luôn rồi.

Lão mở file NsClient ++ post lên đây xem thử (NSC.INI)
 

Cái này là host/client trên Windows mà quanta. Như tui đã nói, từ server gõ comment để restart cái service trên Windows là ok rồi (server --> Windows - ok). Quan trọng là nagios execute cái script để chạy command đó lên thôi.

Nội dung script autoupdate:
Code:
LOGFILE=/usr/local/nagios/libexec/event_handlers/log.txt
echo "Restart Automatic Updates" >$LOGFILE
echo $1 >>$LOGFILE
echo $2 >>$LOGFILE

HOSTNAME=$2

echo $1
#if [ "$1" == "CRITICAL" ] ; then
	echo -n "Restarting Automatic Updates..."
	/usr/local/nagios/libexec/check_nrpe -H $HOSTNAME -c autoupdate
#fi

Gõ lệnh: ./autoupdate
Code:
# ./autoupdate CRITICAL 192.168.11.15
CRITICAL
Restarting Automatic Updates...
D:\Program Files\NSClient++>net start wuauserv 
The Automatic Updates service is starting.
The Automatic Updates service was started successfully.
#

---> Nagios -> Windows: Done.

Nhưng thôi, chiều lòng bác nè smilie

IP server (Nagios): 192.168.11.14
IP client (Windows): 192.168.11.15
autoupdate=D:\Program Files\NSClient++\scripts\autoupdate.bat

Code:
[modules]

;# NSCLIENT++ MODULES

;# A list with DLLs to load at startup.

;  You will need to enable some of these for NSClient++ to work.

; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

; *                                                               *

; * N O T I C E ! ! ! - Y O U   H A V E   T O   E D I T   T H I S *

; *                                                               *

; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

FileLogger.dll

CheckSystem.dll

CheckDisk.dll

NSClientListener.dll

NRPEListener.dll

SysTray.dll

CheckEventLog.dll

CheckHelpers.dll

CheckWMI.dll

;

; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!

;RemoteConfiguration.dll

; NSCA Agent is a new beta module use with care!

;NSCAAgent.dll

; LUA script module used to write your own "check deamon" (sort of) early beta.

LUAScript.dll

; Script to check external scripts and/or internal aliases, early beta.

CheckExternalScripts.dll

; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)

NRPEClient.dll

; Extreamly early beta of a task-schedule checker

;CheckTaskSched.dll







[Settings]

;# OBFUSCATED PASSWORD

;  This is the same as the password option but here you can store the password in an obfuscated manner.

;  *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the 

;  password. Its just a bit harder to do it at first glance.

;obfuscated_password=Jw0KAUUdXlAAUwASDAAB

;

;# PASSWORD

;  This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.

;password=secret-password

;

;# ALLOWED HOST ADDRESSES

;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.

;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).

;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access

allowed_hosts=192.168.0.0/24

;

;# USE THIS FILE

;  Use the INI file as opposed to the registry if this is 0 and the use_reg in the registry is set to 1 

;  the registry will be used instead.

use_file=1

;

; # USE SHARED MEMORY CHANNELS

;  This is the "new" way for using the system tray based on an IPC framework on top shared memmory channels and events.

;  It is brand new and (probably has bugs) so dont enable this unless for testing!

;  If set to 1 shared channels will be created and system tray icons created and such and such...

;shared_session=0





[log]

;# LOG DEBUG

;  Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test)

;debug=1

;

;# LOG FILE

;  The file to print log statements to

;file=nsclient.log

;

;# LOG DATE MASK

;  The format to for the date/time part of the log entry written to file.

;date_mask=%Y-%m-%d %H:%M:%S

;

;# LOG ROOT FOLDER

;  The root folder to use for logging.

;  exe = the folder where the executable is located

;  local-app-data = local application data (probably a better choice then the old default)

;root_folder=exe





[NSClient]

;# ALLOWED HOST ADDRESSES

;  This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon.

;  If you leave this blank the global version will be used instead.

allowed_hosts=192.168.11.14

;

;# NSCLIENT PORT NUMBER

;  This is the port the NSClientListener.dll will listen to.

port=12489

;

;# BIND TO ADDRESS

;  Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.

;  Leaving this blank will bind to all avalible IP adresses.

;bind_to_address=

;

;# SOCKET TIMEOUT

;  Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.

;socket_timeout=30



[NRPE]

;# NRPE PORT NUMBER

;  This is the port the NRPEListener.dll will listen to.

port=5666

;

;# COMMAND TIMEOUT

;  This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.

command_timeout=60

;

;# COMMAND ARGUMENT PROCESSING

;  This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.

allow_arguments=1

;

;# COMMAND ALLOW NASTY META CHARS

;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.

;allow_nasty_meta_chars=0

;

;# USE SSL SOCKET

;  This option controls if SSL should be used on the socket.

;use_ssl=1

;

;# BIND TO ADDRESS

;  Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.

;  Leaving this blank will bind to all avalible IP adresses.

; bind_to_address=

;

;# ALLOWED HOST ADDRESSES

;  This is a comma-delimited list of IP address of hosts that are allowed to talk to NRPE deamon.

;  If you leave this blank the global version will be used instead.

allowed_hosts=192.168.11.14

;

;# SCRIPT DIRECTORY

;  All files in this directory will become check commands.

;  *WARNING* This is undoubtedly dangerous so use with care!

script_dir=D:\Program Files\NSClient++\scripts\*.*

;

;# SOCKET TIMEOUT

;  Timeout when reading packets on incoming sockets. If the data has not arrived withint this time we will bail out.

;socket_timeout=30



[Check System]

;# CPU BUFFER SIZE

;  Can be anything ranging from 1s (for 1 second) to 10w for 10 weeks. Notice that a larger buffer will waste memory 

;  so don't use a larger buffer then you need (ie. the longest check you do +1).

CPUBufferSize=1h

;

;# CHECK RESOLUTION

;  The resolution to check values (currently only CPU).

;  The value is entered in 1/10:th of a second and the default is 10 (which means ones every second)

;CheckResolution=10

;

;# CHECK ALL SERVICES

;  Configure how to check services when a CheckAll is performed.

;  ...=started means services in that class *has* to be running.

;  ...=stopped means services in that class has to be stopped.

;  ...=ignored means services in this class will be ignored.

check_all_services[SERVICE_BOOT_START]=ignored

check_all_services[SERVICE_SYSTEM_START]=ignored

check_all_services[SERVICE_AUTO_START]=started

check_all_services[SERVICE_DEMAND_START]=ignored

check_all_services[SERVICE_DISABLED]=stopped



[External Script]

;# COMMAND TIMEOUT

;  This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.

;command_timeout=60

;

;# COMMAND ARGUMENT PROCESSING

;  This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.

;allow_arguments=0

;

;# COMMAND ALLOW NASTY META CHARS

;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.

;allow_nasty_meta_chars=0

;

;# COMMAND ALLOW NASTY META CHARS

;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.

;script_dir=c:\my\script\dir



[External Scripts]

;check_es_long=scripts\long.bat

;check_es_ok=scripts\ok.bat

;check_es_nok=scripts\nok.bat

;check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs

;check_powershell_warn=cmd /c echo scripts\powershell.ps1 | powershell.exe -command -



[External Alias]

;alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s

;alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED

;alias_service=checkServiceState CheckAll

;alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=physical

;alias_event_log=CheckEventLog file=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2d filter-severity==success filter-severity==informational truncate=1023 unique descriptions  "syntax=%severity%: %source%: %message% (%count%)"











; [includes]

;# The order when used is "reversed" thus the last included file will be "first"

;# Included files can include other files (be carefull only do basic recursive checking)

;

; myotherfile.ini

; real.ini





[NSCA Agent]

;# CHECK INTERVALL (in seconds)

;   How often we should run the checks and submit the results.

interval=5

;

;# ENCRYPTION METHOD

;   This option determines the method by which the send_nsca client will encrypt the packets it sends 

;   to the nsca daemon. The encryption 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 an encryption method.

;

; Note: The encryption method you specify here must match the decryption method the nsca daemon uses 

;       (as specified in the 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

;	6 = xTEA

;	8 = BLOWFISH

;	9 = TWOFISH

;	11 = RC2

;	14 = RIJNDAEL-128 (AES)

;	20 = SERPENT

;encryption_method=14

;

;# ENCRYPTION PASSWORD

;  This is the password/passphrase that should be used to encrypt the sent packets. 

;password=

;

;# BIND TO ADDRESS

;  Allows you to bind server to a specific local address. This has to be a dotted ip adress not a hostname.

;  Leaving this blank will bind to "one" local interface.

; -- not supported as of now -- 

;bind_to_address=

;

;# LOCAL HOST NAME

;  The name of this host (if empty "computername" will be used.

;hostname=

;

;# NAGIOS SERVER ADDRESS

;  The address to the nagios server to submit results to.

;nsca_host=192.168.11.14

;

;# NAGIOS SERVER PORT

;  The port to the nagios server to submit results to.

;nsca_port=5667

;



;# CHECK COMMAND LIST

;  The checks to run everytime we submit results back to nagios

;  Any command(alias/key) starting with a host_ is sent as HOST_COMMAND others are sent as SERVICE_COMMANDS

;  where the alias/key is used as service name.

;

[NSCA Commands]

my_cpu_check=checkCPU warn=80 crit=90 time=20m time=10s time=4

my_mem_check=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=page

my_svc_check=checkServiceState CheckAll exclude=wampmysqld exclude=MpfService

host_check=check_ok



[NRPE Handlers]

;# COMMAND DEFINITIONS

;# Command definitions that this daemon will run.

;# Can be either NRPE syntax:

;command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

;# Or simplified syntax:

;test=c:\test.bat foo $ARG1$ bar

;check_disk1=/usr/local/nagios/libexec/check_disk -w 5 -c 10

;# Or even loopback (inject) syntax (to run internal commands)

;# This is a way to run "NSClient" commands and other internal module commands such as check eventlog etc.

;check_cpu=inject checkCPU warn=80 crit=90 5 10 15

;check_eventlog=inject CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions

;check_disk_c=inject CheckFileSize ShowAll MaxWarn=1024M MaxCrit=4096M File:WIN=c:\ATI\*.*

;# But be careful:

; dont_check=inject dont_check This will "loop forever" so be careful with the inject command...

;# Check some escapings...

; check_escape=inject CheckFileSize ShowAll MaxWarn=1024M MaxCrit=4096M "File: foo \" WIN=c:\\WINDOWS\\*.*"

;# Some real world samples

;nrpe_cpu=inject checkCPU warn=80 crit=90 5 10 15

;nrpe_ok=scripts\ok.bat

;check_multi_line=scripts\multi_line.bat

;#

;# The sample scripts

;#

;check_long=scripts\long.bat

;check_ok=scripts\ok.bat

;check_nok=scripts\xlong.bat

;check_vbs=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs

autoupdate=D:\Program Files\NSClient++\scripts\autoupdate.bat



;# REMOTE NRPE PROXY COMMANDS

;  A list of commands that check other hosts.

;  Used by the NRPECLient module

[NRPE Client Handlers]

check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments



;# LUA SCRIPT SECTION

;  A list of all Lua scripts to load.

;[LUA Scripts]

;scripts\test.lua
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:42:21 (+0700) | #8 | 161834
[Avatar]
tranhuuphuoc
Moderator

Joined: 05/09/2004 06:08:09
Messages: 865
Location: Lầu Xanh
Offline
[Profile] [PM] [WWW]
Lão thử dùng cách này xem smilie
Download cái script này về (lưu nó đường dẫn thích hợp)

Code:
http://www.nagiosexchange.org/cgi-bin/page.cgi?g=Detailed%2F2639.html;d=1


Code:
http://www.nagiosexchange.org/cgi-bin/jump.cgi?ID=1471&view=File1;d=1


Thêm vào NSC.INI
check_updates=c:\windows\system32\cscript.exe //NoLogo //T:40 C:\Scripts\checkupdates.wsf $arg1$ 


command.cfg
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c $ARG1$ -a $ARG2$


Định nghĩa service mà lão cần giám sát (đây là phần templates)
define service{
use generic-service
host_name Name Of Host - replace this with your Host Name
service_description Updates
check_command check_nrpe!check_updates!-l


Apply cấu hình Nagios sau đó restart, reload lại Nagios

Good luck
[Up] [Print Copy]
  [Question]   Re: Problem với event_handler của Nagios 10/12/2008 01:45:08 (+0700) | #9 | 161835
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]
Chắc tui nói chưa rõ lắm nên lão hiểu nhầm. Không phải script chạy sai, mà là Nagios không thực thi cái script đó (bằng event_handler). Điển hình cụ thể là nó không save ra thành log.txt (trên server).

Lão xem thêm post ở trên của tui có nội dung script autoupdate và nó có thể restart Automatic Updates nha lão (Nagios -> Windows là ok rồi). Nhưng đó là gõ bằng tay, tui muốn Nagios tự động gọi cái script autoupdate ở trên mỗi khi service thay đổi state.

Document ở đây nè lão:
http://nagios.sourceforge.net/docs/1_0/eventhandlers.html

Khi service state thay đổi, event_handler sẽ cho phép execute 1 cái command. Từ command này, tui sẽ chạy check_nrpe để restart lại cái service. Nhưng không hiểu sao sự kiện event_handler không xuất hiện.
[Up] [Print Copy]
  [Question]   Problem với event_handler của Nagios 26/10/2010 14:55:23 (+0700) | #10 | 223750
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
Cái này chắc bác giải quyết từ... 2 năm về trước rồi nhưng tôi liều mình ghi lại, hy vọng nó có ích với ai đó.

LeVuHoang wrote:

Trong commands.cfg, định nghĩa restart-autoupdate, với đường dẫn tới autoupdate:
Code:
define command{
        command_name    restart-autoupdate
        command_line    $USER2$/autoupdate $HOSTADDRESS$
        }

 

Chỗ này bác định nghĩa thiếu SERVICESTATE rồi, nên nó đâu biết khi nào service die đâu mà gọi event handler:
Code:
define command{
        command_name    restart-autoupdate
        command_line    $USER2$/autoupdate $SERVICESTATE$ $HOSTADDRESS$
        }

LeVuHoang wrote:

Trong script autoupdate, tui add 1 log:
Code:
LOGFILE=/usr/local/nagios/libexec/event_handlers/log.txt
echo "Restart Automatic Updates" >$LOGFILE
echo $1 >>$LOGFILE
echo $2 >>$LOGFILE

 

Cái này là trên remote host chứ. Trên Nagios server bác cần một đoạn script check SERVICESTATE và restart thông qua check_nrpe:
Code:
#!/bin/bash

case "$1" in
    OK)
        ;;
    WARNING)
        ;;
    UNKNOWN)
        ;;
    CRITICAL)
        /usr/local/nagios/libexec/check_nrpe -H $2 -c autoupdate
        ;;
esac

exit 0

Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Problem với event_handler của Nagios 27/10/2010 10:05:33 (+0700) | #11 | 223783
LeVuHoang
HVA Friend

Joined: 08/03/2003 16:54:07
Messages: 1155
Offline
[Profile] [PM]
hi quanta,
Trong trường hợp này là cái script ghi log đó nằm trên server là đúng rồi. Chưa tính đến trường hợp SERVICESTATUS như thế nào là nó cũng không được thực thi.
Mình đã giải quyết vấn đề này với lý do là nó cần tty để chạy.
Cụ thể là default tty trong /etc/sudoers.
[Up] [Print Copy]
  [Question]   Problem với event_handler của Nagios 27/10/2010 10:53:13 (+0700) | #12 | 223789
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]

LeVuHoang wrote:
hi quanta,
Trong trường hợp này là cái script ghi log đó nằm trên server là đúng rồi.
 

Server nào bác? Nagios server hay remote server?
Let's build on a great foundation!
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|