Skip to content
Merged
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
27 changes: 19 additions & 8 deletions instana/fsm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys
import socket
import subprocess
import threading as t
Expand Down Expand Up @@ -129,13 +129,24 @@ def announce_sensor(self, e):
pid = os.getpid()
cmdline = []

if os.path.isfile("/proc/self/cmdline"):
with open("/proc/self/cmdline") as cmd:
cmdinfo = cmd.read()
cmdline = cmdinfo.split('\x00')
else:
cmdline = [sys.executable]
cmdline += sys.argv
try:
if os.path.isfile("/proc/self/cmdline"):
with open("/proc/self/cmdline") as cmd:
cmdinfo = cmd.read()
cmdline = cmdinfo.split('\x00')
else:
# Python doesn't provide a reliable method to determine what
# the OS process command line may be. Here we are forced to
# rely on ps rather than adding a dependency on something like
# psutil which requires dev packages, gcc etc...
proc = subprocess.Popen(["ps", "-p", str(pid), "-o", "command"],
stdout=subprocess.PIPE)
(out, err) = proc.communicate()
parts = out.split(b'\n')
cmdline = [parts[1].decode("utf-8")]
except Exception as err:
cmdline = sys.argv
log.debug(err)

d = Discovery(pid=pid,
name=cmdline[0],
Expand Down