Skip to content

Commit

Permalink
Periodically check if plugin is running on AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
charless-splunk committed Sep 22, 2016
1 parent 576bb91 commit 7484834
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
0.0.26 / 2016-09-08
0.0.27 / 2016-09-21
===================

* Periodically check if the plugin is running on AWS

0.0.26 / 2016-09-08

* Add optional configuration to report cpu utilization on a per core basis

0.0.25 / 2016-08-03
Expand Down
16 changes: 8 additions & 8 deletions src/signalfx_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
TIMEOUT = 3
POST_URLS = []
DEFAULT_POST_URL = "https://ingest.signalfx.com/v1/collectd"
VERSION = "0.0.26"
VERSION = "0.0.27"
MAX_LENGTH = 0
COLLECTD_VERSION = ""
LINUX_VERSION = ""
Expand All @@ -77,7 +77,7 @@
3600 + random.randint(0, 60),
86400 + random.randint(0, 600)]
LAST = 0
AWS = True
AWS = False
AWS_SET = False
PROCESS_INFO = True
DATAPOINTS = True
Expand Down Expand Up @@ -842,7 +842,7 @@ def plugin_config(conf):
log("Cpu utilization per core has been enabled via configuration")

collectd.register_read(send, INTERVAL)
set_aws_url(get_aws_info())
get_aws_info()


def compact(thing):
Expand Down Expand Up @@ -1032,16 +1032,13 @@ def get_kernel_info(host_info={}):
def get_aws_info(host_info={}):
"""
call into aws to get some information about the instance, timeout really
small for non aws systems and only try the once per startup
small for non aws systems.
"""
global AWS
if not AWS:
return host_info

url = "http://169.254.169.254/latest/dynamic/instance-identity/document"
try:
req = urllib2.Request(url)
response = urllib2.urlopen(req, timeout=0.1)
response = urllib2.urlopen(req, timeout=0.2)
identity = json.loads(response.read())
want = {
'availability_zone': 'availabilityZone',
Expand All @@ -1054,6 +1051,9 @@ def get_aws_info(host_info={}):
}
for k, v in iter(want.items()):
host_info["aws_" + k] = identity[v]
AWS = True
set_aws_url(host_info)
log("is an aws box")
except:
log("not an aws box")
AWS = False
Expand Down

0 comments on commit 7484834

Please sign in to comment.