Skip to content

Commit 5e28b2d

Browse files
authored
Merge pull request #44 from signalfx/aws_metadata_check
Periodically check if plugin is running on AWS
2 parents 576bb91 + 7484834 commit 5e28b2d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
0.0.26 / 2016-09-08
1+
0.0.27 / 2016-09-21
22
===================
33

4+
* Periodically check if the plugin is running on AWS
5+
6+
0.0.26 / 2016-09-08
7+
48
* Add optional configuration to report cpu utilization on a per core basis
59

610
0.0.25 / 2016-08-03

src/signalfx_metadata.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
TIMEOUT = 3
6565
POST_URLS = []
6666
DEFAULT_POST_URL = "https://ingest.signalfx.com/v1/collectd"
67-
VERSION = "0.0.26"
67+
VERSION = "0.0.27"
6868
MAX_LENGTH = 0
6969
COLLECTD_VERSION = ""
7070
LINUX_VERSION = ""
@@ -77,7 +77,7 @@
7777
3600 + random.randint(0, 60),
7878
86400 + random.randint(0, 600)]
7979
LAST = 0
80-
AWS = True
80+
AWS = False
8181
AWS_SET = False
8282
PROCESS_INFO = True
8383
DATAPOINTS = True
@@ -842,7 +842,7 @@ def plugin_config(conf):
842842
log("Cpu utilization per core has been enabled via configuration")
843843

844844
collectd.register_read(send, INTERVAL)
845-
set_aws_url(get_aws_info())
845+
get_aws_info()
846846

847847

848848
def compact(thing):
@@ -1032,16 +1032,13 @@ def get_kernel_info(host_info={}):
10321032
def get_aws_info(host_info={}):
10331033
"""
10341034
call into aws to get some information about the instance, timeout really
1035-
small for non aws systems and only try the once per startup
1035+
small for non aws systems.
10361036
"""
10371037
global AWS
1038-
if not AWS:
1039-
return host_info
1040-
10411038
url = "http://169.254.169.254/latest/dynamic/instance-identity/document"
10421039
try:
10431040
req = urllib2.Request(url)
1044-
response = urllib2.urlopen(req, timeout=0.1)
1041+
response = urllib2.urlopen(req, timeout=0.2)
10451042
identity = json.loads(response.read())
10461043
want = {
10471044
'availability_zone': 'availabilityZone',
@@ -1054,6 +1051,9 @@ def get_aws_info(host_info={}):
10541051
}
10551052
for k, v in iter(want.items()):
10561053
host_info["aws_" + k] = identity[v]
1054+
AWS = True
1055+
set_aws_url(host_info)
1056+
log("is an aws box")
10571057
except:
10581058
log("not an aws box")
10591059
AWS = False

0 commit comments

Comments
 (0)