


Nagiosで監視している機器がしきい値を超えてアラートが発生した場合に管理者にメールを通知する設定を行いました
Nagios
http://www.nagios.org/
- contacts.cfgの編集
設定ファイルの”/usr/local/nagios/etc/objects/contacts.cfg”を編集します
nagiosadmin@localhostの部分を実際の管理者のアドレスに変更します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
; html-script: false ] ############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don&amp;#039;t need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that&amp;#039;s you) # This contact definition inherits a lot of default values from the &amp;#039;generic-contact&amp;#039; # template which is defined elsewhere. define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagiosadmin@localhost ; << ***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin } |
メールアドレスの設定としてはこの部分ですが、ただし使用するSMTPサーバはlocalhostになっています。その部分は下記のファイルに記述されています
- /usr/local/nagios/etc/objects/commands.cfg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
; html-script: false ]################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. As an example, some systems will require # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below. # ################################################################################ # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } |
サンプルでは/bin/mailを使用してアラートメールを送信するようになっていますので、他のSMTPサーバを使用する場合はここの記述を変更する必要があります
この状態でアラートが発生すると下記のようなメールが管理者に届きます
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
; html-script: false ]Subject: ** PROBLEM Service Alert: VMWare ESXi/ESXi Memory usage is WARNING ** ***** Nagios ***** Notification Type: PROBLEM Service: ESXi Memory usage Host: VMWare ESXi Address: 192.168.1.10 State: WARNING Date/Time: Wed Aug 21 18:34:19 JST 2013 Additional Info: CHECK_VMWARE_API.PL WARNING - mem usage=85.30 % |