Skip to content

Commit

Permalink
Merge pull request #55 from signalfx/alternate-etc
Browse files Browse the repository at this point in the history
Add alternate etc path configuration
  • Loading branch information
charless-splunk authored Jun 19, 2017
2 parents 2dbac5d + bb8fc14 commit 9de886a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
0.0.30 / 2017-03-25
0.0.31 / 2017-06-19
===================

* Configure alternate proc path
* Configure alternate etc path
* Fix logging of "Next Metadata Send" message

0.0.30 / 2017-03-25

* Fix memory leak related to cpu utilization metrics collection
* Upgrade to latest signalfx-python v1.0.16

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ For metadata:
each processor? Default is false
* Datapoints: would you like the plugin to send in metrics about max round
trip time, plugin uptime and notification sending errors? Default is true.
* ProcPath: specify an alternate `proc` path to parse for process information.
Default is `/proc`.
* EtcPath: specify an alternate `etc` path to parse for os release information.
Default is `/etc`.

For DogstatsD support:

Expand Down
22 changes: 15 additions & 7 deletions src/signalfx_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
TIMEOUT = 3
POST_URLS = []
DEFAULT_POST_URL = "https://ingest.signalfx.com/v1/collectd"
VERSION = "0.0.30"
VERSION = "0.0.31"
MAX_LENGTH = 0
COLLECTD_VERSION = ""
LINUX_VERSION = ""
Expand Down Expand Up @@ -96,6 +96,7 @@
DOGSTATSD_INSTANCE = collectd_dogstatsd.DogstatsDCollectD(collectd)
PERCORECPUUTIL = False
OVERALLCPUUTIL = True
ETC_PATH = "{0}etc".format(os.sep)


class mdict(dict):
Expand Down Expand Up @@ -846,6 +847,10 @@ def plugin_config(conf):
elif kv.key == 'ProcPath':
psutil.PROCFS_PATH = kv.values[0]
debug("Setting proc path to %s for psutil" % psutil.PROCFS_PATH)
elif kv.key == 'EtcPath':
ETC_PATH = kv.values[0].rstrip(os.pathsep).rstrip(os.sep)
debug("Setting etc path to %s for os release detection"
% ETC_PATH)

if not POST_URLS:
POST_URLS = [DEFAULT_POST_URL]
Expand Down Expand Up @@ -1152,26 +1157,29 @@ def get_collectd_version():


def getLsbRelease():
if os.path.isfile("/etc/lsb-release"):
with open("/etc/lsb-release") as f:
path = os.path.join(ETC_PATH, "lsb-release")
if os.path.isfile(path):
with open(path) as f:
for line in f.readlines():
regexed = re.search('DISTRIB_DESCRIPTION="(.*)"', line)
if regexed:
return regexed.groups()[0]


def getOsRelease():
if os.path.isfile("/etc/os-release"):
with open("/etc/os-release") as f:
path = os.path.join(ETC_PATH, "os-release")
if os.path.isfile(path):
with open(path) as f:
for line in f.readlines():
regexed = re.search('PRETTY_NAME="(.*)"', line)
if regexed:
return regexed.groups()[0]


def getCentos():
for file in ["/etc/centos-release", "/etc/redhat-release",
"/etc/system-release"]:
for file in [os.path.join(ETC_PATH, "centos-release"),
os.path.join(ETC_PATH, "redhat-release"),
os.path.join(ETC_PATH, "system-release")]:
if os.path.isfile(file):
with open(file) as f:
line = f.read()
Expand Down

0 comments on commit 9de886a

Please sign in to comment.