Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Watson
committed
Oct 29, 2011
1 parent
d644ade
commit b91ebdc
Showing
1 changed file
with
17 additions
and
0 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,17 @@ | ||
import json | ||
import requests | ||
from porkchop.plugin import PorkchopPlugin | ||
|
||
class ElasticSearchPlugin(PorkchopPlugin): | ||
def get_data(self): | ||
stats_url = self.config.get('elasticsearch', {}).get('stats_url', | ||
'http://localhost:9200/_cluster/nodes/_local/stats') | ||
|
||
raw_stats = json.loads(requests.get(stats_url).content) | ||
|
||
# raw_stats['nodes'][<HASH>] | ||
# The <HASH> is generated at server start and since it is the only key | ||
# just list keys and grab the first one | ||
stats = { raw_stats['cluster_name']: raw_stats['nodes'][raw_stats['nodes'].keys()[0]] } | ||
|
||
return stats |
b91ebdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should just do return {raw_stats ...} here