|
1 | | -import subprocess |
2 | | -import os |
3 | 1 | import sys |
| 2 | +import os |
4 | 3 | import socket |
| 4 | +import subprocess |
5 | 5 | import threading as t |
6 | 6 | import fysom as f |
7 | 7 | from instana import log |
@@ -41,24 +41,31 @@ def __init__(self, agent): |
41 | 41 |
|
42 | 42 | self.agent = agent |
43 | 43 | self.fsm = f.Fysom({ |
44 | | - "initial": "lostandalone", |
45 | 44 | "events": [ |
46 | | - ("startup", "*", "lostandalone"), |
47 | | - ("lookup", "lostandalone", "found"), |
| 45 | + ("lookup", "*", "found"), |
48 | 46 | ("announce", "found", "announced"), |
49 | 47 | ("ready", "announced", "good2go")], |
50 | 48 | "callbacks": { |
51 | 49 | "onlookup": self.lookup_agent_host, |
52 | 50 | "onannounce": self.announce_sensor, |
| 51 | + "onready": self.start_metric_reporting, |
53 | 52 | "onchangestate": self.printstatechange}}) |
54 | 53 |
|
| 54 | + timer = t.Timer(2, self.fsm.lookup) |
| 55 | + timer.daemon = True |
| 56 | + timer.name = "Startup" |
| 57 | + timer.start() |
| 58 | + |
55 | 59 | def printstatechange(self, e): |
56 | 60 | log.debug('========= (%i#%s) FSM event: %s, src: %s, dst: %s ==========' % |
57 | 61 | (os.getpid(), t.current_thread().name, e.event, e.src, e.dst)) |
58 | 62 |
|
59 | 63 | def reset(self): |
60 | 64 | self.fsm.lookup() |
61 | 65 |
|
| 66 | + def start_metric_reporting(self, e): |
| 67 | + self.agent.sensor.meter.run() |
| 68 | + |
62 | 69 | def lookup_agent_host(self, e): |
63 | 70 | if self.agent.sensor.options.agent_host != "": |
64 | 71 | host = self.agent.sensor.options.agent_host |
@@ -110,6 +117,7 @@ def announce_sensor(self, e): |
110 | 117 | log.debug("announcing sensor to the agent") |
111 | 118 | s = None |
112 | 119 | pid = os.getpid() |
| 120 | + cmdline = [] |
113 | 121 |
|
114 | 122 | if os.path.isfile("/proc/self/cmdline"): |
115 | 123 | with open("/proc/self/cmdline") as cmd: |
|
0 commit comments