Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliasing for all #96

Merged
merged 1 commit into from
Jun 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions checks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@ def getDdforwarderData(self):
def getCPUStats(self):
return self._cpu.check(self.checksLogger, self.agentConfig)

@recordsize
def get_metadata(self):
metadata = self._ec2.get_metadata()

if self.agentConfig.get('hostname'):
metadata['agent-hostname'] = self.agentConfig.get('hostname')

# Get fqdn, make sure that hostname only contains local part
try:
hname = metadata.get("hostname", None)
if hname is None:
hname = socket.gethostname()
metadata["fqdn"] = socket.getfqdn()
else:
metadata["fqdn"] = metadata["hostname"]

# Replace hostname with shortname
metadata["hostname"] = hname.split(".")[0]
except:
pass
return metadata

def doChecks(self, firstRun=False, systemStats=False):
"""Actual work
"""
Expand Down Expand Up @@ -365,10 +387,8 @@ def doChecks(self, firstRun=False, systemStats=False):
}]

# Collect metadata
checksData['meta'] = self._ec2.get_metadata()
if self.agentConfig.get('hostname'):
checksData['meta']['agent-hostname'] = self.agentConfig.get('hostname')

checksData['meta'] = self.get_metadata()

# Resources checks
has_resource = False
for resources_check in self._resources_checks:
Expand Down
14 changes: 0 additions & 14 deletions checks/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ def get_metadata():
except:
pass

# Get fqdn, make sure that hostname only contains local part
try:
hname = metadata.get("hostname", None)
if hname is None:
hname = socket.gethostname()
metadata["fqdn"] = socket.getfqdn()
else:
metadata["fqdn"] = metadata["hostname"]

# Replace hostname with shortname
metadata["hostname"] = hname.split(".")[0]
except:
pass

try:
if socket_to is None:
socket_to = 3
Expand Down