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
1diff --git a/src/templates/base_inputs.conf b/src/templates/base_inputs.conf
2index 889690a..636b10e 100644
3--- a/src/templates/base_inputs.conf
4+++ b/src/templates/base_inputs.conf
5@@ -127,6 +127,11 @@ files = ["ip_conntrack_count","ip_conntrack_max", "nf_conntrack_count","nf_connt
6 # no configuration
7 {% endif %}
8
9+{% if "internal" not in disabled_plugins %}
10+[[inputs.internal]]
11+ collect_memstats = true
12+{% endif %}
13+
14 [[inputs.exec]]
15 commands = [
16 "/usr/bin/awk '{ print $1 }' /proc/sys/fs/file-nr"
17diff --git a/src/tests/unit/test_telegraf.py b/src/tests/unit/test_telegraf.py
18index 8ef82ec..ffab0e8 100644
19--- a/src/tests/unit/test_telegraf.py
20+++ b/src/tests/unit/test_telegraf.py
21@@ -1234,6 +1234,20 @@ def test_socket_listener_config(monkeypatch, config):
22 assert expected in config_file.read()
23
24
25+def test_inputs_internal_memstats(monkeypatch, config):
26+ open_ports = set()
27+ monkeypatch.setattr(telegraf.hookenv, "open_port", lambda p: open_ports.add(p))
28+ monkeypatch.setattr(telegraf.hookenv, "close_port", lambda p: open_ports.remove(p))
29+ config["disabled_plugins"] = "" # ensure no metrics are initially disabled
30+ telegraf.configure_telegraf()
31+ config_file = base_dir().join("telegraf.conf")
32+ expected = """
33+[[inputs.internal]]
34+ collect_memstats = true
35+"""
36+ assert expected in config_file.read()
37+
38+
39 class TestGetHostnameLabel(unittest.TestCase):
40 @patch("reactive.telegraf.get_remote_unit_name")
41 @patch("charmhelpers.core.hookenv.config")

Subscribers

People subscribed via source and target branches

to all changes: