Sfoglia il codice sorgente

AMBARI-2012. Check Ambari-agent process - nagios alert is only being configured on the nagios-server host. (smohanty)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1471547 13f79535-47bb-0310-9956-ffa450edef68
Sumit Mohanty 12 anni fa
parent
commit
42cb50e2f5

+ 3 - 0
CHANGES.txt

@@ -786,6 +786,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2012. Check Ambari-agent process - nagios alert is only being
+ configured on the nagios-server host. (smohanty)
+
  AMBARI-2001. Filtering on Jobs table does not work under certain situations.
  (yusaku)
 

+ 1 - 0
ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp

@@ -76,6 +76,7 @@ class hdp-nagios::params() inherits hdp::params
     snamenode => {host_member_info => 'snamenode_host'},
     slaves => {host_member_info => 'slave_hosts'},
     tasktracker-servers => {host_member_info => 'mapred_tt_hosts'},
+    agent-servers => {host_member_info => 'all_hosts'},
     nagios-server => {host_member_info => 'nagios_server_host'},
     jobtracker  => {host_member_info => 'jtnode_host'},
     ganglia-server => {host_member_info => 'ganglia_server_host'},

+ 1 - 1
ambari-agent/src/main/puppet/modules/hdp-nagios/templates/hadoop-services.cfg.erb

@@ -78,7 +78,7 @@ define service {
 
 # AMBARI AGENT Checks
 define service {
-        hostgroup_name          nagios-server
+        hostgroup_name          agent-servers
         use                     hadoop-service
         service_description     AMBARI::Check ambari-agent process
         servicegroups           AMBARI

+ 1 - 0
ambari-agent/src/main/puppet/modules/hdp/manifests/configfile.pp

@@ -31,6 +31,7 @@ define hdp::configfile(
   $snamenode_host = $hdp::params::snamenode_host,
   $slave_hosts = $hdp::params::slave_hosts,
   $mapred_tt_hosts = $hdp::params::mapred_tt_hosts,
+  $all_hosts = $hdp::params::all_hosts,
   $hbase_rs_hosts = $hdp::params::hbase_rs_hosts,
   $zookeeper_hosts = $hdp::params::zookeeper_hosts,
   $hbase_master_hosts = $hdp::params::hbase_master_hosts,

+ 2 - 0
ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp

@@ -71,6 +71,8 @@ class hdp::params()
   #if mapred_tt_hosts not given it is assumed that tasktracker servers on same nodes as slaves
   $mapred_tt_hosts = hdp_default("mapred_tt_hosts", $slave_hosts)
 
+  $all_hosts = hdp_default("all_hosts")
+
   $hive_server_host = hdp_default("hive_server_host", "")
   $oozie_server =  hdp_default("oozie_server", "")
   $webhcat_server_host = hdp_default("webhcat_server_host", "")

+ 5 - 3
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -922,7 +922,8 @@ public class AmbariManagementControllerImpl implements
 
     // Generate cluster host info
     execCmd.setClusterHostInfo(
-        StageUtils.getClusterHostInfo(cluster, hostsMap, injector));
+        StageUtils.getClusterHostInfo(
+            clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap, injector));
 
     Host host = clusters.getHost(scHost.getHostName());
 
@@ -2194,7 +2195,8 @@ public class AmbariManagementControllerImpl implements
         // Generate cluster host info
         stage.getExecutionCommandWrapper(clientHost, smokeTestRole)
             .getExecutionCommand()
-            .setClusterHostInfo(StageUtils.getClusterHostInfo(cluster, hostsMap, injector));
+            .setClusterHostInfo(StageUtils.getClusterHostInfo(
+                clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap, injector));
       }
 
       RoleGraph rg = new RoleGraph(rco);
@@ -4018,7 +4020,7 @@ public class AmbariManagementControllerImpl implements
 
     // Generate cluster host info
     execCmd.setClusterHostInfo(
-      StageUtils.getClusterHostInfo(clusters.getCluster(clusterName), hostsMap, injector));
+      StageUtils.getClusterHostInfo(clusters.getHostsForCluster(clusterName), cluster, hostsMap, injector));
   }
 
   private void addDecommissionDatanodeAction(

+ 14 - 1
ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java

@@ -34,6 +34,7 @@ import javax.xml.bind.JAXBException;
 
 import com.google.gson.Gson;
 import com.google.inject.Injector;
+import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.Stage;
@@ -41,6 +42,8 @@ import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
 import org.apache.commons.logging.Log;
@@ -181,7 +184,9 @@ public class StageUtils {
   }
 
 
-  public static Map<String, List<String>> getClusterHostInfo(Cluster cluster, HostsMap hostsMap, Injector injector) {
+  public static Map<String, List<String>> getClusterHostInfo(
+      Map<String, Host> allHosts, Cluster cluster, HostsMap hostsMap,
+      Injector injector) throws AmbariException {
     Map<String, List<String>> info = new HashMap<String, List<String>>();
     if (cluster.getServices() != null) {
       for (String serviceName : cluster.getServices().keySet()) {
@@ -220,6 +225,14 @@ public class StageUtils {
         }
       }
     }
+
+    // Add a list of all host for agent and host monitoring
+    List<String> allHostNames = new ArrayList<String>();
+    for (Host host : allHosts.values()) {
+      allHostNames.add(host.getHostName());
+    }
+    info.put("all_hosts", allHostNames);
+
     return info;
   }
 

+ 7 - 2
ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java

@@ -188,26 +188,31 @@ public class TestStageUtils {
     fsm.addHost("h1");
     fsm.addHost("h2");
     fsm.addHost("h3");
+    fsm.addHost("h4");
     fsm.getCluster("c1").setDesiredStackVersion(new StackId("HDP-0.1"));
     fsm.getHost("h1").setOsType("centos5");
     fsm.getHost("h2").setOsType("centos5");
     fsm.getHost("h3").setOsType("centos5");
+    fsm.getHost("h4").setOsType("centos5");
     fsm.getHost("h1").persist();
     fsm.getHost("h2").persist();
     fsm.getHost("h3").persist();
+    fsm.getHost("h4").persist();
     fsm.mapHostToCluster("h1", "c1");
     fsm.mapHostToCluster("h2", "c1");
     fsm.mapHostToCluster("h3", "c1");
+    fsm.mapHostToCluster("h4", "c1");
     String [] hostList = {"h1", "h2", "h3" };
     addHdfsService(fsm.getCluster("c1"), hostList, injector);
     addHbaseService(fsm.getCluster("c1"), hostList, injector);
     addMapreduceService(fsm.getCluster("c1"), hostList, injector);
-    Map<String, List<String>> info = StageUtils.getClusterHostInfo(fsm
-        .getCluster("c1"), new HostsMap(injector.getInstance(Configuration.class)), injector);
+    Map<String, List<String>> info = StageUtils.getClusterHostInfo(fsm.getHostsForCluster("c1"),
+        fsm.getCluster("c1"), new HostsMap(injector.getInstance(Configuration.class)), injector);
     assertEquals(2, info.get("slave_hosts").size());
     assertEquals(2, info.get("mapred_tt_hosts").size());
     assertEquals(2, info.get("hbase_rs_hosts").size());
     assertEquals(1, info.get("hbase_master_hosts").size());
+    assertEquals(4, info.get("all_hosts").size());
     assertEquals("h1", info.get("hbase_master_hosts").get(0));
 
     assertFalse(info.get("ambari_db_rca_url").get(0).contains(Configuration.HOSTNAME_MACRO));