-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/ganglia/gmond_python_modules
- Loading branch information
Showing
44 changed files
with
6,597 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apc_status | ||
=============== | ||
|
||
python module for ganglia 3.1. | ||
|
||
"apc_status" sends metrics on Another PHP Cache process status refering to | ||
apc-json.php. | ||
|
||
To use this you will need to copy apc-json.php to your webdir. | ||
|
||
## AUTHOR | ||
|
||
Jacob V. Rasmussen <jacobvrasmussen@gmail.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
modules { | ||
module { | ||
name = "apc_status" | ||
language = "python" | ||
|
||
# URL of the resident apc-json.php script, which will translate the APC figures to JSON | ||
param url { | ||
value = "http://localhost/apc-json.php" | ||
} | ||
|
||
# Which metric group should these metrics be put into | ||
param metric_group { | ||
value = "apc_cache" | ||
} | ||
} | ||
} | ||
|
||
collection_group { | ||
collect_every = 30 | ||
time_threshold = 90 | ||
|
||
metric { | ||
name = "apc_mem_size" | ||
title = "Total Memory" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_mem_avail" | ||
title = "Free Memory" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_mem_used" | ||
title = "Used Memory" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_slots" | ||
title = "Number of Slots" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_hits" | ||
title = "Number of Cache Hits" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_misses" | ||
title = "Number of Cache Misses" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_inserts" | ||
title = "Number of Cache Inserts" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_expunges" | ||
title = "Number of Cache Deletes" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_entries" | ||
title = "Cached Files" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_num_seg" | ||
title = "Segments" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_uptime" | ||
title = "Uptime" | ||
value_threshold = 0 | ||
} | ||
metric { | ||
name = "apc_request_rate" | ||
title = "Request Rate (hits, misses)" | ||
value_threshold = 0.0 | ||
} | ||
metric { | ||
name = "apc_hit_rate" | ||
title = "Hit Rate" | ||
value_threshold = 0.0 | ||
} | ||
metric { | ||
name = "apc_miss_rate" | ||
title = "Miss Rate" | ||
value_threshold = 0.0 | ||
} | ||
metric { | ||
name = "apc_insert_rate" | ||
title = "Insert Rate" | ||
value_threshold = 0.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
# | ||
# APC JSON builder | ||
# Used for Ganglia APC Status module | ||
# | ||
# Author: Jacob V. Rasmussen (jacobvrasmussen@gmail.com) | ||
# Site: http://blackthorne.dk | ||
# | ||
|
||
header("Content-type: text/plain"); | ||
|
||
function cmp_cache_list($a, $b) | ||
{ | ||
return ($b['num_hits'] - $a['num_hits']); | ||
} | ||
|
||
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1" || TRUE) | ||
{ | ||
$cache = apc_cache_info(); | ||
$mem = apc_sma_info(); | ||
$cache['uptime'] = time() - $cache['start_time']; | ||
$cache['request_rate'] = ($cache['num_hits'] + $cache['num_misses']) / $cache['uptime']; | ||
$cache['hit_rate'] = $cache['num_hits'] / $cache['uptime']; | ||
$cache['miss_rate'] = $cache['num_misses'] / $cache['uptime']; | ||
$cache['insert_rate'] = $cache['num_inserts'] / $cache['uptime']; | ||
$cache['num_seg'] = $mem['num_seg']; | ||
$cache['mem_size'] = $mem['num_seg'] * $mem['seg_size']; | ||
$cache['mem_avail'] = $mem['avail_mem']; | ||
$cache['mem_used'] = $cache['mem_size'] - $cache['mem_avail']; | ||
|
||
$cache_list = $cache['cache_list']; | ||
usort($cache_list, 'cmp_cache_list'); | ||
|
||
unset($cache['cache_list']); //lots of info that we don't need for a brief status | ||
unset($cache['deleted_list']); // ditto | ||
|
||
if (@$_REQUEST['debug'] == '1') | ||
{ | ||
print_r($cache); | ||
print_r($mem); | ||
print_r($cache_list); | ||
} | ||
echo json_encode($cache); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# | ||
# | ||
# Module: apc_status | ||
# Graphs the status of APC: Another PHP Cache | ||
# | ||
# Useage: To use this, you need to copy the apc-json.php file to your document root of the local webserver. | ||
# The path to the apc-json.php should be set in conf.d/apc_status.pyconf | ||
# | ||
# Author: Jacob V. Rasmussen (jacobvrasmussen@gmail.com) | ||
# Site: http://blackthorne.dk | ||
# | ||
|
||
import urllib2 | ||
import json | ||
import traceback | ||
|
||
NAME_PREFIX = "apc_" | ||
|
||
APC_STATUS_URL = "" | ||
|
||
descriptors = list() | ||
Desc_Skel = {} | ||
metric_list = { | ||
NAME_PREFIX + 'num_slots' : { 'type': 'uint', 'format' : '%d', 'unit': 'Slots', 'desc': 'Number of slots' }, | ||
NAME_PREFIX + 'num_hits' : { 'type': 'uint', 'format' : '%d', 'unit': 'Hits', 'desc': 'Number of cache hits' }, | ||
NAME_PREFIX + 'num_misses' : { 'type': 'uint', 'format' : '%d', 'unit': 'Misses', 'desc': 'Number of cache misses' }, | ||
NAME_PREFIX + 'num_inserts' : { 'type': 'uint', 'format' : '%d', 'unit': 'Inserts', 'desc': 'Number of cache inserts' }, | ||
NAME_PREFIX + 'expunges' : { 'type': 'uint', 'format' : '%d', 'unit': 'Deletes', 'desc': 'Number of cache deletes' }, | ||
NAME_PREFIX + 'mem_size' : { 'type': 'uint', 'format' : '%d', 'unit': 'Bytes', 'desc': 'Memory size' }, | ||
NAME_PREFIX + 'num_entries' : { 'type': 'uint', 'format' : '%d', 'unit': 'Entries', 'desc': 'Cached Files' }, | ||
NAME_PREFIX + 'uptime' : { 'type': 'uint', 'format' : '%d', 'unit': 'seconds', 'desc': 'Uptime' }, | ||
NAME_PREFIX + 'request_rate' : { 'type': 'float', 'format' : '%f', 'unit': 'requests/sec', 'desc': 'Request Rate (hits, misses)' }, | ||
NAME_PREFIX + 'hit_rate' : { 'type': 'float', 'format' : '%f', 'unit': 'requests/sec', 'desc': 'Hit Rate' }, | ||
NAME_PREFIX + 'miss_rate' : { 'type': 'float', 'format' : '%f', 'unit': 'requests/sec', 'desc': 'Miss Rate' }, | ||
NAME_PREFIX + 'insert_rate' : { 'type': 'float', 'format' : '%f', 'unit': 'requests/sec', 'desc': 'Insert Rate' }, | ||
NAME_PREFIX + 'num_seg' : { 'type': 'uint', 'format' : '%d', 'unit': 'fragments', 'desc': 'Segments' }, | ||
NAME_PREFIX + 'mem_avail' : { 'type': 'uint', 'format' : '%d', 'unit': 'bytes', 'desc': 'Free Memory' }, | ||
NAME_PREFIX + 'mem_used' : { 'type': 'uint', 'format' : '%d', 'unit': 'bytes', 'desc': 'Used Memory' }, | ||
} | ||
|
||
def get_value(name): | ||
try: | ||
req = urllib2.Request(APC_STATUS_URL, None, {'user-agent':'ganglia-apc-python'}) | ||
opener = urllib2.build_opener() | ||
f = opener.open(req) | ||
apc_stats = json.load(f) | ||
|
||
except urllib2.URLError: | ||
traceback.print_exc() | ||
|
||
return apc_stats[name[len(NAME_PREFIX):]] | ||
|
||
def create_desc(prop): | ||
d = Desc_Skel.copy() | ||
for k,v in prop.iteritems(): | ||
d[k] = v | ||
return d | ||
|
||
def metric_init(params): | ||
global descriptors, Desc_Skel, APC_STATUS_URL | ||
|
||
if "metric_group" not in params: | ||
params["metric_group"] = "apc_cache" | ||
|
||
Desc_Skel = { | ||
'name' : 'XXX', | ||
'call_back' : get_value, | ||
'time_max' : 60, | ||
'value_type' : 'uint', | ||
'units' : 'proc', | ||
'slope' : 'both', | ||
'format' : '%d', | ||
'description' : 'XXX', | ||
'groups' : params["metric_group"], | ||
} | ||
|
||
if "refresh_rate" not in params: | ||
params["refresh_rate"] = 15 | ||
|
||
if "url" not in params: | ||
params["url"] = "http://localhost/apc-json.php" | ||
|
||
|
||
APC_STATUS_URL = params["url"] | ||
|
||
if "spoof_host" in params: | ||
Desc_Skel["spoof_host"] = params["spoof_host"] | ||
|
||
for k,v in metric_list.iteritems(): | ||
descriptors.append(create_desc({ | ||
"name" : k, | ||
"call_back" : get_value, | ||
"value_type" : v["type"], | ||
"units" : v["unit"], | ||
"format" : v["format"], | ||
"description" : v["desc"], | ||
})) | ||
|
||
return descriptors | ||
|
||
def metric_cleanup(): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
metric_init({}) | ||
for d in descriptors: | ||
v = d['call_back'](d['name']) | ||
print 'value for %s is %s' % (d['name'], v) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
couchdb | ||
======= | ||
|
||
python module for ganglia 3.1. | ||
|
||
## Metrics | ||
* Number of authentication cache hits | ||
* Number of authentication cache misses | ||
* Number of times a document was read from a database | ||
* Number of times a document was changed | ||
* Number of open databases | ||
* Number of file descriptors CouchDB has open | ||
* Request time | ||
* Number of bulk requests | ||
* Number of clients for continuous _changes | ||
* Number of HTTP requests | ||
* Number of temporary view reads | ||
* Number of view reads | ||
* Number of HTTP COPY requests | ||
* Number of HTTP DELETE requests | ||
* Number of HTTP GET requests | ||
* Number of HTTP HEAD requests | ||
* Number of HTTP POST requests | ||
* Number of HTTP PUT requests | ||
* Number of HTTP 200 OK responses | ||
* Number of HTTP 201 Created responses | ||
* Number of HTTP 202 Accepted responses | ||
* Number of HTTP 301 Moved Permanently responses | ||
* Number of HTTP 304 Not Modified responses | ||
* Number of HTTP 400 Bad Request responses | ||
* Number of HTTP 401 Unauthorized responses | ||
* Number of HTTP 403 Forbidden responses | ||
* Number of HTTP 404 Not Found responses | ||
* Number of HTTP 405 Method Not Allowed responses | ||
* Number of HTTP 409 Conflict responses | ||
* Number of HTTP 412 Precondition Failed responses | ||
* Number of HTTP 500 Internal Server Error responses | ||
|
||
## Parameters | ||
* stats_url (The URL to query for CouchDB _stats. Default: 'http://127.0.0.1:5984/_stats' | ||
* refresh_rate (The time in seconds between polling the stats. Either 60, 300 or 900. Default: 60) | ||
|
||
## Notes | ||
* This has been tested with: | ||
- python 2.7.1 on Mac OS X | ||
- python 2.7.3 on Ubuntu 12.04 | ||
|
||
## AUTHORS | ||
|
||
Andreas Lappe <nd@kaeufli.ch> |
Oops, something went wrong.