added update_hostname
* gets the hostname from the the munin connection hello string * does not override displayname if provided
This commit is contained in:
parent
25eab12604
commit
12e2057505
@ -12,6 +12,7 @@ import time
|
||||
|
||||
LOGGING_FORMAT = "%(asctime)s:%(levelname)s:%(message)s"
|
||||
RE_LEFTRIGHT = re.compile(r"^(?P<left>\S+)\s+(?P<right>\S+)$")
|
||||
RE_MUNIN_NODE_NAME = re.compile(r"^# munin node at\s+(?P<nodename>\S+)$")
|
||||
|
||||
## TODO: Catch keyboard interrupt properly and die when requested
|
||||
|
||||
@ -33,6 +34,7 @@ class Munin():
|
||||
def go(self):
|
||||
"""Bootstrap method to start processing hosts's Munin stats."""
|
||||
self.connect()
|
||||
self.update_hostname()
|
||||
self.process_host_stats()
|
||||
|
||||
while True and self.args.interval != 0:
|
||||
@ -40,6 +42,18 @@ class Munin():
|
||||
self.connect()
|
||||
self.process_host_stats()
|
||||
|
||||
def update_hostname(self):
|
||||
"""Updating hostname from connection hello string."""
|
||||
if self.args.displayname:
|
||||
return
|
||||
try:
|
||||
node_name = RE_MUNIN_NODE_NAME.search(self.hello_string).group(1)
|
||||
self.displayname = node_name
|
||||
except AttributeError:
|
||||
logging.info("Unable to obtain munin node name from: %s",
|
||||
self.hello_string)
|
||||
return
|
||||
|
||||
def connect(self):
|
||||
"""Initial connection to Munin host."""
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user