diff --git a/attributes/agent.rb b/attributes/agent.rb index 214f59f..d25c6d8 100644 --- a/attributes/agent.rb +++ b/attributes/agent.rb @@ -12,6 +12,7 @@ default['zabbix']['agent']['hostname'] = node['fqdn'] default['zabbix']['agent']['configure_options'] = ['--with-libcurl'] default['zabbix']['agent']['include_dir'] = ::File.join(node['zabbix']['etc_dir'] , 'agent_include') +default['zabbix']['agent']['scripts_dir'] = ::File.join(node['zabbix']['etc_dir'], 'user_scripts') default['zabbix']['agent']['enable_remote_commands'] = true default['zabbix']['agent']['listen_port'] = '10050' default['zabbix']['agent']['timeout'] = '3' @@ -44,3 +45,4 @@ default['zabbix']['agent']['interfaces'] = ['zabbix_agent'] default['zabbix']['agent']['user_parameter'] = [] +default['zabbix']['agent']['user_script'] = [] diff --git a/metadata.rb b/metadata.rb index 95decb7..1709fc0 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Installs/Configures Zabbix Agent/Server' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.8.0' +version '0.8.1' supports 'ubuntu', '>= 10.04' supports 'debian', '>= 6.0' supports 'redhat', '>= 5.0' diff --git a/recipes/_agent_common_directories.rb b/recipes/_agent_common_directories.rb index 8df10d0..e8debaa 100644 --- a/recipes/_agent_common_directories.rb +++ b/recipes/_agent_common_directories.rb @@ -1,5 +1,6 @@ root_dirs = [ - node['zabbix']['agent']['include_dir'] + node['zabbix']['agent']['include_dir'], + node['zabbix']['agent']['scripts_dir'] ] # Create root folders diff --git a/recipes/agent.rb b/recipes/agent.rb index 6b8929e..dad0bf3 100644 --- a/recipes/agent.rb +++ b/recipes/agent.rb @@ -26,6 +26,19 @@ only_if { node['zabbix']['agent']['user_parameter'].length > 0 } end +# Install custom scripts +node['zabbix']['agent']['user_script'].each do |script| + cookbook_file File.join(node['zabbix']['agent']['scripts_dir'], script) do + source "scripts/#{script}" + unless node['platform_family'] == 'windows' + owner 'root' + group 'root' + mode '755' + end + action :create_if_missing + end +end + ruby_block 'start service' do block do true