44import socket
55import threading as t
66import fysom as f
7- import instana . log as l
7+ from instana import log
88import instana .agent_const as a
99
1010
@@ -36,8 +36,8 @@ class Fsm(object):
3636 timer = None
3737
3838 def __init__ (self , agent ):
39- l .info ("Stan is on the scene. Starting Instana instrumentation." )
40- l .debug ("initializing fsm" )
39+ log .info ("Stan is on the scene. Starting Instana instrumentation." )
40+ log .debug ("initializing fsm" )
4141
4242 self .agent = agent
4343 self .fsm = f .Fysom ({
@@ -53,8 +53,8 @@ def __init__(self, agent):
5353 "onchangestate" : self .printstatechange }})
5454
5555 def printstatechange (self , e ):
56- l .debug ('========= (%i#%s) FSM event: %s, src: %s, dst: %s ==========' % \
57- (os .getpid (), t .current_thread ().name , e .event , e .src , e .dst ))
56+ log .debug ('========= (%i#%s) FSM event: %s, src: %s, dst: %s ==========' %
57+ (os .getpid (), t .current_thread ().name , e .event , e .src , e .dst ))
5858
5959 def reset (self ):
6060 self .fsm .lookup ()
@@ -79,34 +79,35 @@ def lookup_agent_host(self, e):
7979 self .fsm .announce ()
8080 return True
8181
82- l .warn ("Instana Host Agent can't be found. Scheduling retry." )
82+ log .warn ("Instana Host Agent can't be found. Scheduling retry." )
8383 self .schedule_retry (self .lookup_agent_host , e , "agent_lookup" )
8484 return False
8585
8686 def get_default_gateway (self ):
87- l .debug ("checking default gateway" )
87+ log .debug ("checking default gateway" )
8888
8989 try :
9090 proc = subprocess .Popen (
91- "/sbin/ip route | awk '/default/' | cut -d ' ' -f 3 | tr -d '\n '" , shell = True , stdout = subprocess .PIPE )
91+ "/sbin/ip route | awk '/default/' | cut -d ' ' -f 3 | tr -d '\n '" ,
92+ shell = True , stdout = subprocess .PIPE )
9293
9394 addr = proc .stdout .read ()
9495 return addr .decode ("UTF-8" )
9596 except Exception as e :
96- l .error (e )
97+ log .error (e )
9798
9899 return None
99100
100101 def check_host (self , host ):
101- l .debug ("checking host" , host )
102+ log .debug ("checking host" , host )
102103
103104 (_ , h ) = self .agent .request_header (
104105 self .agent .make_host_url (host , "/" ), "GET" , "Server" )
105106
106107 return h
107108
108109 def announce_sensor (self , e ):
109- l .debug ("announcing sensor to the agent" )
110+ log .debug ("announcing sensor to the agent" )
110111 s = None
111112 pid = os .getpid ()
112113
@@ -135,23 +136,24 @@ def announce_sensor(self, e):
135136 if b :
136137 self .agent .set_from (b )
137138 self .fsm .ready ()
138- l .warn ("Host agent available. We're in business. Announced pid: %i (true pid: %i)" % (pid , self .agent .from_ .pid ))
139+ log .warn ("Host agent available. We're in business. Announced pid: %i (true pid: %i)" %
140+ (pid , self .agent .from_ .pid ))
139141 return True
140142 else :
141- l .warn ("Cannot announce sensor. Scheduling retry." )
143+ log .warn ("Cannot announce sensor. Scheduling retry." )
142144 self .schedule_retry (self .announce_sensor , e , "announce" )
143145 return False
144146
145147 def schedule_retry (self , fun , e , name ):
146- l .debug ("Scheduling: " + name )
148+ log .debug ("Scheduling: " + name )
147149 self .timer = t .Timer (self .RETRY_PERIOD , fun , [e ])
148150 self .timer .daemon = True
149151 self .timer .name = name
150152 self .timer .start ()
151- l .debug ('Threadlist: ' , str (t .enumerate ()))
153+ log .debug ('Threadlist: ' , str (t .enumerate ()))
152154
153155 def test_agent (self , e ):
154- l .debug ("testing communication with the agent" )
156+ log .debug ("testing communication with the agent" )
155157
156158 (b , _ ) = self .agent .head (self .agent .make_url (a .AGENT_DATA_URL ))
157159
0 commit comments