Merge ~sajoupa/charm-telegraf:internal-stats into charm-telegraf:master

Proposed by Laurent Sesquès
Status: Merged
Approved by: Paul Goins
Approved revision: d14961237b4be0f76013518a427de5c593c9dad8
Merged at revision: 4ef6c03cd01c7024547b7ae1d6ce1288d31733f1
Proposed branch: ~sajoupa/charm-telegraf:internal-stats
Merge into: charm-telegraf:master
Diff against target: 41 lines (+19/-0)
2 files modified
src/templates/base_inputs.conf (+5/-0)
src/tests/unit/test_telegraf.py (+14/-0)
Reviewer Review Type Date Requested Status
Paul Goins Approve
Benjamin Allot Approve
Junien F Approve
Review via email: mp+391131@code.launchpad.net

Commit message

add the internal input plugin to base inputs, with memstats collection. Fixes lp:1895661.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Laurent Sesquès (sajoupa) wrote :

passed `make test`.

Revision history for this message
Laurent Sesquès (sajoupa) wrote :

This last commit makes memstats collection non-optional.
`make test` still passes successfully.

Revision history for this message
Junien F (axino) wrote :

+1

review: Approve
Revision history for this message
Benjamin Allot (ballot) wrote :

LGTM, you can add "-" when doing jinja (see comments), but that's not a blocker

review: Approve
Revision history for this message
Paul Goins (vultaire) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 4ef6c03cd01c7024547b7ae1d6ce1288d31733f1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/templates/base_inputs.conf b/src/templates/base_inputs.conf
index 889690a..636b10e 100644
--- a/src/templates/base_inputs.conf
+++ b/src/templates/base_inputs.conf
@@ -127,6 +127,11 @@ files = ["ip_conntrack_count","ip_conntrack_max", "nf_conntrack_count","nf_connt
127 # no configuration127 # no configuration
128{% endif %}128{% endif %}
129129
130{% if "internal" not in disabled_plugins %}
131[[inputs.internal]]
132 collect_memstats = true
133{% endif %}
134
130[[inputs.exec]]135[[inputs.exec]]
131commands = [136commands = [
132 "/usr/bin/awk '{ print $1 }' /proc/sys/fs/file-nr"137 "/usr/bin/awk '{ print $1 }' /proc/sys/fs/file-nr"
diff --git a/src/tests/unit/test_telegraf.py b/src/tests/unit/test_telegraf.py
index 8ef82ec..ffab0e8 100644
--- a/src/tests/unit/test_telegraf.py
+++ b/src/tests/unit/test_telegraf.py
@@ -1234,6 +1234,20 @@ def test_socket_listener_config(monkeypatch, config):
1234 assert expected in config_file.read()1234 assert expected in config_file.read()
12351235
12361236
1237def test_inputs_internal_memstats(monkeypatch, config):
1238 open_ports = set()
1239 monkeypatch.setattr(telegraf.hookenv, "open_port", lambda p: open_ports.add(p))
1240 monkeypatch.setattr(telegraf.hookenv, "close_port", lambda p: open_ports.remove(p))
1241 config["disabled_plugins"] = "" # ensure no metrics are initially disabled
1242 telegraf.configure_telegraf()
1243 config_file = base_dir().join("telegraf.conf")
1244 expected = """
1245[[inputs.internal]]
1246 collect_memstats = true
1247"""
1248 assert expected in config_file.read()
1249
1250
1237class TestGetHostnameLabel(unittest.TestCase):1251class TestGetHostnameLabel(unittest.TestCase):
1238 @patch("reactive.telegraf.get_remote_unit_name")1252 @patch("reactive.telegraf.get_remote_unit_name")
1239 @patch("charmhelpers.core.hookenv.config")1253 @patch("charmhelpers.core.hookenv.config")

Subscribers

People subscribed via source and target branches

to all changes: