Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for zabbix::agent on AIX #665

Merged
merged 9 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@
else {
# Installing the package
package { $zabbix_package_agent:
ensure => $zabbix_package_state,
require => Class['zabbix::repo'],
tag => 'zabbix',
ensure => $zabbix_package_state,
require => Class['zabbix::repo'],
tag => 'zabbix',
provider => $zabbix_package_provider,
}
}

Expand All @@ -434,12 +435,18 @@
# Controlling the 'zabbix-agent' service
if str2bool(getvar('::systemd')) {
$service_provider = 'systemd'
$service_path = undef
} elsif $facts['os']['name'] == 'AIX' {
$service_provider = 'init'
$service_path = '/etc/rc.d/init.d'
} else {
$service_provider = undef
$service_path = undef
}
service { $servicename:
ensure => $service_ensure,
enable => $service_enable,
path => $service_path,
provider => $service_provider,
hasstatus => true,
hasrestart => true,
Expand Down
12 changes: 12 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
}
'AIX': {
$manage_repo = false
$zabbix_package_provider = 'yum'
$zabbix_package_agent = 'zabbix-agent'
$agent_configfile_path = '/etc/zabbix/zabbix_agentd.conf'
$agent_config_owner = 'zabbix'
$agent_zabbix_user = 'zabbix'
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
}

'Archlinux': {
$server_fpinglocation = '/usr/bin/fping'
$server_fping6location = '/usr/bin/fping6'
Expand Down
12 changes: 11 additions & 1 deletion manifests/startup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
mode => '0755',
content => template("zabbix/${name}-${osfamily_downcase}.init.erb"),
}
} elsif $facts['os']['family'] in ['AIX'] {
file { "/etc/rc.d/init.d/${service_name}":
ensure => file,
mode => '0755',
content => epp('zabbix/zabbix-agent-aix.init.epp', { 'pidfile' => $pidfile, 'agent_configfile_path' => $agent_configfile_path, 'zabbix_user' => $zabbix_user }),
}
file { "/etc/rc.d/rc2.d/S999${service_name}":
ensure => 'link',
target => "/etc/rc.d/init.d/${service_name}",
}
} elsif ($facts['os']['family'] == 'windows') {
exec { "install_agent_${name}":
command => "& 'C:\\Program Files\\Zabbix Agent\\zabbix_agentd.exe' --config ${agent_configfile_path} --install",
Expand All @@ -64,6 +74,6 @@
notify => Service[$name],
}
} else {
fail('We currently only support Debian, Redhat and Windows osfamily as non-systemd')
fail('We currently only support Debian, Redhat, AIX and Windows osfamily as non-systemd')
}
}
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
"2012 R2",
"2016"
]
},
{
"operatingsystem": "AIX"
}
]
}
46 changes: 46 additions & 0 deletions templates/zabbix-agent-aix.init.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<%- | String $pidfile,
String $agent_configfile_path,
String $zabbix_user
| -%>
#!/bin/ksh
# THIS FILE IS MANAGED BY PUPPET


##################################################
# name: start zabbix agent
# purpose: zabbix agent start script
# author: V.Danhelka IBM 11.2.2016; B. Schafer 2020-02-26
##################################################

PID=<%= $pidfile %>
BIN=/usr/sbin/zabbix_agentd
CONF=<%= $agent_configfile_path %>
LOGFILE=/var/log/zabbix/zabbix_agentd.log
ARGS="-c $CONF"
USER=<%= $zabbix_user %>

test -d $(dirname $LOGFILE) || mkdir -p $(dirname $LOGFILE)
chown -R $USER $LOGDIR

test -d $(dirname $PID) || mkdir -p $(dirname $PID)
chown -R $USER $(dirname $PID)

case "$1" in
start )
sudo -u $USER $BIN $ARGS
;;
stop )
[ -f $PID ] && kill $(cat $PID)
;;
restart )
[ -f $PID ] && kill $(cat $PID)
sleep 5
sudo -u $USER $BIN $ARGS
;;
status)
[ -f $PID ] && echo "running as $(cat $PID)" || echo "stopped"
;;
* )
echo "Usage: $0 (start | stop | restart | status)"
exit 1
esac