diff --git a/hhvm/README.mkdn b/hhvm/README.mkdn index c6af043c..b5746cf3 100644 --- a/hhvm/README.mkdn +++ b/hhvm/README.mkdn @@ -50,6 +50,32 @@ This module supports two types of authentication: * hhvm_jemalloc_low_mapped * hhvm_jemalloc_low_active * hhvm_jemalloc_error +* hhvm_vm_tcspace_code_hot +* hhvm_vm_tcspace_code_main +* hhvm_vm_tcspace_code_prof +* hhvm_vm_tcspace_code_cold +* hhvm_vm_tcspace_code_frozen +* hhvm_vm_tcspace_data +* hhvm_vm_tcspace_rds +* hhvm_vm_tcspace_rds_local +* hhvm_vm_tcspace_persistent_rds +* hhvm_vm_tcspace_cloned_closures +* hhvm_vm_tcspace_total + +## Optional graphs + +* hhvm_jemalloc_aggregated_report +* hhvm_mem_proc_report +* hhvm_vm_rds_aggregated_report +* hhvm_vm_tcspace_aggregated_report +* hhvm_mem_tcjit_aggregated_report (hhvm >= 3.4) +* hhvm_mem_tcjit_code_cold_report (hhvm >= 3.4) +* hhvm_mem_tcjit_code_frozen_report (hhvm >= 3.4) +* hhvm_mem_tcjit_code_hot_report (hhvm >= 3.4) +* hhvm_mem_tcjit_code_main_report (hhvm >= 3.4) +* hhvm_mem_tcjit_code_prof_report (hhvm >= 3.4) +* hhvm_mem_tcjit_data_report (hhvm >= 3.4) +* hhvm_mem_tcjit_total_report (hhvm >= 3.4) ## Parameters @@ -61,11 +87,12 @@ This module supports two types of authentication: * v1.0.0 - 2015-01-15 - Initial version * v1.0.1 - 2015-02-10 - Added debug mode +* v1.0.2 - 2015-02-12 - Added vm tc space metrics ## Notes * Tested with python 2.7 and Ganglia 3.6 -* Tested with HHVM 3.4 and 3.5 +* Tested with HHVM 3.3.3, 3.4.2 and 3.5.0 ## AUTHORS diff --git a/hhvm/conf.d/hhvm.pyconf b/hhvm/conf.d/hhvm.pyconf index 023e368b..417c2038 100644 --- a/hhvm/conf.d/hhvm.pyconf +++ b/hhvm/conf.d/hhvm.pyconf @@ -4,7 +4,7 @@ modules { language = "python" param url { - value = 'http://localhost:9001/' + value = 'http://localhost:9001' } param user { value = '' @@ -34,4 +34,9 @@ collection_group { title = "hhvm_jemalloc_\\1" } + metric { + name_match = "hhvm_vm_tcspace_(.+)" + title = "hhvm_vm_tcspace_\\1" + } + } diff --git a/hhvm/graph.d/hhvm_vm_rds_aggregated_report.json b/hhvm/graph.d/hhvm_vm_rds_aggregated_report.json new file mode 100644 index 00000000..c252b9e6 --- /dev/null +++ b/hhvm/graph.d/hhvm_vm_rds_aggregated_report.json @@ -0,0 +1,11 @@ +{ + "report_name" : "hhvm vm tc space rds aggregated report", + "report_type" : "standard", + "title" : "hhvm vm tc space rds aggregated report", + "vertical_label" : "Bytes", + "series" : [ + { "metric": "hhvm_vm_tcspace_rds", "color": "00DD00", "label": "vm tc space code hot", "line_width": "2", "type": "line" }, + { "metric": "hhvm_vm_tcspace_rds_local", "color": "0000DD", "label": "vm tc space code main", "line_width": "2", "type": "line" }, + { "metric": "hhvm_vm_tcspace_persistent_rds", "color": "A20025", "label": "vm tc space code prof", "line_width": "2", "type": "line" } + ] +} diff --git a/hhvm/graph.d/hhvm_vm_tcspace_aggregated_report.json b/hhvm/graph.d/hhvm_vm_tcspace_aggregated_report.json new file mode 100644 index 00000000..d6064bc1 --- /dev/null +++ b/hhvm/graph.d/hhvm_vm_tcspace_aggregated_report.json @@ -0,0 +1,14 @@ +{ + "report_name" : "hhvm vm tc space aggregated report", + "report_type" : "standard", + "title" : "hhvm vm tc space aggregated report", + "vertical_label" : "Bytes", + "series" : [ + { "metric": "hhvm_vm_tcspace_code_hot", "color": "00DD00", "label": "vm tc space code hot", "line_width": "2", "type": "stack" }, + { "metric": "hhvm_vm_tcspace_code_main", "color": "0000DD", "label": "vm tc space code main", "line_width": "2", "type": "stack" }, + { "metric": "hhvm_vm_tcspace_code_prof", "color": "A20025", "label": "vm tc space code prof", "line_width": "2", "type": "stack" }, + { "metric": "hhvm_vm_tcspace_code_cold", "color": "FFFF00", "label": "vm tc space code cold", "line_width": "2", "type": "stack" }, + { "metric": "hhvm_vm_tcspace_code_frozen", "color": "825A2C", "label": "vm tc space code frozen", "line_width": "2", "type": "stack" }, + { "metric": "hhvm_vm_tcspace_data", "color": "FF00FF", "label": "vm tc space data", "line_width": "2", "type": "stack" } + ] +} diff --git a/hhvm/python_modules/hhvm.py b/hhvm/python_modules/hhvm.py index 5f194bb8..c245d737 100644 --- a/hhvm/python_modules/hhvm.py +++ b/hhvm/python_modules/hhvm.py @@ -11,6 +11,8 @@ # * Initial version # v1.0.1 - 2015-02-10 # * Added debug mode +# v1.0.2 - 2015-02-12 +# * Added vm tc space metrics # # Copyright (c) 2015 Juan J. Villalobos # License to use, modify, and distribute under the GPL @@ -111,6 +113,30 @@ name_map['hhvm_jemalloc_error'] = \ 'hhvm_jemalloc_error' +name_map['hhvm_vm_tcspace_code_hot'] = \ + 'code.hot' +name_map['hhvm_vm_tcspace_code_main'] = \ + 'code.main' +name_map['hhvm_vm_tcspace_code_prof'] = \ + 'code.prof' +name_map['hhvm_vm_tcspace_code_cold'] = \ + 'code.cold' +name_map['hhvm_vm_tcspace_code_frozen'] = \ + 'code.frozen' +name_map['hhvm_vm_tcspace_data'] = \ + 'data' +name_map['hhvm_vm_tcspace_rds'] = \ + 'RDS' +name_map['hhvm_vm_tcspace_rds_local'] = \ + 'RDSLocal' +name_map['hhvm_vm_tcspace_persistent_rds'] = \ + 'persistentRDS' +name_map['hhvm_vm_tcspace_cloned_closures'] = \ + 'cloned-closures' +name_map['hhvm_vm_tcspace_total'] = \ + 'total' + + url = '' username = '' password = '' @@ -180,6 +206,25 @@ def get(self, name): return 0 +class TCSpaceData(object): + '''Object to store /vm-tcspace endpoint result''' + global url, password + + def __init__(self): + self.url = url + '/vm-tcspace?auth=' + password + self.data = {} + logging.debug('TCSpaceData object initialized pointing to ' + self.url) + + def get(self, name): + try: + logging.debug('TCSpaceData get method called') + self.data = parse_vm_tcspace(fetch_url(self.url)) + return int(self.data[name_map[name]]) + except Exception as e: + logging.error('TCSpaceData get method failed, ' + 'could not parse output data, retval=0' + e.message) + + def flatten(structure, key="", path="", flattened=None): if flattened is None: flattened = {} @@ -194,6 +239,14 @@ def flatten(structure, key="", path="", flattened=None): return flattened +def parse_vm_tcspace(tsv_data, result=None): + if result is None: + result = {} + result = dict((line.rstrip().split()[5], line.rstrip().split()[1]) + for line in tsv_data) + return result + + def fetch_url(url): '''Returns fetched url''' try: @@ -257,6 +310,7 @@ def metric_init(params): memory_data = MemoryData() health_data = HealthData() jemalloc_data = JemallocData() + tcspace_data = TCSpaceData() descriptors = [] @@ -296,6 +350,18 @@ def metric_init(params): 'groups': 'hhvm', } + Desc_Skel_TCSpace = { + 'name': 'XXX', + 'call_back': tcspace_data.get, + 'time_max': 20, + 'value_type': 'uint', + 'format': '%u', + 'units': 'XXX', + 'slope': 'both', # zero|positive|negative|both + 'description': 'XXX', + 'groups': 'hhvm', + } + descriptors.append(create_desc(Desc_Skel_Memory, { "name": "hhvm_mem_procstats_vmsize", "units": "Bytes", @@ -524,6 +590,72 @@ def metric_init(params): "description": "hhvm jemalloc error", })) + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_code_hot", + "units": "Bytes", + "description": "hhvm vm tcspace code hot", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_code_main", + "units": "Bytes", + "description": "hhvm vm tcspace code main", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_code_prof", + "units": "Bytes", + "description": "hhvm vm tcspace code prof", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_code_cold", + "units": "Bytes", + "description": "hhvm vm tcspace code cold", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_code_frozen", + "units": "Bytes", + "description": "hhvm vm tcspace code frozen", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_data", + "units": "Bytes", + "description": "hhvm vm tcspace data", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_rds", + "units": "Bytes", + "description": "hhvm vm tcspace rds", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_rds_local", + "units": "Bytes", + "description": "hhvm vm tcspace rds local", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_persistent_rds", + "units": "Bytes", + "description": "hhvm vm tcspace persistent rds", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_cloned_closures", + "units": "Bytes", + "description": "hhvm vm tcspace cloned closures", + })) + + descriptors.append(create_desc(Desc_Skel_TCSpace, { + "name": "hhvm_vm_tcspace_total", + "units": "Bytes", + "description": "hhvm vm tcspace total", + })) + return descriptors @@ -536,7 +668,7 @@ def metric_cleanup(): # This code is for debugging and unit testing if __name__ == '__main__': params = { - 'url': 'http://localhost/memory.json', + 'url': 'http://localhost:9001', 'user': '', 'pass': '' } diff --git a/zeromq_pub/python_modules/zpubmon.py b/zeromq_pub/python_modules/zpubmon.py index db70630d..4405a54a 100644 --- a/zeromq_pub/python_modules/zpubmon.py +++ b/zeromq_pub/python_modules/zpubmon.py @@ -78,7 +78,7 @@ def metric_init(params): """ groups = params.pop('groups', 'ZeroMQ') - counter = {name: 0 for name in params} + counter = dict((name, 0) for name in params) thread = threading.Thread(target=zmq_pub_mon, args=(params, counter)) thread.daemon = True