You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2013/12/03 17:50:50 UTC
git commit: AMBARI-3958 - Metrics of HDFS,
YARN and HBase are not available on CentOS 5.9.
Updated Branches:
refs/heads/branch-1.4.2 17dd05485 -> 2fb24d9d2
AMBARI-3958 - Metrics of HDFS, YARN and HBase are not available on CentOS 5.9.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2fb24d9d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2fb24d9d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2fb24d9d
Branch: refs/heads/branch-1.4.2
Commit: 2fb24d9d2c38f44167978f53480d755126971c0d
Parents: 17dd054
Author: tbeerbower <tb...@hortonworks.com>
Authored: Tue Dec 3 11:21:39 2013 -0500
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Tue Dec 3 11:50:26 2013 -0500
----------------------------------------------------------------------
.../puppet/modules/hdp-ganglia/files/rrd.py | 4 +-
ambari-server/src/main/python/rrd.py | 139 -------------------
2 files changed, 2 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2fb24d9d/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py b/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
index f446fc2..c9b490e 100755
--- a/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
+++ b/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
@@ -98,8 +98,8 @@ sys.stdout.write("\n")
requestMethod = os.environ['REQUEST_METHOD']
if requestMethod == 'POST':
- postData = sys.stdin.read()
- queryString = urlparse.parse_qs(postData)
+ postData = sys.stdin.readline()
+ queryString = cgi.parse_qs(postData)
queryString = dict((k, v[0]) for k, v in queryString.items())
elif requestMethod == 'GET':
queryString = dict(cgi.parse_qsl(os.environ['QUERY_STRING']));
http://git-wip-us.apache.org/repos/asf/ambari/blob/2fb24d9d/ambari-server/src/main/python/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/rrd.py b/ambari-server/src/main/python/rrd.py
deleted file mode 100644
index d7ee49f..0000000
--- a/ambari-server/src/main/python/rrd.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import cgi
-#import cgitb
-import os
-import rrdtool
-import sys
-
-# place this script in /var/www/cgi-bin of the Ganglia collector
-# requires 'yum install rrdtool-python' on the Ganglia collector
-
-#cgitb.enable()
-
-def printMetric(clusterName, hostName, metricName, file, cf, start, end, resolution):
- if clusterName.endswith("rrds"):
- clusterName = ""
-
- args = [file, cf]
-
- if start is not None:
- args.extend(["-s", start])
-
- if end is not None:
- args.extend(["-e", end])
-
- if resolution is not None:
- args.extend(["-r", resolution])
-
- rrdMetric = rrdtool.fetch(args)
-
- time = rrdMetric[0][0]
- step = rrdMetric[0][2]
-
- sys.stdout.write(" {\n \"ds_name\":\"" + rrdMetric[1][0] +\
- "\",\n \"cluster_name\":\"" + clusterName +\
- "\",\n \"host_name\":\"" + hostName +\
- "\",\n \"metric_name\":\"" + metricName + "\",\n")
-
- firstDP = True
- sys.stdout.write(" \"datapoints\":[\n")
- for tuple in rrdMetric[2]:
- if tuple[0] is not None:
- if not firstDP:
- sys.stdout.write(",\n")
- firstDP = False
- sys.stdout.write(" [")
- sys.stdout.write(str(tuple[0]))
- sys.stdout.write(",")
- sys.stdout.write(str(time))
- sys.stdout.write("]")
- time = time + step
- sys.stdout.write("\n ]\n }")
- return
-
-def stripList(l):
- return([x.strip() for x in l])
-
-sys.stdout.write("Content-type: application/json\n\n")
-
-queryString = dict(cgi.parse_qsl(os.environ['QUERY_STRING']));
-
-sys.stdout.write("[\n")
-
-firstMetric = True
-
-if "m" in queryString:
- metricParts = queryString["m"].split(",")
-else:
- metricParts = [""]
-metricParts = stripList(metricParts)
-
-hostParts = []
-if "h" in queryString:
- hostParts = queryString["h"].split(",")
-hostParts = stripList(hostParts)
-
-if "c" in queryString:
- clusterParts = queryString["c"].split(",")
-else:
- clusterParts = [""]
-clusterParts = stripList(clusterParts)
-
-if "p" in queryString:
- rrdPath = queryString["p"]
-else:
- rrdPath = "/var/lib/ganglia/rrds/"
-
-start = None
-if "s" in queryString:
- start = queryString["s"]
-
-end = None
-if "e" in queryString:
- end = queryString["e"]
-
-resolution = None
-if "r" in queryString:
- resolution = queryString["r"]
-
-if "cf" in queryString:
- cf = queryString["cf"]
-else:
- cf = "AVERAGE"
-
-for cluster in clusterParts:
- for path, dirs, files in os.walk(rrdPath + cluster):
- pathParts = path.split("/")
- if len(hostParts) == 0 or pathParts[-1] in hostParts:
- for file in files:
- for metric in metricParts:
- if file.endswith(metric + ".rrd"):
- if not firstMetric:
- sys.stdout.write(",\n")
-
- printMetric(pathParts[-2], pathParts[-1], file[:-4], os.path.join(path, file), cf, start, end, resolution)
-
- firstMetric = False
-
-sys.stdout.write("\n]\n")
-sys.stdout.flush
-