Skip to content

Commit

Permalink
Add support for aggregation and Graphite Separate Instances to Collec…
Browse files Browse the repository at this point in the history
…td plugin, add 2 plugins to collectd (opnsense#1927)

* Fix indentation

* Make Graphite separate instances configurable

* Add configuration to send CPU aggregate values

* Remove superfluous blank lines

* Fix inconsistent capitalisation

* Add blank line between plugin sections

* Add option to send CPU metrics as percent values

* Fix inconsistent indentation

* Fix inconsistent indentation

* Add CPU temperature plugin

* Add disk I/O plugin, remove CPU temperature plugin - it's not available

* Add swap plugin

* Fix misplaced `endif` in jinja template
  • Loading branch information
pmhausen authored Jul 20, 2020
1 parent ca59a61 commit 8b87192
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@
</field>
<field>
<id>general.p_graphite_prefix</id>
<label>Graphite Prefix</label>
<label>Graphite prefix</label>
<type>text</type>
<help>Prefix to set before the hostname. If it ends with a dot it creates an own directory.</help>
</field>
<field>
<id>general.p_graphite_postfix</id>
<label>Graphite Postfix</label>
<label>Graphite postfix</label>
<type>text</type>
<help>String to set after the hostname. For compatibility reason default is collectd, but you can also simply remove it.</help>
</field>
<field>
<id>general.p_graphite_separate_instances</id>
<label>Graphite separate instances</label>
<type>checkbox</type>
<help>Enabling sends the plugin instance and type instance to Graphite as separate path components: host.cpu.0.cpu.idle. Disabling sends the plugin and plugin instance as one path component and type and type instance as another component: host.cpu-0.cpu-idle.</help>
</field>
<field>
<id>general.p_contextswitch_enable</id>
<label>Enable contextswitch plugin</label>
Expand All @@ -107,6 +113,24 @@
<type>checkbox</type>
<help>The CPU plugin collects the amount of time spent by the CPU in various states, most notably executing user code, executing system code, waiting for IO-operations and being idle.</help>
</field>
<field>
<id>general.p_cpu_percent</id>
<label>Report cpu usage in percent</label>
<type>checkbox</type>
<help>When set, report CPU usage in percent instead of units of kernel time.</help>
</field>
<field>
<id>general.p_cpu_aggregates</id>
<label>Enable cpu aggregates</label>
<type>checkbox</type>
<help>Send aggregate values for CPU metrics in addition to values for individual cores.</help>
</field>
<field>
<id>general.p_disk_enable</id>
<label>Enable disk plugin</label>
<type>checkbox</type>
<help>The Disk plugin collects disk I/O information, i.e. read and write operations per second.</help>
</field>
<field>
<id>general.p_df_enable</id>
<label>Enable df plugin</label>
Expand All @@ -129,7 +153,13 @@
<id>general.p_memory_enable</id>
<label>Enable memory plugin</label>
<type>checkbox</type>
<help>The Memory plugin collects physical memory utilization (Used, buffered, cached and free).</help>
<help>The Memory plugin collects physical memory utilization (used, buffered, cached and free).</help>
</field>
<field>
<id>general.p_swap_enable</id>
<label>Enable swap plugin</label>
<type>checkbox</type>
<help>The Swap plugin collects swap space utilization (used and free).</help>
</field>
<field>
<id>general.p_processes_enable</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
</p_network_port>
<p_network_username type="TextField">
<default></default>
<Required>N</Required>
<mask>/^([0-9a-zA-Z._\-]){1,128}$/u</mask>
</p_network_username>
<p_network_password type="TextField">
<default></default>
<Required>N</Required>
<mask>/^([0-9a-zA-Z._\-\!\$\%\/\(\)\+\#\=]){1,128}$/u</mask>
</p_network_password>
<p_network_encryption type="BooleanField">
<default>0</default>
<Required>N</Required>
</p_network_encryption>
<Required>N</Required>
<mask>/^([0-9a-zA-Z._\-]){1,128}$/u</mask>
</p_network_username>
<p_network_password type="TextField">
<default></default>
<Required>N</Required>
<mask>/^([0-9a-zA-Z._\-\!\$\%\/\(\)\+\#\=]){1,128}$/u</mask>
</p_network_password>
<p_network_encryption type="BooleanField">
<default>0</default>
<Required>N</Required>
</p_network_encryption>
<p_graphite_enable type="BooleanField">
<default>0</default>
<Required>N</Required>
Expand Down Expand Up @@ -77,6 +77,10 @@
<default>collectd</default>
<Required>N</Required>
</p_graphite_postfix>
<p_graphite_separate_instances type="BooleanField">
<default>0</default>
<Required>N</Required>
</p_graphite_separate_instances>
<p_contextswitch_enable type="BooleanField">
<default>1</default>
<Required>N</Required>
Expand All @@ -85,6 +89,18 @@
<default>1</default>
<Required>N</Required>
</p_cpu_enable>
<p_cpu_percent type="BooleanField">
<default>1</default>
<Required>N</Required>
</p_cpu_percent>
<p_cpu_aggregates type="BooleanField">
<default>1</default>
<Required>N</Required>
</p_cpu_aggregates>
<p_disk_enable type="BooleanField">
<default>1</default>
<Required>N</Required>
</p_disk_enable>
<p_df_enable type="BooleanField">
<default>1</default>
<Required>N</Required>
Expand All @@ -101,6 +117,10 @@
<default>1</default>
<Required>N</Required>
</p_memory_enable>
<p_swap_enable type="BooleanField">
<default>1</default>
<Required>N</Required>
</p_swap_enable>
<p_processes_enable type="BooleanField">
<default>1</default>
<Required>N</Required>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% if helpers.exists('OPNsense.collectd.general.enabled') and OPNsense.collectd.general.enabled == '1' %}

{% if helpers.exists('OPNsense.collectd.general.hostname') and OPNsense.collectd.general.hostname != '' %}
Hostname "{{ OPNsense.collectd.general.hostname }}"
{% else %}
Expand All @@ -12,12 +11,9 @@ FQDNLookup true
Interval {{ OPNsense.collectd.general.interval }}
{% endif %}




LoadPlugin syslog
<Plugin syslog>
LogLevel err
LogLevel err
</Plugin>

{% if helpers.exists('OPNsense.collectd.general.p_contextswitch_enable') and OPNsense.collectd.general.p_contextswitch_enable == '1' %}
Expand All @@ -26,6 +22,12 @@ LoadPlugin contextswitch
{% if helpers.exists('OPNsense.collectd.general.p_cpu_enable') and OPNsense.collectd.general.p_cpu_enable == '1' %}
LoadPlugin cpu
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_cpu_aggregates') and OPNsense.collectd.general.p_cpu_aggregates == '1' %}
LoadPlugin aggregation
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_disk_enable') and OPNsense.collectd.general.p_disk_enable == '1' %}
LoadPlugin disk
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_df_enable') and OPNsense.collectd.general.p_df_enable == '1' %}
LoadPlugin df
{% endif %}
Expand All @@ -38,6 +40,9 @@ LoadPlugin load
{% if helpers.exists('OPNsense.collectd.general.p_memory_enable') and OPNsense.collectd.general.p_memory_enable == '1' %}
LoadPlugin memory
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_swap_enable') and OPNsense.collectd.general.p_swap_enable == '1' %}
LoadPlugin swap
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_network_enable') and OPNsense.collectd.general.p_network_enable == '1' %}
LoadPlugin network
{% endif %}
Expand Down Expand Up @@ -65,19 +70,19 @@ LoadPlugin write_graphite
{% if helpers.exists('OPNsense.collectd.general.p_network_host') and OPNsense.collectd.general.p_network_host != '' %}
{% if helpers.exists('OPNsense.collectd.general.p_network_port') and OPNsense.collectd.general.p_network_port != '' %}
<Plugin network>
<Server "{{ OPNsense.collectd.general.p_network_host }}" "{{ OPNsense.collectd.general.p_network_port }}">
<Server "{{ OPNsense.collectd.general.p_network_host }}" "{{ OPNsense.collectd.general.p_network_port }}">
{% if helpers.exists('OPNsense.collectd.general.p_network_username') and OPNsense.collectd.general.p_network_username != '' %}
Username "{{ OPNsense.collectd.general.p_network_username }}"
Username "{{ OPNsense.collectd.general.p_network_username }}"
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_network_password') and OPNsense.collectd.general.p_network_password != '' %}
Password "{{ OPNsense.collectd.general.p_network_password }}"
Password "{{ OPNsense.collectd.general.p_network_password }}"
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_network_username') and OPNsense.collectd.general.p_network_username != '' %}
{% if helpers.exists('OPNsense.collectd.general.p_network_encryption') and OPNsense.collectd.general.p_network_encryption == '1' %}
SecurityLevel Encrypt
SecurityLevel Encrypt
{% endif %}
{% endif %}
</Server>
</Server>
</Plugin>
{% endif %}
{% endif %}
Expand All @@ -101,16 +106,44 @@ LoadPlugin write_graphite
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_graphite_postfix') and OPNsense.collectd.general.p_graphite_postfix != '' %}
Postfix "{{ OPNsense.collectd.general.p_graphite_postfix }}"
{% endif %}
{% if helpers.exists('OPNsense.collectd.general.p_graphite_separate_instances') and OPNsense.collectd.general.p_graphite_separate_instances == '1' %}
SeparateInstances true
{% else %}
SeparateInstances false
{% endif %}
StoreRates true
AlwaysAppendDS false
EscapeCharacter "_"
SeparateInstances false
PreserveSeparator false
DropDuplicateFields false
</Node>
</Plugin>
{% endif %}
{% endif %}

<Plugin cpu>
{% if helpers.exists('OPNsense.collectd.general.p_cpu_percent') and OPNsense.collectd.general.p_cpu_percent == '1' %}
ValuesPercentage true
{% else %}
ValuesPercentage false
{% endif %}
</Plugin>

{% if helpers.exists('OPNsense.collectd.general.p_cpu_aggregates') and OPNsense.collectd.general.p_cpu_aggregates == '1' %}
<Plugin "aggregation">
<Aggregation>
Plugin "cpu"
Type "percent"
GroupBy "Host"
GroupBy "TypeInstance"
CalculateNum false
CalculateSum true
CalculateAverage true
CalculateMinimum false
CalculateMaximum false
CalculateStddev false
</Aggregation>
</Plugin>
{% endif %}
{% endif %}

0 comments on commit 8b87192

Please sign in to comment.