2017-02-07 01:02:03 -05:00
|
|
|
#
|
|
|
|
# Cookbook Name:: zabbix
|
|
|
|
# Recipe:: trap_scripts
|
|
|
|
#
|
|
|
|
# Copyright 2017, Linux-Help.org
|
|
|
|
# Authors:
|
|
|
|
# Eric Renfro <psi-jack@linux-help.org>
|
|
|
|
#
|
|
|
|
|
2017-02-13 00:06:00 -05:00
|
|
|
include_recipe 'chef-vault'
|
|
|
|
|
2017-02-07 01:02:03 -05:00
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] = []
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] = []
|
|
|
|
node.override['zabbix']['trap_scripts']['daily']['add'] = []
|
|
|
|
node.override['zabbix']['trap_scripts']['daily']['del'] = []
|
|
|
|
node.override['zabbix']['agent_meta'] = []
|
|
|
|
|
|
|
|
# Utilize node tags to determine which agents to activate:
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Apache Web Server
|
|
|
|
#
|
|
|
|
if node['recipes'].include?('httpd') or node.tags.include?('httpd')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['httpd.sh', 'ssl_check_apache.sh']
|
|
|
|
node.override['zabbix']['agent_meta'] += ['HTTPD']
|
|
|
|
elsif
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['httpd.sh', 'ssl_check_apache.sh']
|
|
|
|
end
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# OpenLDAP
|
|
|
|
#
|
|
|
|
if node['recipes'].include?('ldap') or node.tags.include?('openldap')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['openldap2.sh', 'ssl_check_ldap.sh']
|
|
|
|
node.override['zabbix']['agent_meta'] += ['OpenLDAP']
|
|
|
|
else
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['openldap2.sh', 'ssl_check_ldap.sh']
|
|
|
|
end
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# MongoDB
|
|
|
|
#
|
|
|
|
if node['recipes'].include?('mongodb') or node.tags.include?('mongodb')
|
2017-02-13 00:06:00 -05:00
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['mongo26.sh', 'ssl_check_mongo.sh']
|
|
|
|
node.override['zabbix']['agent_meta'] += ['MongoDB']
|
|
|
|
|
|
|
|
template "/etc/zabbix/trap.d/mongo26.config" do
|
|
|
|
owner "root"
|
|
|
|
group "root"
|
|
|
|
mode "0700"
|
|
|
|
source "mongo26.config.erb"
|
|
|
|
sensitive true
|
|
|
|
credentials = chef_vault_item("secrets", "mongodb")
|
|
|
|
variables({
|
|
|
|
:credentials => credentials
|
|
|
|
})
|
|
|
|
end
|
2017-02-07 01:02:03 -05:00
|
|
|
else
|
2017-02-13 00:06:00 -05:00
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['mongo26.sh', 'ssl_check_mongo.sh']
|
|
|
|
file "/etc/zabbix/trap.d/mongo26.config" do
|
|
|
|
action :delete
|
|
|
|
end
|
2017-02-07 01:02:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Shibboleth Service Provider
|
|
|
|
#
|
|
|
|
if node['recipes'].include?('shibboleth') or node.tags.include?('shibboleth')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['sp.sh', 'idp.sh', 'tomcat.sh']
|
|
|
|
if not node.override['zabbix']['trap_scripts']['live']['add'].include?('httpd.sh')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['httpd.sh']
|
|
|
|
end
|
|
|
|
if node.override['zabbix']['trap_scripts']['live']['del'].include?('httpd.sh')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'].delete('httpd.sh')
|
|
|
|
end
|
|
|
|
if node['zabbix']['agent_meta'].include?('HTTPD')
|
|
|
|
node.override['zabbix']['agent_meta'].delete('HTTPD')
|
|
|
|
end
|
|
|
|
node.override['zabbix']['agent_meta'] += ['ShibD']
|
|
|
|
else
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['sp.sh', 'idp.sh']
|
|
|
|
if not node['recipes'].include?('tomcat')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['tomcat.sh']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# Tomcat
|
|
|
|
#
|
|
|
|
if (node['recipes'].include?('tomcat') or node.tags.include?('tomcat')) and
|
|
|
|
not node.override['zabbix']['trap_scripts']['live']['add'].include?('tomcat.sh')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['add'] += ['tomcat.sh']
|
|
|
|
node.override['zabbix']['agent_meta'] += ['Tomcat6']
|
|
|
|
elsif not node['zabbix']['trap_scripts']['live']['del'].include?('tomcat.sh') and
|
|
|
|
not node['zabbix']['trap_scripts']['live']['add'].include?('tomcat.sh') and
|
|
|
|
not node.tags.include?('tomcat')
|
|
|
|
node.override['zabbix']['trap_scripts']['live']['del'] += ['tomcat.sh']
|
|
|
|
end
|