Skip to content

Commit dadecec

Browse files
Add configuration parameters to Server and Agent
- Agent: - adding StatusPort parameter to config file - adding PersistentBufferPeriod parameter to config file - adding ControlSocket parameter to config file
1 parent 0c2853d commit dadecec

File tree

5 files changed

+117
-8
lines changed

5 files changed

+117
-8
lines changed

REFERENCE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ The following parameters are available in the `zabbix::agent` class:
14001400
* [`server`](#-zabbix--agent--server)
14011401
* [`listenport`](#-zabbix--agent--listenport)
14021402
* [`listenip`](#-zabbix--agent--listenip)
1403+
* [`statusport`](#-zabbix--agent--statusport)
14031404
* [`startagents`](#-zabbix--agent--startagents)
14041405
* [`serveractive`](#-zabbix--agent--serveractive)
14051406
* [`service_ensure`](#-zabbix--agent--service_ensure)
@@ -1413,6 +1414,9 @@ The following parameters are available in the `zabbix::agent` class:
14131414
* [`refreshactivechecks`](#-zabbix--agent--refreshactivechecks)
14141415
* [`buffersend`](#-zabbix--agent--buffersend)
14151416
* [`buffersize`](#-zabbix--agent--buffersize)
1417+
* [`enablepersistentbuffer`](#-zabbix--agent--enablepersistentbuffer)
1418+
* [`persistentbufferperiod`](#-zabbix--agent--persistentbufferperiod)
1419+
* [`persistentbufferfile`](#-zabbix--agent--persistentbufferfile)
14161420
* [`maxlinespersecond`](#-zabbix--agent--maxlinespersecond)
14171421
* [`allowroot`](#-zabbix--agent--allowroot)
14181422
* [`zabbix_user`](#-zabbix--agent--zabbix_user)
@@ -1447,6 +1451,7 @@ The following parameters are available in the `zabbix::agent` class:
14471451
* [`include_dir_purge`](#-zabbix--agent--include_dir_purge)
14481452
* [`unsafeuserparameters`](#-zabbix--agent--unsafeuserparameters)
14491453
* [`userparameter`](#-zabbix--agent--userparameter)
1454+
* [`controlsocket`](#-zabbix--agent--controlsocket)
14501455
* [`loadmodulepath`](#-zabbix--agent--loadmodulepath)
14511456
* [`loadmodule`](#-zabbix--agent--loadmodule)
14521457
* [`manage_startup_script`](#-zabbix--agent--manage_startup_script)
@@ -1721,6 +1726,14 @@ if more than 1 interface is on the server.
17211726

17221727
Default value: `$zabbix::params::agent_listenip`
17231728

1729+
##### <a name="-zabbix--agent--statusport"></a>`statusport`
1730+
1731+
Data type: `Optional[Integer[1024,32767]]`
1732+
1733+
Agent will listen on this port for HTTP status requests.
1734+
1735+
Default value: `$zabbix::params::agent_statusport`
1736+
17241737
##### <a name="-zabbix--agent--startagents"></a>`startagents`
17251738

17261739
Data type: `Any`
@@ -1827,6 +1840,30 @@ Maximum number of values in a memory buffer.
18271840

18281841
Default value: `$zabbix::params::agent_buffersize`
18291842

1843+
##### <a name="-zabbix--agent--enablepersistentbuffer"></a>`enablepersistentbuffer`
1844+
1845+
Data type: `Optional[Integer[0,1]]`
1846+
1847+
Use persistent buffer (set to 1), or in-memory buffer is used (default).
1848+
1849+
Default value: `$zabbix::params::agent_enablepersistentbuffer`
1850+
1851+
##### <a name="-zabbix--agent--persistentbufferperiod"></a>`persistentbufferperiod`
1852+
1853+
Data type: `Optional[String[1]]`
1854+
1855+
Zabbix Agent2 will keep data for this time period in case of no connectivity with Zabbix server or proxy.
1856+
1857+
Default value: `$zabbix::params::agent_persistentbufferperiod`
1858+
1859+
##### <a name="-zabbix--agent--persistentbufferfile"></a>`persistentbufferfile`
1860+
1861+
Data type: `Optional[Stdlib::Absolutepath]`
1862+
1863+
Full filename. Zabbix Agent2 will keep SQLite database in this file.
1864+
1865+
Default value: `$zabbix::params::agent_persistentbufferfile`
1866+
18301867
##### <a name="-zabbix--agent--maxlinespersecond"></a>`maxlinespersecond`
18311868

18321869
Data type: `Any`
@@ -2105,6 +2142,14 @@ User-defined parameter to monitor.
21052142

21062143
Default value: `$zabbix::params::agent_userparameter`
21072144

2145+
##### <a name="-zabbix--agent--controlsocket"></a>`controlsocket`
2146+
2147+
Data type: `Optional[Stdlib::Absolutepath]`
2148+
2149+
The control socket, used to send runtime commands with '-R' option.
2150+
2151+
Default value: `$zabbix::params::agent_controlsocket`
2152+
21082153
##### <a name="-zabbix--agent--loadmodulepath"></a>`loadmodulepath`
21092154

21102155
Data type: `Optional[String[1]]`

manifests/agent.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
# It will find out which ip is configured for this ipaddress. Can be handy
5454
# if more than 1 interface is on the server.
5555
#
56+
# @param statusport Agent will listen on this port for HTTP status requests.
5657
# @param startagents Number of pre-forked instances of zabbix_agentd that process passive checks.
5758
# @param serveractive List of comma delimited ip:port (or hostname:port) pairs of zabbix servers for active checks.
5859
# @param service_ensure Start / stop the agent service. E.g. to preconfigure a hosts agent and turn on the service at a later time (when the server reaches production SLA)
@@ -70,6 +71,9 @@
7071
# @param refreshactivechecks How often list of active checks is refreshed, in seconds.
7172
# @param buffersend Do not keep data longer than n seconds in buffer.
7273
# @param buffersize Maximum number of values in a memory buffer.
74+
# @param enablepersistentbuffer Use persistent buffer (set to 1), or in-memory buffer is used (default).
75+
# @param persistentbufferperiod Zabbix Agent2 will keep data for this time period in case of no connectivity with Zabbix server or proxy.
76+
# @param persistentbufferfile Full filename. Zabbix Agent2 will keep SQLite database in this file.
7377
# @param maxlinespersecond Maximum number of new lines the agent will send per second to zabbix server or proxy processing.
7478
# @param allowroot Allow the agent to run as 'root'.
7579
# @param zabbix_user Drop privileges to a specific, existing user on the system. Only has effect if run as 'root' and AllowRoot is disabled.
@@ -116,6 +120,7 @@
116120
# @param include_dir_purge Include dir to purge.
117121
# @param unsafeuserparameters Allow all characters to be passed in arguments to user-defined parameters.
118122
# @param userparameter User-defined parameter to monitor.
123+
# @param controlsocket The control socket, used to send runtime commands with '-R' option.
119124
# @param loadmodulepath Full path to location of agent modules.
120125
# @param loadmodule Module to load at agent startup.
121126
# @param manage_startup_script
@@ -179,6 +184,7 @@
179184
$server = $zabbix::params::agent_server,
180185
$listenport = $zabbix::params::agent_listenport,
181186
$listenip = $zabbix::params::agent_listenip,
187+
Optional[Integer[1024,32767]] $statusport = $zabbix::params::agent_statusport,
182188
$startagents = $zabbix::params::agent_startagents,
183189
$serveractive = $zabbix::params::agent_serveractive,
184190
Stdlib::Ensure::Service $service_ensure = $zabbix::params::agent_service_ensure,
@@ -192,6 +198,9 @@
192198
$refreshactivechecks = $zabbix::params::agent_refreshactivechecks,
193199
$buffersend = $zabbix::params::agent_buffersend,
194200
$buffersize = $zabbix::params::agent_buffersize,
201+
Optional[Integer[0,1]] $enablepersistentbuffer = $zabbix::params::agent_enablepersistentbuffer,
202+
Optional[Stdlib::Absolutepath] $persistentbufferfile = $zabbix::params::agent_persistentbufferfile,
203+
Optional[String[1]] $persistentbufferperiod = $zabbix::params::agent_persistentbufferperiod,
195204
$maxlinespersecond = $zabbix::params::agent_maxlinespersecond,
196205
Optional[Array] $zabbix_alias = $zabbix::params::agent_zabbix_alias,
197206
$timeout = $zabbix::params::agent_timeout,
@@ -201,6 +210,7 @@
201210
$include_dir_purge = $zabbix::params::agent_include_purge,
202211
$unsafeuserparameters = $zabbix::params::agent_unsafeuserparameters,
203212
$userparameter = $zabbix::params::agent_userparameter,
213+
Optional[Stdlib::Absolutepath] $controlsocket = $zabbix::params::agent_controlsocket,
204214
Optional[String[1]] $loadmodulepath = $zabbix::params::agent_loadmodulepath,
205215
$loadmodule = $zabbix::params::agent_loadmodule,
206216
Optional[Variant[Array[Enum['unencrypted','psk','cert']],Enum['unencrypted','psk','cert']]] $tlsaccept = $zabbix::params::agent_tlsaccept,

manifests/params.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,11 @@
301301
$agent_allowroot = '0'
302302
$agent_buffersend = '5'
303303
$agent_buffersize = '100'
304+
$agent_controlsocket = undef
304305
$agent_debuglevel = '3'
305306
$agent_allowkey = undef
306307
$agent_denykey = undef
308+
$agent_enablepersistentbuffer = undef
307309
$agent_enableremotecommands = '0'
308310
$agent_hostmetadata = undef
309311
$agent_hostmetadataitem = undef
@@ -314,9 +316,12 @@
314316
$agent_include_purge = true
315317
$agent_listenip = undef
316318
$agent_listenport = '10050'
319+
$agent_statusport = undef
317320
$agent_loadmodule = undef
318321
$agent_logremotecommands = '0'
319322
$agent_maxlinespersecond = '100'
323+
$agent_persistentbufferfile = undef
324+
$agent_persistentbufferperiod = undef
320325
$agent_refreshactivechecks = '120'
321326
$agent_server = '127.0.0.1'
322327
$agent_serveractive = undef

spec/classes/agent_spec.rb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
agent_configfile_path: '/etc/zabbix/zabbix_agentd.conf',
293293
buffersend: '5',
294294
buffersize: '100',
295+
controlsocket: '/tmp/agent.sock',
295296
debuglevel: '4',
296297
allowkey: 'system.run[*]',
297298
denykey: 'system.run[*]',
@@ -334,6 +335,7 @@
334335
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^AllowRoot=0$} }
335336
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSend=5$} }
336337
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSize=100$} }
338+
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ControlSocket=/tmp/agent.sock$} }
337339
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^DebugLevel=4$} }
338340
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^AllowKey=system.run\[\*\]$} }
339341
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^DenyKey=system.run\[\*\]$} }
@@ -495,21 +497,30 @@
495497

496498
let :params do
497499
{
498-
zabbix_package_agent: 'zabbix-agent2', startagents: 1,
499-
maxlinespersecond: 1, allowroot: 1, zabbix_user: 'root',
500-
loadmodulepath: '/tmp', allowkey: 'system.run[*]',
501-
denykey: 'system.run[*]', enableremotecommands: 1,
502-
logremotecommands: 1
500+
allowkey: 'system.run[*]',
501+
allowroot: 1,
502+
denykey: 'system.run[*]',
503+
enablepersistentbuffer: 1,
504+
enableremotecommands: 1,
505+
loadmodulepath: '/tmp',
506+
logremotecommands: 1,
507+
maxlinespersecond: 1,
508+
persistentbufferfile: '/var/lib/zabbix/zabbix_agent2.zbxtmp',
509+
persistentbufferperiod: '1h',
510+
startagents: 1,
511+
zabbix_package_agent: 'zabbix-agent2',
512+
zabbix_user: 'root',
503513
}
504514
end
505515

506516
it { is_expected.to contain_package('zabbix-agent2') }
507517

508518
it do
509519
is_expected.not_to contain_file(config_path).with_content(
510-
%r{^(LogRemoteCommands|StartAgents|MaxLinesPerSecond
511-
|AllowRoot|User|LoadModulePath|
512-
EnableRemoteCommands|LogRemoteCommands)}
520+
%r{^(AllowRoot|EnablePersistentBuffer|EnableRemoteCommands
521+
|LoadModulePath|LogRemoteCommands|MaxLinesPerSecond
522+
|PersistentBufferFile|PersistentBufferPeriod
523+
|StartAgents|User)}
513524
)
514525
end
515526
end

templates/zabbix_agentd.conf.erb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ ListenPort=<%= @listenport %>
126126
# Mandatory: no
127127
<% if @listen_ip %>ListenIP=<%= @listen_ip %><% end %>
128128

129+
### Option: StatusPort
130+
# Agent will listen on this port for HTTP status requests.
131+
#
132+
# Mandatory: no
133+
# Range: 1024-32767
134+
<% if @statusport %>StatusPort=<%= @statusport %><% end %>
135+
129136
<% unless @agent2 %>
130137
### Option: StartAgents
131138
# Number of pre-forked instances of zabbix_agentd that process passive checks.
@@ -241,6 +248,31 @@ BufferSend=<%= @buffersend %>
241248
# Range: 2-65535
242249
BufferSize=<%= @buffersize %>
243250

251+
### Option: EnablePersistentBuffer:
252+
# 0 - disabled, in-memory buffer is used (default);
253+
# 1 - use persistent buffer
254+
# Mandatory: no
255+
# Range: 0-1
256+
<% if @enablepersistentbuffer %>EnablePersistentBuffer=<%= @enablepersistentbuffer %><% end %>
257+
258+
<% unless @enablepersistentbuffer %>
259+
### Option: PersistentBufferPeriod
260+
# Zabbix Agent2 will keep data for this time period in case of no
261+
# connectivity with Zabbix server or proxy. Older data will be lost. Log data will be preserved.
262+
# Option is valid if EnablePersistentBuffer=1
263+
#
264+
# Mandatory: no
265+
# Range: 1m-365d
266+
<% if @persistentbufferperiod %>PersistentBufferPeriod=<%= @persistentbufferperiod %><% end %>
267+
268+
### Option: PersistentBufferFile
269+
# full filename. Zabbix Agent2 will keep SQLite database in this file
270+
# Option is valid if EnablePersistentBuffer=1
271+
#
272+
# Mandatory: no
273+
<% if @persistentbufferfile %>PersistentBufferFile=<%= @persistentbufferfile %><% end %>
274+
275+
<% end %>
244276
<% unless @agent2 %>
245277
### Option: MaxLinesPerSecond
246278
# Maximum number of new lines the agent will send per second to Zabbix Server
@@ -326,6 +358,12 @@ UnsafeUserParameters=<%= @unsafeuserparameters %>
326358
#
327359
# Disabled. A configuration file should be placed on directory: <%= @include %>
328360

361+
### Option: ControlSocket
362+
# The control socket, used to send runtime commands with '-R' option.
363+
#
364+
# Mandatory: no
365+
<% if @controlsocket %>ControlSocket=<%= @controlsocket %><% end %>
366+
329367
####### LOADABLE MODULES #######
330368
<% if @kernel != 'windows' and !@agent2 %>
331369
### Option: LoadModulePath

0 commit comments

Comments
 (0)