You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2015/01/08 00:56:08 UTC
[2/2] ambari git commit: AMBARI-9012. Add Nagios-SNMP contrib to
Ambari. (Cabir Zounaidou via mahadev)
AMBARI-9012. Add Nagios-SNMP contrib to Ambari. (Cabir Zounaidou via mahadev)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6b1eef55
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6b1eef55
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6b1eef55
Branch: refs/heads/trunk
Commit: 6b1eef55ec692db337233c8f676b8725eae10652
Parents: d7a293b
Author: Mahadev Konar <ma...@apache.org>
Authored: Wed Jan 7 15:55:52 2015 -0800
Committer: Mahadev Konar <ma...@apache.org>
Committed: Wed Jan 7 15:55:52 2015 -0800
----------------------------------------------------------------------
contrib/nagios-snmp/README.md | 99 ++++++++++++++++++++
.../src/nagios/objects/snmp-commands.cfg | 33 +++++++
.../src/nagios/objects/snmp-contacts.cfg | 31 ++++++
contrib/nagios-snmp/src/scripts/send-host-trap | 29 ++++++
.../nagios-snmp/src/scripts/send-service-trap | 30 ++++++
5 files changed, 222 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6b1eef55/contrib/nagios-snmp/README.md
----------------------------------------------------------------------
diff --git a/contrib/nagios-snmp/README.md b/contrib/nagios-snmp/README.md
new file mode 100644
index 0000000..dd76f46
--- /dev/null
+++ b/contrib/nagios-snmp/README.md
@@ -0,0 +1,99 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+Ambari Server integration with SNMP traps
+=========================================
+Ambari uses nagios to manage alerts in the cluster. When a node goes down or a service state changes in the cluster, nagios
+will handle those events and is monitored using Ambari-web. This document describes how to integrate alerts with remote
+SNMP management station by sending SNMP traps. By enabling SNMP traps, Ambari & Hadoop cluster alerts can be monitored
+using remote management station (like OpenNMS, HP OpenView, etc.,).
+
+ This will work with Ambari Server 1.7.0 and below. In Ambari 2.0.0, this feature will be
+ replaced by alert framework.
+
+Prerequisites:
+--------------
+1. Nagios server should be running in one of the hadoop cluster node. (Need not to be same node as Ambari server).
+2. SNMP should be installed in the node where nagios server is running. Run the following command to install net-snmp
+and net-snmp-utils.
+> yum install net-snmp net-snmp-utils net-snmp-devel
+3. There should be connectivity between the hadoop node running nagios server and the management station. The snmptrap
+command will use 162/udp to send trap to the management station.
+
+Instructions:
+-------------
+1. Copy the file src/nagios/objects/snmp-commands.cfg to {nagios\_home\_dir}/objects/snmp-commands.cfg in the node where nagios is running.
+This file defines the command to send traps for service and host failures.
+
+ The default home directory (nagios_home_dir) for nagios is /etc/nagios
+
+2. Copy the file src/nagios/objects/snmp-contacts.cfg to {nagios\_home\_dir}/objects/snmp-contacts.cfg in the node where nagios is running.
+This file defines the **snmp-management-station** contact.
+
+3. In the node where ambari-server is running, edit file /var/lib/ambari-server/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
+and add below lines just before the {{nagios\_host\_cfg}}
+
+ <pre><code>#Definitions for SNMP traps
+ cfg_file=/etc/nagios/objects/snmp-commands.cfg
+ cfg_file=/etc/nagios/objects/snmp-contacts.cfg</code></pre>
+
+ Note: If the home directory is different than /etc/nagios, use the updated home directory. The updated configuration will be automatically
+ pushed to the nagios server when ambari-server restarted.
+
+4. To enable SNMP trap, edit file /var/lib/ambari-server/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/contacts.cfg.j2
+in the ambari-server and add **snmp-management-station** to the contract group **admins**
+
+ > members {{nagios\_web\_login}},sys_logger,**snmp-management-station**
+
+5. Copy the file src/scripts/send-service-trap to /usr/local/bin/send-service-trap in the node where nagios is running.
+Also, run the following command
+
+ > chmod +x /usr/local/bin/send-service-trap
+
+ > chown nagios:nagios /usr/local/bin/send-service-trap
+
+6. Copy the file src/scripts/send-host-trap to /usr/local/bin/send-host-trap in the node where nagios is running.
+Also, run the following command
+
+ > chmod +x /usr/local/bin/send-service-trap
+
+ > chown nagios:nagios /usr/local/bin/send-service-trap
+
+7. Download nagios MIBS from *http://ftp.cc.uoc.gr/mirrors/monitoring-plugins/mib/nagiosmib-1.0.0.tar.gz* and
+extract the files to /usr/share/snmp/mibs/ directory.
+
+8. Restart ambari-server
+ > ambari-server restart
+
+9. Launch ambari-web (or GUI) in the browser and login. Select Nagios server and restart the service.
+
+10. Configure management station by editing file /etc/hosts and add the below line
+
+ <MGMT_STATION_IP> snmp-manager
+
+11. For integrating with existing management station or NMS system,
+ 1. Download the nagios MIB's from *http://ftp.cc.uoc.gr/mirrors/monitoring-plugins/mib/nagiosmib-1.0.0.tar.gz*
+ 2. Extract and copy the files under MIB directory of the management station's (or NMS) mib directory.
+ 3. Import the mibs if required.
+
+Testing:
+-------
+To test whether the snmptraps are triggered, use the following procedure.
+
+1. Load the MIB in the snmp management system.
+2. Make sure the snmp management system IP (or FQDN) is configured in the /etc/hosts file in the node where
+nagios server is running.
+3. Open the ambari-web in the browser and login. Try to stop some services from ambari-web and check the snmptraps
+are received by the snmp management station.
http://git-wip-us.apache.org/repos/asf/ambari/blob/6b1eef55/contrib/nagios-snmp/src/nagios/objects/snmp-commands.cfg
----------------------------------------------------------------------
diff --git a/contrib/nagios-snmp/src/nagios/objects/snmp-commands.cfg b/contrib/nagios-snmp/src/nagios/objects/snmp-commands.cfg
new file mode 100644
index 0000000..81087bf
--- /dev/null
+++ b/contrib/nagios-snmp/src/nagios/objects/snmp-commands.cfg
@@ -0,0 +1,33 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+#
+
+# 'send-service-trap' command definition
+define command {
+ command_name send-service-trap
+ command_line /usr/local/bin/send-service-trap snmp-manager public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
+}
+
+# 'send-host-trap' command definition
+define command {
+ command_name send-host-trap
+ command_line /usr/local/bin/send-host-trap snmp-manager public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6b1eef55/contrib/nagios-snmp/src/nagios/objects/snmp-contacts.cfg
----------------------------------------------------------------------
diff --git a/contrib/nagios-snmp/src/nagios/objects/snmp-contacts.cfg b/contrib/nagios-snmp/src/nagios/objects/snmp-contacts.cfg
new file mode 100644
index 0000000..cf44858
--- /dev/null
+++ b/contrib/nagios-snmp/src/nagios/objects/snmp-contacts.cfg
@@ -0,0 +1,31 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+#
+
+define contact {
+ contact_name snmp-management-station
+ use generic-contact
+ alias Management Station
+ service_notification_options w,u,c,r
+ host_notification_options d,u,r
+ service_notification_commands send-service-trap
+ host_notification_commands send-host-trap
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6b1eef55/contrib/nagios-snmp/src/scripts/send-host-trap
----------------------------------------------------------------------
diff --git a/contrib/nagios-snmp/src/scripts/send-host-trap b/contrib/nagios-snmp/src/scripts/send-host-trap
new file mode 100644
index 0000000..388cc6f
--- /dev/null
+++ b/contrib/nagios-snmp/src/scripts/send-host-trap
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+#
+# Inputs:
+# $1 - Management station host name (example: snmp-manager).
+# $2 - Community string (example: public, default, etc.,).
+# $3 - Host name where the trap originated.
+# $4 - Current state of the host (0=UP, 1=DOWN, 2=UNREACHABLE)
+# $5 - Host specific description
+#
+# For more details, refer to NAGIOS-ROOT-MIB.txt and NAGIOS-NOTIFY-MIB.txt
+#
+
+# Sending trap to the management station
+/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"
http://git-wip-us.apache.org/repos/asf/ambari/blob/6b1eef55/contrib/nagios-snmp/src/scripts/send-service-trap
----------------------------------------------------------------------
diff --git a/contrib/nagios-snmp/src/scripts/send-service-trap b/contrib/nagios-snmp/src/scripts/send-service-trap
new file mode 100644
index 0000000..fc7ffe4
--- /dev/null
+++ b/contrib/nagios-snmp/src/scripts/send-service-trap
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+#
+# Inputs:
+# $1 - Management station host name (example: snmp-manager).
+# $2 - Community string (example: public, default, etc.,).
+# $3 - Host name where the trap originated.
+# $4 - Description of the service.
+# $5 - Severity ( 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN).
+# $6 - Service specific description.
+#
+# For more details, refer to NAGIOS-ROOT-MIB.txt and NAGIOS-NOTIFY-MIB.txt
+#
+
+# Sending trap to the management station
+/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$3" nSvcDesc s "$4" nSvcStateID i $5 nSvcOutput s "$6"