1- import subprocess
2- import os
31import sys
2+ import os
43import socket
4+ import subprocess
55import threading as t
66import fysom as f
77from instana import log
@@ -41,7 +41,7 @@ def __init__(self, agent):
4141
4242 self .agent = agent
4343 self .fsm = f .Fysom ({
44- "initial" : "lostandalone" ,
44+ "initial" : { 'state' : "lostandalone" , 'event' : 'init' , 'defer' : True } ,
4545 "events" : [
4646 ("startup" , "*" , "lostandalone" ),
4747 ("lookup" , "lostandalone" , "found" ),
@@ -52,10 +52,19 @@ def __init__(self, agent):
5252 "onannounce" : self .announce_sensor ,
5353 "onchangestate" : self .printstatechange }})
5454
55+ timer = t .Timer (2 , self .boot )
56+ timer .daemon = True
57+ timer .name = "Startup"
58+ timer .start ()
59+
5560 def printstatechange (self , e ):
5661 log .debug ('========= (%i#%s) FSM event: %s, src: %s, dst: %s ==========' %
5762 (os .getpid (), t .current_thread ().name , e .event , e .src , e .dst ))
5863
64+ def boot (self ):
65+ self .fsm .init ()
66+ self .fsm .lookup ()
67+
5968 def reset (self ):
6069 self .fsm .lookup ()
6170
@@ -110,6 +119,7 @@ def announce_sensor(self, e):
110119 log .debug ("announcing sensor to the agent" )
111120 s = None
112121 pid = os .getpid ()
122+ cmdline = []
113123
114124 if os .path .isfile ("/proc/self/cmdline" ):
115125 with open ("/proc/self/cmdline" ) as cmd :
0 commit comments