Skip to content

Commit 1846061

Browse files
authored
Merge pull request #665 from bjschafer/aix-support
Support for zabbix::agent on AIX
2 parents 372ee21 + 7179c48 commit 1846061

File tree

5 files changed

+82
-4
lines changed

5 files changed

+82
-4
lines changed

manifests/agent.pp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,10 @@
405405
else {
406406
# Installing the package
407407
package { $zabbix_package_agent:
408-
ensure => $zabbix_package_state,
409-
require => Class['zabbix::repo'],
410-
tag => 'zabbix',
408+
ensure => $zabbix_package_state,
409+
require => Class['zabbix::repo'],
410+
tag => 'zabbix',
411+
provider => $zabbix_package_provider,
411412
}
412413
}
413414

@@ -434,12 +435,18 @@
434435
# Controlling the 'zabbix-agent' service
435436
if str2bool(getvar('::systemd')) {
436437
$service_provider = 'systemd'
438+
$service_path = undef
439+
} elsif $facts['os']['name'] == 'AIX' {
440+
$service_provider = 'init'
441+
$service_path = '/etc/rc.d/init.d'
437442
} else {
438443
$service_provider = undef
444+
$service_path = undef
439445
}
440446
service { $servicename:
441447
ensure => $service_ensure,
442448
enable => $service_enable,
449+
path => $service_path,
443450
provider => $service_provider,
444451
hasstatus => true,
445452
hasrestart => true,

manifests/params.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@
3232
$zabbix_package_provider = undef
3333
$agent_loadmodulepath = '/usr/lib/modules'
3434
}
35+
'AIX': {
36+
$manage_repo = false
37+
$zabbix_package_provider = 'yum'
38+
$zabbix_package_agent = 'zabbix-agent'
39+
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
40+
$agent_config_owner = 'zabbix'
41+
$agent_zabbix_user = 'zabbix'
42+
$agent_config_group = 'zabbix'
43+
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
44+
$agent_servicename = 'zabbix-agent'
45+
}
46+
3547
'Archlinux': {
3648
$server_fpinglocation = '/usr/bin/fping'
3749
$server_fping6location = '/usr/bin/fping6'

manifests/startup.pp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
mode => '0755',
5757
content => template("zabbix/${name}-${osfamily_downcase}.init.erb"),
5858
}
59+
} elsif $facts['os']['family'] in ['AIX'] {
60+
file { "/etc/rc.d/init.d/${service_name}":
61+
ensure => file,
62+
mode => '0755',
63+
content => epp('zabbix/zabbix-agent-aix.init.epp', { 'pidfile' => $pidfile, 'agent_configfile_path' => $agent_configfile_path, 'zabbix_user' => $zabbix_user }),
64+
}
65+
file { "/etc/rc.d/rc2.d/S999${service_name}":
66+
ensure => 'link',
67+
target => "/etc/rc.d/init.d/${service_name}",
68+
}
5969
} elsif ($facts['os']['family'] == 'windows') {
6070
exec { "install_agent_${name}":
6171
command => "& 'C:\\Program Files\\Zabbix Agent\\zabbix_agentd.exe' --config ${agent_configfile_path} --install",
@@ -64,6 +74,6 @@
6474
notify => Service[$name],
6575
}
6676
} else {
67-
fail('We currently only support Debian, Redhat and Windows osfamily as non-systemd')
77+
fail('We currently only support Debian, Redhat, AIX and Windows osfamily as non-systemd')
6878
}
6979
}

metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
"2012 R2",
157157
"2016"
158158
]
159+
},
160+
{
161+
"operatingsystem": "AIX"
159162
}
160163
]
161164
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<%- | String $pidfile,
2+
String $agent_configfile_path,
3+
String $zabbix_user
4+
| -%>
5+
#!/bin/ksh
6+
# THIS FILE IS MANAGED BY PUPPET
7+
8+
9+
##################################################
10+
# name: start zabbix agent
11+
# purpose: zabbix agent start script
12+
# author: V.Danhelka IBM 11.2.2016; B. Schafer 2020-02-26
13+
##################################################
14+
15+
PID=<%= $pidfile %>
16+
BIN=/usr/sbin/zabbix_agentd
17+
CONF=<%= $agent_configfile_path %>
18+
LOGFILE=/var/log/zabbix/zabbix_agentd.log
19+
ARGS="-c $CONF"
20+
USER=<%= $zabbix_user %>
21+
22+
test -d $(dirname $LOGFILE) || mkdir -p $(dirname $LOGFILE)
23+
chown -R $USER $LOGDIR
24+
25+
test -d $(dirname $PID) || mkdir -p $(dirname $PID)
26+
chown -R $USER $(dirname $PID)
27+
28+
case "$1" in
29+
start )
30+
sudo -u $USER $BIN $ARGS
31+
;;
32+
stop )
33+
[ -f $PID ] && kill $(cat $PID)
34+
;;
35+
restart )
36+
[ -f $PID ] && kill $(cat $PID)
37+
sleep 5
38+
sudo -u $USER $BIN $ARGS
39+
;;
40+
status)
41+
[ -f $PID ] && echo "running as $(cat $PID)" || echo "stopped"
42+
;;
43+
* )
44+
echo "Usage: $0 (start | stop | restart | status)"
45+
exit 1
46+
esac

0 commit comments

Comments
 (0)