Skip to content

Commit

Permalink
Merge pull request #186 from debianized/master
Browse files Browse the repository at this point in the history
Added vm tc space metrics for hhvm module
  • Loading branch information
jbuchbinder committed Feb 17, 2015
2 parents d90c3dc + 005cb68 commit 64a5002
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 4 deletions.
29 changes: 28 additions & 1 deletion hhvm/README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
7 changes: 6 additions & 1 deletion hhvm/conf.d/hhvm.pyconf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ modules {
language = "python"

param url {
value = 'http://localhost:9001/'
value = 'http://localhost:9001'
}
param user {
value = ''
Expand Down Expand Up @@ -34,4 +34,9 @@ collection_group {
title = "hhvm_jemalloc_\\1"
}

metric {
name_match = "hhvm_vm_tcspace_(.+)"
title = "hhvm_vm_tcspace_\\1"
}

}
11 changes: 11 additions & 0 deletions hhvm/graph.d/hhvm_vm_rds_aggregated_report.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
14 changes: 14 additions & 0 deletions hhvm/graph.d/hhvm_vm_tcspace_aggregated_report.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
134 changes: 133 additions & 1 deletion hhvm/python_modules/hhvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <jj@debianized.net>
# License to use, modify, and distribute under the GPL
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 = {}
Expand All @@ -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:
Expand Down Expand Up @@ -257,6 +310,7 @@ def metric_init(params):
memory_data = MemoryData()
health_data = HealthData()
jemalloc_data = JemallocData()
tcspace_data = TCSpaceData()

descriptors = []

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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


Expand All @@ -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': ''
}
Expand Down
2 changes: 1 addition & 1 deletion zeromq_pub/python_modules/zpubmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 64a5002

Please sign in to comment.