diff --git a/README.md b/README.md
index 2dd1db1..0a75a99 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,24 @@ There is a number of roles which are available to you:
- ``shinken-poller``
- ``shinken-scheduler``
+To use the recipes, you must create the following data bags:
+
+shinken_commands
+shinken_contacts
+shinken_contact_templates
+shinken_escalations
+shinken_hostgroups
+shinken_hosts
+shinken_host_templates
+shinken_modules
+shinken_notificationways
+shinken_servicegroups
+shinken_services
+shinken_service_templates
+shinken_timeperiods
+
+See the examples directory for example roles and data bag entries.
+
## License and author
Copyright 2013, Arthur Gautier
diff --git a/attributes/default.rb b/attributes/default.rb
index 8c443e9..f82ed9d 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -24,6 +24,20 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
+case node['platform_family']
+when 'rhel'
+ default["shinken"]["core_package"] = "shinken"
+ default["shinken"]["run_dir"] = "/var/run/shinken"
+ default["shinken"]["work_dir"] = "/var/lib/shinken"
+ default["shinken"]["bin_dir"] = "/usr/sbin"
+else
+ default["shinken"]["core_package"] = "shinken-core"
+ default["shinken"]["run_dir"] = "/var/run/nagios"
+ default["shinken"]["work_dir"] = "/var/lib/nagios"
+ default["shinken"]["bin_dir"] = "/usr/bin"
+end
+
+default["shinken"]["log_dir"] = "/var/log/shinken"
default["shinken"]["scheduler" ]["port"] = 7768
default["shinken"]["reactionner"]["port"] = 7769
@@ -44,8 +58,17 @@
default["shinken"]["scheduler" ]["variables"] = default_variables
default["shinken"]["arbiter" ]["variables"] = default_variables
-default["shinken"]["poller" ]["variables"] = default_variables
-default["shinken"]["broker" ]["variables"] = default_variables
+default["shinken"]["poller" ]["variables"] = default_variables.merge({
+ "manage_sub_realms" => 0,
+ "min_workers" => 0,
+ "max_workers" => 0,
+ "processes_by_worker" => 256,
+ "polling_interval" => 1
+})
+default["shinken"]["broker" ]["variables"] = default_variables.merge({
+ "manage_sub_realms" => 1,
+ "manage_arbiters" => 1
+})
default["shinken"]["receiver" ]["variables"] = default_variables
default["shinken"]["reactionner"]["variables"] = default_variables.merge({
"manage_sub_realms" => 0,
@@ -53,4 +76,4 @@
"max_workers" => 15
})
-
+default["shinken"]["auto_poller_tags"] = false
diff --git a/attributes/pnp.rb b/attributes/pnp.rb
new file mode 100644
index 0000000..a58ac44
--- /dev/null
+++ b/attributes/pnp.rb
@@ -0,0 +1,6 @@
+case node['platform_family']
+when 'rhel'
+ default["shinken"]["pnp"]["fpm"] = "php-fpm"
+else
+ default["shinken"]["pnp"]["fpm"] = "php5-fpm"
+end
diff --git a/examples/data_bags/shinken_commands/check_host_alive.json b/examples/data_bags/shinken_commands/check_host_alive.json
new file mode 100644
index 0000000..7770e12
--- /dev/null
+++ b/examples/data_bags/shinken_commands/check_host_alive.json
@@ -0,0 +1,7 @@
+{
+ "id": "check_host_alive",
+ "command_name": "check_host_alive",
+ "command": "$PLUGINSDIR$/check_ping",
+ "arguments": ["-H", "$HOSTADDRESS$", "-w", "1000,100%", "-c", "3000,100%", "-p", "1"]
+}
+
diff --git a/examples/data_bags/shinken_commands/notify_host_by_email.json b/examples/data_bags/shinken_commands/notify_host_by_email.json
new file mode 100644
index 0000000..42bd590
--- /dev/null
+++ b/examples/data_bags/shinken_commands/notify_host_by_email.json
@@ -0,0 +1,6 @@
+{
+ "id": "notify_host_by_email",
+ "command_name": "notify_host_by_email",
+ "command": "/usr/bin/printf",
+ "arguments": [ "\"%b\"", "\"Shinken Notification\\n\\nType:$NOTIFICATIONTYPE$\\nHost: $HOSTNAME$\\nState: $HOSTSTATE$\\nAddress: $HOSTADDRESS$\\nInfo: $HOSTOUTPUT$\\nDate/Time: $DATE$\\n\"", "|", "/bin/mail", "-s", "\"Host $HOSTSTATE$ alert for $HOSTNAME$!\" $CONTACTEMAIL$"]
+}
diff --git a/examples/data_bags/shinken_commands/notify_host_by_xmpp.json b/examples/data_bags/shinken_commands/notify_host_by_xmpp.json
new file mode 100644
index 0000000..dde5f7f
--- /dev/null
+++ b/examples/data_bags/shinken_commands/notify_host_by_xmpp.json
@@ -0,0 +1,6 @@
+{
+ "id": "notify_host_by_xmpp",
+ "command_name": "notify_host_by_xmpp",
+ "command": "/usr/local/bin/xmppsend",
+ "arguments": ["-a", "/usr/local/etc/xmppsend.ini", "\"$NOTIFICATIONTYPE$: Host '$HOSTNAME$' is $HOSTSTATE$: $HOSTOUTPUT$\"", "$CONTACTPAGER$"]
+}
diff --git a/examples/data_bags/shinken_commands/notify_service_by_email.json b/examples/data_bags/shinken_commands/notify_service_by_email.json
new file mode 100644
index 0000000..8a9cf1e
--- /dev/null
+++ b/examples/data_bags/shinken_commands/notify_service_by_email.json
@@ -0,0 +1,6 @@
+{
+ "id": "notify_service_by_email",
+ "command_name": "notify_service_by_email",
+ "command": "/usr/bin/printf",
+ "arguments": [ "\"%b\"", "\"Shinken Notification\\n\\nNotification Type: $NOTIFICATIONTYPE$\\n\\nService: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$\\nState: $SERVICESTATE$\\n\\nDate/Time: $DATE$ Additional Info : $SERVICEOUTPUT$\\n\"", "|", "/bin/mail", "-s", "\"** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **\" $CONTACTEMAIL$"]
+}
diff --git a/examples/data_bags/shinken_commands/notify_service_by_xmpp.json b/examples/data_bags/shinken_commands/notify_service_by_xmpp.json
new file mode 100644
index 0000000..b3b1557
--- /dev/null
+++ b/examples/data_bags/shinken_commands/notify_service_by_xmpp.json
@@ -0,0 +1,6 @@
+{
+ "id": "notify_service_by_xmpp",
+ "command_name": "notify_service_by_xmpp",
+ "command": "/usr/local/bin/xmppsend",
+ "arguments": ["-a", "/usr/local/etc/xmppsend.ini", "\"$NOTIFICATIONTYPE$: Service $HOSTNAME$ $SERVICEDESC$ is $SERVICESTATE$: $SERVICEOUTPUT$\"", "$CONTACTPAGER$"]
+}
diff --git a/examples/data_bags/shinken_contact_templates/admin.json b/examples/data_bags/shinken_contact_templates/admin.json
new file mode 100644
index 0000000..1549bc8
--- /dev/null
+++ b/examples/data_bags/shinken_contact_templates/admin.json
@@ -0,0 +1,11 @@
+{
+ "id": "admin",
+ "use": ["generic-contact"],
+ "host_notifications_enabled": true,
+ "service_notifications_enabled": true,
+ "email": "sitealerts@example.com",
+ "can_submit_commands": true,
+ "notificationways": ["xmpp"],
+ "is_admin": true,
+ "register": false
+}
diff --git a/examples/data_bags/shinken_contact_templates/client-contact.json b/examples/data_bags/shinken_contact_templates/client-contact.json
new file mode 100644
index 0000000..aa51eef
--- /dev/null
+++ b/examples/data_bags/shinken_contact_templates/client-contact.json
@@ -0,0 +1,6 @@
+{
+ "id": "client-contact",
+ "use": ["generic-contact"],
+ "is_admin": false,
+ "register": false
+}
diff --git a/examples/data_bags/shinken_contact_templates/deployment-contact.json b/examples/data_bags/shinken_contact_templates/deployment-contact.json
new file mode 100644
index 0000000..ecd1f1b
--- /dev/null
+++ b/examples/data_bags/shinken_contact_templates/deployment-contact.json
@@ -0,0 +1,10 @@
+{
+ "id": "deployment-contact",
+ "use": ["generic-contact"],
+ "host_notifications_enabled": true,
+ "service_notifications_enabled": true,
+ "email": "deployment@exampl.com",
+ "notificationways": ["email"],
+ "is_admin": false,
+ "register": false
+}
diff --git a/examples/data_bags/shinken_contact_templates/generic_contact.json b/examples/data_bags/shinken_contact_templates/generic_contact.json
new file mode 100644
index 0000000..827a490
--- /dev/null
+++ b/examples/data_bags/shinken_contact_templates/generic_contact.json
@@ -0,0 +1,11 @@
+{
+ "id": "generic-contact",
+ "host_notifications_enabled": false,
+ "service_notifications_enabled": false,
+ "email": "root@localhost",
+ "can_submit_commands": false,
+ "notificationways": ["email"],
+ "contactgroups": "+all",
+ "is_admin": true,
+ "register": false
+}
diff --git a/examples/data_bags/shinken_contacts/deployment.json b/examples/data_bags/shinken_contacts/deployment.json
new file mode 100644
index 0000000..179acc7
--- /dev/null
+++ b/examples/data_bags/shinken_contacts/deployment.json
@@ -0,0 +1,7 @@
+{
+ "id": "deployment",
+ "comment": "Deployment User",
+ "email": "deployment@example.com",
+ "groups": ["deployment"],
+ "use": ["deployment-contact"]
+}
diff --git a/examples/data_bags/shinken_escalations/deployment_email.json b/examples/data_bags/shinken_escalations/deployment_email.json
new file mode 100644
index 0000000..333e3b1
--- /dev/null
+++ b/examples/data_bags/shinken_escalations/deployment_email.json
@@ -0,0 +1,9 @@
+{
+ "id": "deployment_email",
+ "first_notification_time": 30,
+ "last_notification_time": 0,
+ "notification_interval": 60,
+ "escalation_period": "24x7",
+ "escalation_options": [ "critical", "recovery"],
+ "contact_groups": ["deployment"]
+}
diff --git a/examples/data_bags/shinken_escalations/sysadmin_email.json b/examples/data_bags/shinken_escalations/sysadmin_email.json
new file mode 100644
index 0000000..dca7287
--- /dev/null
+++ b/examples/data_bags/shinken_escalations/sysadmin_email.json
@@ -0,0 +1,9 @@
+{
+ "id": "sysadmin_email",
+ "first_notification_time": 60,
+ "last_notification_time": 0,
+ "notification_interval": 60,
+ "escalation_period": "24x7",
+ "escalation_options": ["warning", "unknown", "critical", "recovery"],
+ "contact_groups": ["sysadmin"]
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_host_templates/centos-host.json b/examples/data_bags/shinken_host_templates/centos-host.json
new file mode 100644
index 0000000..02a1e82
--- /dev/null
+++ b/examples/data_bags/shinken_host_templates/centos-host.json
@@ -0,0 +1,7 @@
+{
+ "id": "centos-host",
+ "use": ["generic-host"],
+ "hostgroups": ["+linux", "centos"],
+ "icon_image": "centos.png",
+ "icon_image_alt": "Centos"
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_host_templates/generic-host.json b/examples/data_bags/shinken_host_templates/generic-host.json
new file mode 100644
index 0000000..82837a8
--- /dev/null
+++ b/examples/data_bags/shinken_host_templates/generic-host.json
@@ -0,0 +1,20 @@
+{
+ "id": "generic-host",
+ "hostgroups": ["+all"],
+ "check_command": "check_host_alive",
+ "max_check_attempts": 2,
+ "check_interval": 5,
+ "active_checks_enabled": true,
+ "check_period": "24x7",
+ "contact_groups": ["sysadmin"],
+ "notification_interval": 60,
+ "notification_period": "24x7",
+ "notification_options": ["down", "unreachable", "recovery", "flapping"],
+ "notifications_enabled": true,
+ "event_handler_enabled": true,
+ "flap_detection_enabled": true,
+ "process_perf_data": true,
+ "notes_url": "/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_",
+ "escalations": "deployment_email",
+ "register": false
+}
diff --git a/examples/data_bags/shinken_host_templates/no-chef-host.json b/examples/data_bags/shinken_host_templates/no-chef-host.json
new file mode 100644
index 0000000..75e305e
--- /dev/null
+++ b/examples/data_bags/shinken_host_templates/no-chef-host.json
@@ -0,0 +1,6 @@
+{
+ "id": "no-chef-host",
+ "hostgroups": ["+no_chef", "monitoring"],
+ "use": ["generic-host"],
+ "register": false
+}
diff --git a/examples/data_bags/shinken_host_templates/windows-host.json b/examples/data_bags/shinken_host_templates/windows-host.json
new file mode 100644
index 0000000..17fe374
--- /dev/null
+++ b/examples/data_bags/shinken_host_templates/windows-host.json
@@ -0,0 +1,7 @@
+{
+ "id": "windows-host",
+ "use": ["generic-host"],
+ "hostgroups": ["windows"],
+ "icon_image": "win40.png",
+ "icon_image_alt": "Windows"
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_hostgroups/all.json b/examples/data_bags/shinken_hostgroups/all.json
new file mode 100644
index 0000000..e22768b
--- /dev/null
+++ b/examples/data_bags/shinken_hostgroups/all.json
@@ -0,0 +1,5 @@
+{
+ "id": "all",
+ "hostgroup_name": "all",
+ "hostgroup_alias": "All"
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_hostgroups/no_chef.json b/examples/data_bags/shinken_hostgroups/no_chef.json
new file mode 100644
index 0000000..546f12d
--- /dev/null
+++ b/examples/data_bags/shinken_hostgroups/no_chef.json
@@ -0,0 +1,5 @@
+{
+ "id": "no_chef",
+ "hostgroup_name": "no_chef",
+ "hostgroup_alias": "no_chef"
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_hosts/jira.json b/examples/data_bags/shinken_hosts/jira.json
new file mode 100644
index 0000000..43aa8e7
--- /dev/null
+++ b/examples/data_bags/shinken_hosts/jira.json
@@ -0,0 +1,8 @@
+{
+ "id": "jira",
+ "host_name": "jira",
+ "address": " 1.2.3.5",
+ "host_alias": "jira.example.com",
+ "hostgroups": ["+prod", "mysql-master", "mysql", "jira"],
+ "use": ["no-chef-host","centos-host","generic-host"]
+}
diff --git a/examples/data_bags/shinken_hosts/tomcat.json b/examples/data_bags/shinken_hosts/tomcat.json
new file mode 100644
index 0000000..9f4515c
--- /dev/null
+++ b/examples/data_bags/shinken_hosts/tomcat.json
@@ -0,0 +1,8 @@
+{
+ "id": "tomcat",
+ "host_name": "tomcat",
+ "address": "1.2.3.8",
+ "host_alias": "tomcat.example.com",
+ "hostgroups": ["+prod", "example.com", "tomcat"],
+ "use": ["no-chef-host","centos-host","generic-host"]
+}
diff --git a/examples/data_bags/shinken_hosts/windows.json b/examples/data_bags/shinken_hosts/windows.json
new file mode 100644
index 0000000..bec205e
--- /dev/null
+++ b/examples/data_bags/shinken_hosts/windows.json
@@ -0,0 +1,8 @@
+{
+ "id": "windows",
+ "host_name": "windows",
+ "address": "1.2.3.7",
+ "host_alias": "windows.example.com",
+ "hostgroups": ["+prod", "bi"],
+ "use": ["no-chef-host","windows-host","generic-host"]
+}
diff --git a/examples/data_bags/shinken_hosts/wordpress.json b/examples/data_bags/shinken_hosts/wordpress.json
new file mode 100644
index 0000000..40cb41f
--- /dev/null
+++ b/examples/data_bags/shinken_hosts/wordpress.json
@@ -0,0 +1,8 @@
+{
+ "id": "wordpress",
+ "host_name": "wordpress",
+ "address": "1.2.3.6",
+ "host_alias": "wordpress.example.com",
+ "hostgroups": ["+prod", "mysql-master", "wordpress"],
+ "use": ["no-chef-host","centos-host","generic-host"]
+}
diff --git a/examples/data_bags/shinken_modules/apache_passwd.json b/examples/data_bags/shinken_modules/apache_passwd.json
new file mode 100644
index 0000000..fbb1b53
--- /dev/null
+++ b/examples/data_bags/shinken_modules/apache_passwd.json
@@ -0,0 +1,7 @@
+{
+ "id": "Apache_passwd",
+ "type": "passwd_webui",
+ "variables": {
+ "passwd": "/etc/shinken/htpasswd.users"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/commandfile.json b/examples/data_bags/shinken_modules/commandfile.json
new file mode 100644
index 0000000..e6c804d
--- /dev/null
+++ b/examples/data_bags/shinken_modules/commandfile.json
@@ -0,0 +1,7 @@
+{
+ "id": "CommandFile",
+ "type": "named_pipe",
+ "variables": {
+ "command_file": "rw/nagios.cmd"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/livestatus.json b/examples/data_bags/shinken_modules/livestatus.json
new file mode 100644
index 0000000..4da7de2
--- /dev/null
+++ b/examples/data_bags/shinken_modules/livestatus.json
@@ -0,0 +1,9 @@
+{
+ "id": "Livestatus",
+ "type": "livestatus",
+ "variables": {
+ "host": "*",
+ "port": "50000"
+ },
+ "modules": ["mongologs"]
+}
diff --git a/examples/data_bags/shinken_modules/mongodb.json b/examples/data_bags/shinken_modules/mongodb.json
new file mode 100644
index 0000000..fb76506
--- /dev/null
+++ b/examples/data_bags/shinken_modules/mongodb.json
@@ -0,0 +1,8 @@
+{
+ "id": "Mongodb",
+ "type": "mongodb",
+ "variables": {
+ "uri": "mongodb://localhost/?safe=true",
+ "database": "shinken"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/mongologs.json b/examples/data_bags/shinken_modules/mongologs.json
new file mode 100644
index 0000000..0b31905
--- /dev/null
+++ b/examples/data_bags/shinken_modules/mongologs.json
@@ -0,0 +1,7 @@
+{
+ "id": "mongologs",
+ "type": "logstore_mongodb",
+ "variables": {
+ "mongodb_uri": "mongodb://localhost/?safe=true"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/npcdmod.json b/examples/data_bags/shinken_modules/npcdmod.json
new file mode 100644
index 0000000..b456364
--- /dev/null
+++ b/examples/data_bags/shinken_modules/npcdmod.json
@@ -0,0 +1,7 @@
+{
+ "id": "NPCDMOD",
+ "type": "npcdmod",
+ "variables": {
+ "config_file": "/etc/pnp4nagios/npcd.cfg"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/nrpe_booster.json b/examples/data_bags/shinken_modules/nrpe_booster.json
new file mode 100644
index 0000000..c3c7e59
--- /dev/null
+++ b/examples/data_bags/shinken_modules/nrpe_booster.json
@@ -0,0 +1,4 @@
+{
+ "id": "NrpeBooster",
+ "type": "nrpe_poller"
+}
diff --git a/examples/data_bags/shinken_modules/pickle_retention.json b/examples/data_bags/shinken_modules/pickle_retention.json
new file mode 100644
index 0000000..d47de58
--- /dev/null
+++ b/examples/data_bags/shinken_modules/pickle_retention.json
@@ -0,0 +1,7 @@
+{
+ "id": "PickleRetention",
+ "type": "pickle_retention_file_generic",
+ "variables": {
+ "path": "/tmp/retention.dat"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/pickle_retention_arbiter.json b/examples/data_bags/shinken_modules/pickle_retention_arbiter.json
new file mode 100644
index 0000000..a8a326d
--- /dev/null
+++ b/examples/data_bags/shinken_modules/pickle_retention_arbiter.json
@@ -0,0 +1,7 @@
+{
+ "id": "PickleRetentionAribiter",
+ "type": "pickle_retention_file_generic",
+ "variables": {
+ "path": "/var/tmp/retention_arbiter.dat"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/pickle_retention_broker.json b/examples/data_bags/shinken_modules/pickle_retention_broker.json
new file mode 100644
index 0000000..40e5931
--- /dev/null
+++ b/examples/data_bags/shinken_modules/pickle_retention_broker.json
@@ -0,0 +1,7 @@
+{
+ "id": "PickleRetentionBroker",
+ "type": "pickle_retention_file_generic",
+ "variables": {
+ "path": "/var/tmp/retention_broker.dat"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/pnp_ui.json b/examples/data_bags/shinken_modules/pnp_ui.json
new file mode 100644
index 0000000..b7434a0
--- /dev/null
+++ b/examples/data_bags/shinken_modules/pnp_ui.json
@@ -0,0 +1,7 @@
+{
+ "id": "PNP_UI",
+ "type": "pnp_webui",
+ "variables": {
+ "uri": "http://mysite.example.com/pnp4nagios/"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/simplelog.json b/examples/data_bags/shinken_modules/simplelog.json
new file mode 100644
index 0000000..5bc0477
--- /dev/null
+++ b/examples/data_bags/shinken_modules/simplelog.json
@@ -0,0 +1,8 @@
+{
+ "id": "Simple-log",
+ "type": "simple_log",
+ "variables": {
+ "path": "/var/log/shinken/shinken.log",
+ "archive_path": "archives/"
+ }
+}
diff --git a/examples/data_bags/shinken_modules/syslog.json b/examples/data_bags/shinken_modules/syslog.json
new file mode 100644
index 0000000..3fe610c
--- /dev/null
+++ b/examples/data_bags/shinken_modules/syslog.json
@@ -0,0 +1,4 @@
+{
+ "id": "Syslog",
+ "type": "syslog"
+}
diff --git a/examples/data_bags/shinken_modules/webui.json b/examples/data_bags/shinken_modules/webui.json
new file mode 100644
index 0000000..5c6202b
--- /dev/null
+++ b/examples/data_bags/shinken_modules/webui.json
@@ -0,0 +1,14 @@
+{
+ "id": "WebUI",
+ "type": "webui",
+ "variables": {
+ "host": "0.0.0.0",
+ "port": "7767",
+ "auth_secret": "put your secret here!",
+ "allow_html_output": "0",
+ "max_output_length": "100",
+ "manage_acl": "1",
+ "play_sound": "0"
+ },
+ "modules": ["Apache_passwd", "Mongodb", "PNP_UI"]
+}
diff --git a/examples/data_bags/shinken_notificationways/email.json b/examples/data_bags/shinken_notificationways/email.json
new file mode 100644
index 0000000..b650cf8
--- /dev/null
+++ b/examples/data_bags/shinken_notificationways/email.json
@@ -0,0 +1,9 @@
+{
+ "id": "email",
+ "service_notification_period": "24x7",
+ "host_notification_period": "24x7",
+ "service_notification_options": ["warning", "unknown", "critical", "recovery"],
+ "host_notification_options": ["down", "unreachable", "recovery", "flapping"],
+ "service_notification_commands": "notify_service_by_email",
+ "host_notification_commands": "notify_host_by_email"
+}
diff --git a/examples/data_bags/shinken_notificationways/xmpp.json b/examples/data_bags/shinken_notificationways/xmpp.json
new file mode 100644
index 0000000..beb60aa
--- /dev/null
+++ b/examples/data_bags/shinken_notificationways/xmpp.json
@@ -0,0 +1,9 @@
+{
+ "id": "xmpp",
+ "service_notification_period": "24x7",
+ "host_notification_period": "24x7",
+ "service_notification_options": ["warning", "unknown", "critical", "recovery"],
+ "host_notification_options": ["down", "unreachable", "recovery", "flapping"],
+ "service_notification_commands": "notify_service_by_xmpp",
+ "host_notification_commands": "notify_host_by_xmpp"
+}
diff --git a/examples/data_bags/shinken_service_templates/daily-service.json b/examples/data_bags/shinken_service_templates/daily-service.json
new file mode 100644
index 0000000..82d4b62
--- /dev/null
+++ b/examples/data_bags/shinken_service_templates/daily-service.json
@@ -0,0 +1,11 @@
+{
+ "id": "daily-service",
+ "use": ["generic-service"],
+ "notification_interval": 1440,
+ "check_interval": 1440,
+ "retry_interval": 60,
+ "max_check_attempts": 2,
+ "check_period": "work_hours",
+ "register": false
+}
+
diff --git a/examples/data_bags/shinken_service_templates/generic-service.json b/examples/data_bags/shinken_service_templates/generic-service.json
new file mode 100644
index 0000000..d4ed109
--- /dev/null
+++ b/examples/data_bags/shinken_service_templates/generic-service.json
@@ -0,0 +1,25 @@
+{
+ "id": "generic-service",
+ "contact_groups": ["sysadmin"],
+ "active_checks_enabled": true,
+ "passive_checks_enabled": true,
+ "check_interval": 5,
+ "retry_interval": 2,
+ "max_check_attempts": 5,
+ "check_period": "24x7",
+ "notifications_enabled": true,
+ "notification_options": ["warning", "unknown", "critical", "recovery"],
+ "notification_interval": 60,
+ "notification_period": "24x7",
+ "event_handler_enabled": true,
+ "flap_detection_enabled": true,
+ "check_freshness": false,
+ "freshness_threshold": 3600,
+ "obsess_over_service": false,
+ "process_perf_data": true,
+ "is_volatile": false,
+ "notes_url": "/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$",
+ "escalations": "deployment_email",
+ "register": false
+}
+
diff --git a/examples/data_bags/shinken_services/disk.json b/examples/data_bags/shinken_services/disk.json
new file mode 100644
index 0000000..94261f8
--- /dev/null
+++ b/examples/data_bags/shinken_services/disk.json
@@ -0,0 +1,12 @@
+{
+ "id": "disk",
+ "use": ["generic-service"],
+ "service_description": "Free disk space",
+ "servicegroups": ["Disk"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_disk",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_disk"]
+}
+
diff --git a/examples/data_bags/shinken_services/dns.json b/examples/data_bags/shinken_services/dns.json
new file mode 100644
index 0000000..891d739
--- /dev/null
+++ b/examples/data_bags/shinken_services/dns.json
@@ -0,0 +1,11 @@
+{
+ "id": "dns",
+ "use": ["generic-service"],
+ "service_description": "DNS",
+ "servicegroups": ["DNS"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_dns",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_dns"]
+}
diff --git a/examples/data_bags/shinken_services/http.json b/examples/data_bags/shinken_services/http.json
new file mode 100644
index 0000000..3b98d28
--- /dev/null
+++ b/examples/data_bags/shinken_services/http.json
@@ -0,0 +1,11 @@
+{
+ "id": "http",
+ "use": ["generic-service"],
+ "service_description": "HTTP",
+ "servicegroups": ["HTTP"],
+ "hostgroup_name": "shinken,chef_server,wordpress,wiki,bi",
+ "check_command": "check_http",
+ "command_line": "$PLUGINSDIR$/check_http",
+ "arguments": ["-H", "$HOSTADDRESS$", "-u", "/monitor-ignore", "-e", "404,301,302"]
+}
+
diff --git a/examples/data_bags/shinken_services/https.json b/examples/data_bags/shinken_services/https.json
new file mode 100644
index 0000000..6c6e1c1
--- /dev/null
+++ b/examples/data_bags/shinken_services/https.json
@@ -0,0 +1,11 @@
+{
+ "id": "https",
+ "use": ["generic-service"],
+ "service_description": "HTTPS",
+ "servicegroups": ["HTTPS"],
+ "hostgroup_name": "chef_server,jira",
+ "check_command": "check_https",
+ "command_line": "$PLUGINSDIR$/check_http",
+ "arguments": ["-H", "$HOSTADDRESS$", "-S", "-u", "/monitor-ignore", "-e", "404,301"]
+}
+
diff --git a/examples/data_bags/shinken_services/iftraffic.json b/examples/data_bags/shinken_services/iftraffic.json
new file mode 100644
index 0000000..72f7542
--- /dev/null
+++ b/examples/data_bags/shinken_services/iftraffic.json
@@ -0,0 +1,11 @@
+{
+ "id": "iftraffic",
+ "use": ["generic-service"],
+ "service_description": "Network traffic",
+ "servicegroups": ["Network traffic"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_iftraffic",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_iftraffic"]
+}
diff --git a/examples/data_bags/shinken_services/load.json b/examples/data_bags/shinken_services/load.json
new file mode 100644
index 0000000..58cf726
--- /dev/null
+++ b/examples/data_bags/shinken_services/load.json
@@ -0,0 +1,12 @@
+{
+ "id": "load",
+ "use": ["generic-service"],
+ "service_description": "CPU load",
+ "servicegroups": ["CPU load"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_load",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_load"]
+}
+
diff --git a/examples/data_bags/shinken_services/mailq.json b/examples/data_bags/shinken_services/mailq.json
new file mode 100644
index 0000000..0dbcf12
--- /dev/null
+++ b/examples/data_bags/shinken_services/mailq.json
@@ -0,0 +1,11 @@
+{
+ "id": "mailq",
+ "use": ["generic-service"],
+ "service_description": "Mail queue",
+ "servicegroups": ["Mail queue"],
+ "hostgroup_name": "base",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_mailq",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_mailq"]
+}
diff --git a/examples/data_bags/shinken_services/mem.json b/examples/data_bags/shinken_services/mem.json
new file mode 100644
index 0000000..7f650ba
--- /dev/null
+++ b/examples/data_bags/shinken_services/mem.json
@@ -0,0 +1,13 @@
+{
+ "id": "mem",
+ "use": ["generic-service"],
+ "service_description": "Free memory",
+ "servicegroups": ["Memory"],
+ "hostgroup_name": "linux",
+ "notification_period": "none",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_mem",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_mem"]
+}
+
diff --git a/examples/data_bags/shinken_services/nrpe.json b/examples/data_bags/shinken_services/nrpe.json
new file mode 100644
index 0000000..dc42ae7
--- /dev/null
+++ b/examples/data_bags/shinken_services/nrpe.json
@@ -0,0 +1,11 @@
+{
+ "id": "nrpe",
+ "use": ["generic-service"],
+ "service_description": "NRPE",
+ "servicegroups": ["NRPE"],
+ "hostgroup_name": "linux",
+ "check_command": "check_nrpe",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_dummy"]
+}
+
diff --git a/examples/data_bags/shinken_services/ntp.json b/examples/data_bags/shinken_services/ntp.json
new file mode 100644
index 0000000..6ac0d44
--- /dev/null
+++ b/examples/data_bags/shinken_services/ntp.json
@@ -0,0 +1,11 @@
+{
+ "id": "ntp",
+ "use": ["generic-service"],
+ "service_description": "NTP",
+ "servicegroups": ["NTP"],
+ "hostgroup_name": "linux,!wiki",
+ "check_command": "check_ntp",
+ "command_line": "$PLUGINSDIR$/check_ntp_time",
+ "arguments": ["-H", "$HOSTADDRESS$", "-w", "30", "-c", "60"]
+}
+
diff --git a/examples/data_bags/shinken_services/procs.json b/examples/data_bags/shinken_services/procs.json
new file mode 100644
index 0000000..3fefc0a
--- /dev/null
+++ b/examples/data_bags/shinken_services/procs.json
@@ -0,0 +1,12 @@
+{
+ "id": "procs",
+ "use": ["generic-service"],
+ "service_description": "Running processes",
+ "servicegroups": ["Running processes"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_procs",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_procs"]
+}
+
diff --git a/examples/data_bags/shinken_services/shinken_arbiter.json b/examples/data_bags/shinken_services/shinken_arbiter.json
new file mode 100644
index 0000000..c30139c
--- /dev/null
+++ b/examples/data_bags/shinken_services/shinken_arbiter.json
@@ -0,0 +1,11 @@
+{
+ "id": "shinken_arbiter",
+ "use": ["generic-service"],
+ "service_description": "Shinken arbiter",
+ "servicegroups": ["Shinken"],
+ "hostgroup_name": "shinken",
+ "check_command": "check_shinken_arbiter",
+ "command_line": "$USER1$/check_shinken.py",
+ "arguments": ["-a", "$HOSTADDRESS$", "-t", "arbiter"]
+}
+
diff --git a/examples/data_bags/shinken_services/shinken_broker.json b/examples/data_bags/shinken_services/shinken_broker.json
new file mode 100644
index 0000000..73a1335
--- /dev/null
+++ b/examples/data_bags/shinken_services/shinken_broker.json
@@ -0,0 +1,12 @@
+{
+ "id": "shinken_broker",
+ "use": ["generic-service"],
+ "service_description": "Shinken broker",
+ "servicegroups": ["Shinken"],
+ "hostgroup_name": "shinken",
+ "service_dependencies": ",Shinken arbiter",
+ "check_command": "check_shinken_broker",
+ "command_line": "$USER1$/check_shinken.py",
+ "arguments": ["-a", "$HOSTADDRESS$", "-t", "broker"]
+}
+
diff --git a/examples/data_bags/shinken_services/shinken_poller.json b/examples/data_bags/shinken_services/shinken_poller.json
new file mode 100644
index 0000000..2e69d1d
--- /dev/null
+++ b/examples/data_bags/shinken_services/shinken_poller.json
@@ -0,0 +1,12 @@
+{
+ "id": "shinken_poller",
+ "use": ["generic-service"],
+ "service_description": "Shinken poller",
+ "servicegroups": ["Shinken"],
+ "hostgroup_name": "shinken",
+ "service_dependencies": ",Shinken arbiter",
+ "check_command": "check_shinken_poller",
+ "command_line": "$USER1$/check_shinken.py",
+ "arguments": ["-a", "$HOSTADDRESS$", "-t", "poller"]
+}
+
diff --git a/examples/data_bags/shinken_services/shinken_reactionner.json b/examples/data_bags/shinken_services/shinken_reactionner.json
new file mode 100644
index 0000000..7a2eeb9
--- /dev/null
+++ b/examples/data_bags/shinken_services/shinken_reactionner.json
@@ -0,0 +1,12 @@
+{
+ "id": "shinken_reactionner",
+ "use": ["generic-service"],
+ "service_description": "Shinken reactionner",
+ "servicegroups": ["Shinken"],
+ "hostgroup_name": "shinken",
+ "service_dependencies": ",Shinken arbiter",
+ "check_command": "check_shinken_reactionner",
+ "command_line": "$USER1$/check_shinken.py",
+ "arguments": ["-a", "$HOSTADDRESS$", "-t", "reactionner"]
+}
+
diff --git a/examples/data_bags/shinken_services/shinken_scheduler.json b/examples/data_bags/shinken_services/shinken_scheduler.json
new file mode 100644
index 0000000..e0d9245
--- /dev/null
+++ b/examples/data_bags/shinken_services/shinken_scheduler.json
@@ -0,0 +1,12 @@
+{
+ "id": "shinken_scheduler",
+ "use": ["generic-service"],
+ "service_description": "Shinken scheduler",
+ "servicegroups": ["Shinken"],
+ "hostgroup_name": "shinken",
+ "service_dependencies": ",Shinken arbiter",
+ "check_command": "check_shinken_scheduler",
+ "command_line": "$USER1$/check_shinken.py",
+ "arguments": ["-a", "$HOSTADDRESS$", "-t", "scheduler"]
+}
+
diff --git a/examples/data_bags/shinken_services/ssh.json b/examples/data_bags/shinken_services/ssh.json
new file mode 100644
index 0000000..1cfc185
--- /dev/null
+++ b/examples/data_bags/shinken_services/ssh.json
@@ -0,0 +1,11 @@
+{
+ "id": "ssh",
+ "use": ["generic-service"],
+ "service_description": "SSH",
+ "servicegroups": ["SSH"],
+ "hostgroup_name": "linux",
+ "check_command": "check_ssh",
+ "command_line": "$PLUGINSDIR$/check_ssh",
+ "arguments": ["-H", "$HOSTADDRESS$"]
+}
+
diff --git a/examples/data_bags/shinken_services/swap.json b/examples/data_bags/shinken_services/swap.json
new file mode 100644
index 0000000..eef12eb
--- /dev/null
+++ b/examples/data_bags/shinken_services/swap.json
@@ -0,0 +1,12 @@
+{
+ "id": "swap",
+ "use": ["generic-service"],
+ "service_description": "Free swap",
+ "servicegroups": ["Swap"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_swap",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_swap"]
+}
+
diff --git a/examples/data_bags/shinken_services/updates.json b/examples/data_bags/shinken_services/updates.json
new file mode 100644
index 0000000..eab3c2d
--- /dev/null
+++ b/examples/data_bags/shinken_services/updates.json
@@ -0,0 +1,13 @@
+{
+ "id": "updates",
+ "use": ["daily-service"],
+ "service_description": "Yum security updates",
+ "servicegroups": ["Yum security updates"],
+ "hostgroup_name": "centos,!no_chef",
+ "service_dependencies": ",NRPE",
+ "escalations": "null",
+ "check_command": "check_updates",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_updates", "-t", "60"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_disk.json b/examples/data_bags/shinken_services/win_disk.json
new file mode 100644
index 0000000..0adac42
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_disk.json
@@ -0,0 +1,12 @@
+{
+ "id": "win_disk",
+ "use": ["generic-service"],
+ "service_description": "Free disk space",
+ "servicegroups": ["Disk"],
+ "hostgroup_name": "windows",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_win_disk",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "alias_disk"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_fw.json b/examples/data_bags/shinken_services/win_fw.json
new file mode 100644
index 0000000..5d00321
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_fw.json
@@ -0,0 +1,12 @@
+{
+ "id": "win_fw",
+ "use": ["generic-service"],
+ "service_description": "Windows Firewall",
+ "servicegroups": ["Firewall"],
+ "hostgroup_name": "windows",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_win_fw",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "alias_win_firewall"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_load.json b/examples/data_bags/shinken_services/win_load.json
new file mode 100644
index 0000000..5f0320e
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_load.json
@@ -0,0 +1,12 @@
+{
+ "id": "win_load",
+ "use": ["generic-service"],
+ "service_description": "CPU load",
+ "servicegroups": ["CPU load"],
+ "hostgroup_name": "windows",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_win_load",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "alias_cpu"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_mem.json b/examples/data_bags/shinken_services/win_mem.json
new file mode 100644
index 0000000..b15f0c3
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_mem.json
@@ -0,0 +1,12 @@
+{
+ "id": "win_mem",
+ "use": ["generic-service"],
+ "service_description": "Free memory",
+ "servicegroups": ["Memory"],
+ "hostgroup_name": "windows",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_win_mem",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "alias_mem"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_nrpe.json b/examples/data_bags/shinken_services/win_nrpe.json
new file mode 100644
index 0000000..d5a16ad
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_nrpe.json
@@ -0,0 +1,11 @@
+{
+ "id": "win_nrpe",
+ "use": ["generic-service"],
+ "service_description": "NRPE",
+ "servicegroups": ["NRPE"],
+ "hostgroup_name": "windows",
+ "check_command": "check_win_nrpe",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_rdesktop.json b/examples/data_bags/shinken_services/win_rdesktop.json
new file mode 100644
index 0000000..e50a11e
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_rdesktop.json
@@ -0,0 +1,11 @@
+{
+ "id": "win_rdesktop",
+ "use": ["generic-service"],
+ "service_description": "Remote desktop",
+ "servicegroups": ["Remote desktop"],
+ "hostgroup_name": "windows",
+ "check_command": "check_rdesktop",
+ "command_line": "$PLUGINSDIR$/check_tcp",
+ "arguments": ["-H", "$HOSTADDRESS$", "-p", "3389"]
+}
+
diff --git a/examples/data_bags/shinken_services/win_updates.json b/examples/data_bags/shinken_services/win_updates.json
new file mode 100644
index 0000000..ba5b115
--- /dev/null
+++ b/examples/data_bags/shinken_services/win_updates.json
@@ -0,0 +1,13 @@
+{
+ "id": "win_updates",
+ "use": ["daily-service"],
+ "service_description": "Windows updates",
+ "servicegroups": ["Windows updates"],
+ "hostgroup_name": "windows",
+ "service_dependencies": ",NRPE",
+ "escalations": "null",
+ "check_command": "check_win_updates",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "alias_updates", "-t", "60"]
+}
+
diff --git a/examples/data_bags/shinken_services/zombie_procs.json b/examples/data_bags/shinken_services/zombie_procs.json
new file mode 100644
index 0000000..89abd04
--- /dev/null
+++ b/examples/data_bags/shinken_services/zombie_procs.json
@@ -0,0 +1,12 @@
+{
+ "id": "zombie_procs",
+ "use": ["generic-service"],
+ "service_description": "Zombie processes",
+ "servicegroups": ["Zombie processes"],
+ "hostgroup_name": "linux",
+ "service_dependencies": ",NRPE",
+ "check_command": "check_zombie_procs",
+ "command_line": "$PLUGINSDIR$/check_nrpe",
+ "arguments": ["-H", "$HOSTADDRESS$", "-c", "check_zombie_procs"]
+}
+
diff --git a/examples/data_bags/shinken_timeperiods/24x7.json b/examples/data_bags/shinken_timeperiods/24x7.json
new file mode 100644
index 0000000..fe28ac9
--- /dev/null
+++ b/examples/data_bags/shinken_timeperiods/24x7.json
@@ -0,0 +1,6 @@
+{
+ "id": "24x7",
+ "timeperiod_name": "24x7",
+ "timeperiod_alias": "24_Hours_A_Day,_7_Days_A_Week",
+ "content": ["sunday 00:00-24:00", "monday 00:00-24:00", "tuesday 00:00-24:00", "wednesday 00:00-24:00", "thursday 00:00-24:00", "friday 00:00-24:00", "saturday 00:00-24:00"]
+}
diff --git a/examples/data_bags/shinken_timeperiods/none.json b/examples/data_bags/shinken_timeperiods/none.json
new file mode 100644
index 0000000..2f9cf50
--- /dev/null
+++ b/examples/data_bags/shinken_timeperiods/none.json
@@ -0,0 +1,5 @@
+{
+ "id": "none",
+ "timeperiod_name": "none",
+ "timeperiod_alias": "No Time Is A Good Time"
+}
\ No newline at end of file
diff --git a/examples/data_bags/shinken_timeperiods/work_hours.json b/examples/data_bags/shinken_timeperiods/work_hours.json
new file mode 100644
index 0000000..8c72887
--- /dev/null
+++ b/examples/data_bags/shinken_timeperiods/work_hours.json
@@ -0,0 +1,6 @@
+{
+ "id": "work_hours",
+ "timeperiod_name": "work_hours",
+ "timeperiod_alias": "Work hours",
+ "content": ["monday 10:00-20:00", "tuesday 10:00-20:00", "wednesday 10:00-20:00", "thursday 10:00-20:00", "friday 10:00-20:00"]
+}
diff --git a/examples/data_bags/users/adminuser.json b/examples/data_bags/users/adminuser.json
new file mode 100644
index 0000000..50a69ee
--- /dev/null
+++ b/examples/data_bags/users/adminuser.json
@@ -0,0 +1,12 @@
+{
+ "id": "adminuser",
+ "password": "$1$put encrypted password here",
+ "groups": [ "sysadmin" ],
+ "uid": 2001,
+ "shell": "\/bin\/bash",
+ "comment": "Example Admin User",
+ "nagios": {
+ "pager": "adminuser@jabber.org",
+ "email": "adminuser@example.com"
+ }
+}
\ No newline at end of file
diff --git a/examples/roles/shinken.rb b/examples/roles/shinken.rb
new file mode 100644
index 0000000..73c02a7
--- /dev/null
+++ b/examples/roles/shinken.rb
@@ -0,0 +1,40 @@
+name "shinken"
+description "Monitoring server"
+run_list "role[monitoring]", "recipe[shinken::mongodb]", "recipe[mongodb]",
+"recipe[shinken::pnp]","role[shinken_poller]", "recipe[shinken::reactionner]",
+"recipe[shinken::scheduler]", "recipe[shinken::broker]", "recipe[shinken::broker-webui]",
+"recipe[shinken::receiver]", "recipe[shinken::arbiter]", "recipe[shinken::plugins]",
+"recipe[shinken::xmpp]"
+
+override_attributes( "shinken" => {
+ "arbiter" => {
+ "modules" => ["CommandFile"]
+ },
+ "broker" => {
+ "modules" => [ "Livestatus", "NPCDMOD", "Simple-log", "WebUI"]
+ },
+ "poller" => {
+ "variables" => {
+ "poller_tags" => "None,example.com"
+ }
+ },
+ "scheduler" => {
+ "ipaddress" => "1.2.3.4",
+ "modules" => ["PickleRetention"]
+ },
+ "xmpp" => {
+ "username" => "myuser@jabber.org",
+ "domain" => "jabber.org",
+ "password" => "123456",
+ "server" => "jabber.org",
+ "port" => "5222"
+ },
+ "cgi" => {
+ "admin_group" => "sysadmin",
+ "read_groups" => "dev,qa"
+ },
+ "auto_poller_tags" => true,
+ "cert_name" => "_.example.com",
+ "cert_ca_name" => "gd_bundle",
+ }
+)
diff --git a/examples/roles/shinken_poller.rb b/examples/roles/shinken_poller.rb
new file mode 100644
index 0000000..d5f8e8c
--- /dev/null
+++ b/examples/roles/shinken_poller.rb
@@ -0,0 +1,10 @@
+name "shinken_poller"
+description "Monitoring polling server"
+run_list "role[monitoring]", "recipe[shinken::poller]", "recipe[shinken::plugins]"
+
+override_attributes( "shinken" => {
+ "poller" => {
+ "modules" => ["NrpeBooster"]
+ }
+ }
+)
diff --git a/examples/roles/shinken_remotepoller.rb b/examples/roles/shinken_remotepoller.rb
new file mode 100644
index 0000000..026b7b9
--- /dev/null
+++ b/examples/roles/shinken_remotepoller.rb
@@ -0,0 +1,13 @@
+name "shinken_remotepoller"
+description "Remote monitoring polling server"
+run_list "role[shinken_poller]"
+
+override_attributes( "shinken" => {
+ "poller" => {
+ "ipaddress" => "2.3.4.5",
+ "variables" => {
+ "poller_tags" => "othersite.com"
+ }
+ }
+ }
+)
diff --git a/files/centos/shinken b/files/centos/shinken
new file mode 100755
index 0000000..20dd2f0
--- /dev/null
+++ b/files/centos/shinken
@@ -0,0 +1,541 @@
+#!/bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken
+# Required-Start: $local_fs
+# Required-Stop: $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: S 0 1 6
+# Short-Description: Shinken monitoring daemon
+# Description: Shinken is a monitoring tool composed of many separated modules:
+# - arbiter : the main one : control everything else.
+# - scheduler : receives checks/actions from arbiter. Schedules & forwards them to pollers.
+# - poller : receives the checks from a scheduler. Launch them and returns results
+# - broker : manage results by looking at scheduler. Like export to flat file or db.
+# - reactionner : manage the failed checks by looking at scheduler.
+# - receiver : manage all passive data
+### END INIT INFO
+
+# Deadlink :(
+# http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+
+
+NAME="shinken"
+
+AVAIL_MODULES="scheduler poller reactionner broker receiver arbiter"
+
+## SHINKEN_MODULE_FILE is set by shinken-* if it's one of these that's calling us.
+if [ -z "$SHINKEN_MODULE_FILE" ]; then
+ SCRIPTNAME=$0
+ _usage_mods_="[ <$AVAIL_MODULES> ]"
+else
+ SCRIPTNAME=$SHINKEN_MODULE_FILE
+fi
+
+curpath=$(cd $(dirname "$0") && pwd)
+#echo curpath is $curpath filename is $(basename "$0")
+
+## Default paths:
+test "$BIN" || BIN=$(cd $curpath/.. && pwd)
+test "$VAR" || VAR=$(cd $curpath/../../var && pwd)
+test "$ETC" || ETC=$(cd $curpath/../../etc && pwd)
+
+export PATH="${PATH:+$PATH:}/usr/sbin:/bin:/sbin"
+export LANG=en_US.UTF8
+export PYTHONIOENCODING=utf8
+
+# We try to find the LAST possible Python VERSION
+pythonver() {
+ versions="2.4 2.5 2.6 2.7"
+ LASTFOUND=""
+ # Is there any python here?
+ for v in $versions
+ do
+ which python$v > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ LASTFOUND="python$v"
+ fi
+ done
+ if [ -z "$LASTFOUND" ]
+ then
+ # Finaly try to find a default python
+ which python > /dev/null 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "No python interpreter found!"
+ exit 2
+ else
+ echo "python found"
+ LASTFOUND=$(which python)
+ fi
+ fi
+ PYTHON=$LASTFOUND
+}
+
+# Ok, go search this Python version
+pythonver
+
+# Uncomment the line below if you got the **lib** shinken installed
+# on a non standard place (not in /usr/lib/python*)
+#export PYTHONPATH="${PATH:+$PATH:}/opt/shinken"
+# Or uncommentif you want to force the Python version
+#export PYTHON=python2.7
+
+# default
+DEBUG=false
+CMD=""
+SUBMODULES=""
+
+## This permits to overhidde the default "default shinken cfg file":
+[ -z "$SHINKEN_DEFAULT_FILE" ] && SHINKEN_DEFAULT_FILE="/etc/default/$NAME"
+## so you can now do:
+## bash -c "SHINKEN_DEFAULT_FILE=$your_own_default_file $init_path/shinken $action $args"
+## to easily use your own config
+
+#echo "Using $SHINKEN_DEFAULT_FILE .."
+
+
+
+usage() {
+ cat << END
+Usage: $SCRIPTNAME [ -d ] {start|stop|restart|status|check} $_usage_mods_
+
+ -d start requested module(s) in debug mode, only useful with start|restart
+
+END
+}
+
+if [ "$1" = "-d" ]; then
+ DEBUG="1"
+ shift
+fi
+
+if [ $# -eq 0 ]; then
+ usage >&2
+ exit 2
+fi
+
+CMD=$1
+shift
+SUBMODULES=$*
+
+if [ -z "$SUBMODULES" ]; then
+ SUBMODULES=$AVAIL_MODULES
+else
+ # check given modules
+ for mod1 in $SUBMODULES; do
+ found=0
+ for mod2 in $AVAIL_MODULES; do
+ [ $mod1 = $mod2 ] && found=1;
+ done
+ [ $found = 0 ] && { usage >&2 ; exit 2 ; }
+ done
+fi
+
+
+# Reads configuration variable file if it is present
+[ -r "$SHINKEN_DEFAULT_FILE" ] && . "$SHINKEN_DEFAULT_FILE"
+
+
+# Now look if some required variables are pre defined:
+if ! test "$SHINKENCFG"
+then
+ SHINKENCFG="$ETC/nagios.cfg"
+fi
+if ! test "$SHINKENSPECIFICCFG"
+then
+ SHINKENSPECIFICCFG="$ETC/shinken-specific.cfg"
+fi
+
+# If var or run dir is missing, create them and chown them
+[ ! -d $VAR ] && mkdir -p $VAR && chown $SHINKENUSER:$SHINKENGROUP $VAR
+[ ! -d $RUN ] && mkdir -p $RUN && chown $SHINKENUSER:$SHINKENGROUP $RUN
+
+# Now place us in our var directory so even our arbiter will be
+# happy for opening its pid and cmd files
+cd $VAR
+
+#echo BIN=$BIN
+#echo VAR=$VAR
+#echo ETC=$ETC
+
+#set -xv
+
+
+echo_success() {
+ log_end_msg 0 $*
+}
+
+echo_failure() {
+ log_end_msg 1 $*
+}
+
+#log_end_msg
+
+
+# Load the VERBOSE setting and other rcS variables
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+
+# Source function library.
+[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
+
+[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions
+
+
+
+################################################
+
+#
+# returns the pid for a submodule
+#
+
+getpidfile() {
+ mod="$1"
+ modPIDVAR=$(echo $mod | tr 'a-z' 'A-Z')"PID"
+ pidfile=$(echo $(eval echo \${$modPIDVAR}))
+ if test "$pidfile"
+ then
+ echo "$pidfile"
+ else
+ echo "$RUN/${mod}d.pid"
+ fi
+}
+
+getmodpid() {
+ mod=$1
+ pidfile=$(getpidfile "$mod")
+ if [ -s $pidfile ]; then
+ cat $pidfile
+ fi
+}
+
+
+getdebugfile() {
+ mod="$1"
+ modDEBUG=$(echo $mod | tr 'a-z' 'A-Z')"DEBUGFILE"
+ debugfile=$(echo $(eval echo \${$modDEBUG}))
+ if test "$debugfile"
+ then
+ echo "$debugfile"
+ else
+ echo "${VAR}/${mod}-debug.log"
+ fi
+}
+
+#
+# Display status
+#
+do_status() {
+ mod=$1
+ pidfile=$(getpidfile "$mod")
+ [ -e "$pidfile" ] || {
+ echo "$mod NOT RUNNING (pidfile ($pidfile) not exist)"
+ return 3
+ }
+ [ -r "$pidfile" ] || {
+ echo "$mod NOT RUNNING (pidfile ($pidfile) unreadable)"
+ return 3
+ }
+ pid=$(cat "$pidfile")
+ if [ -z "$pid" ]; then
+ echo "$mod NOT RUNNING (pid file empty)"
+ return 4
+ fi
+ ps -p "$pid" >/dev/null 2>&1
+ rc=$?
+ if [ $rc != 0 ]; then
+ log_failure_msg "$mod NOT RUNNING (process $pid doesn't exist?)"
+ return 1
+ fi
+ echo "$mod RUNNING (pid $pid)"
+ return 0
+}
+
+#
+# starts our modules
+#
+do_start() {
+ mod=$1
+ modfilepath="$BIN/shinken-${mod}"
+ [ -e "$modfilepath" ] || {
+ log_failure_msg "FAILED: did not found $mod file ($modfilepath) ; are you sure shinken-$mod is installed?"
+ return 5
+ }
+ [ "$DEBUG" = 1 ] && DEBUGCMD="--debug "$(getdebugfile "$mod")
+ # Skonf need skonf.cfg, arbiter nagios.cfg, and the other OTHERd.ini
+ if [ "$mod" = 'skonf' ]; then
+ output=$("$modfilepath" -d -c "$SKONFCFG" $DEBUGCMD 2>&1)
+ rc=$?
+ elif [ "$mod" != "arbiter" ]; then
+ output=$("$modfilepath" -d -c "$ETC/${mod}d.ini" $DEBUGCMD 2>&1)
+ rc=$?
+ else
+ output=$("$modfilepath" -d -c "$SHINKENCFG" -c "$SHINKENSPECIFICCFG" $DEBUGCMD 2>&1)
+ rc=$?
+ fi
+ # debug:
+ #resfile="/tmp/bad_start_for_$mod"
+ #echo "$output" > "$resfile" || true
+ if [ $rc != 0 ]; then
+ resfile="/tmp/bad_start_for_$mod"
+ echo "$output" > "$resfile" || true
+ output=$(echo "$output" | tail -1)
+ echo "FAILED: $output (full output is in $resfile)"
+ return 1
+ fi
+ echo "OK"
+ return 0
+}
+
+#
+# stops modules
+#
+do_stop() {
+ mod=$1
+ pid=$(getmodpid "$mod")
+ statusoutput=$(do_status "$mod")
+ [ $? -ne 0 ] && {
+ echo "$statusoutput"
+ return 0
+ }
+ if [ ! -z "$pid" ]; then
+ kill "$pid"
+ sleep 0.5
+ ## TODO: instead of 'sleep 1': wait up to when pid file is removed (with timeout)?
+ for i in 1 2 3
+ do
+ # TODO: use a better way to get the children pids..
+ allpids="$(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}')"
+ if [ -z "$allpids" ]; then
+ echo "OK"
+ return 0
+ fi
+ sleep 1
+ done
+ echo "there are still remaining processes to $mod running.. ; trying to kill them (SIGTERM).."
+ allpids="$(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}')"
+ for cpid in $(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}'); do
+ kill $cpid > /dev/null 2>&1
+ done
+ for i in 1 2 3
+ do
+ # TODO: eventually use a better way to get the children pids..
+ allpids="$(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}')"
+ if [ -z "$allpids" ]; then
+ echo "OK"
+ return 0
+ fi
+ sleep 1
+ done
+ echo "there are still remaining processes to $mod running.. ; trying to kill -9 them.."
+ allpids="$(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}')"
+ for cpid in $(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}'); do
+ kill -9 $cpid > /dev/null 2>&1
+ done
+ sleep 1
+ allpids="$(ps -aef | grep "$pid" | grep "shinken-$mod" | awk '{print $2}')"
+ if [ ! -z "$allpids" ]; then
+ echo "FAILED: one or more process for $mod are still running after kill -9!"
+ echo "Remaining processes are (pids="$allpids"):"
+ ps -lf $(for p in $allpids ; do echo -n "-p$p " ; done)
+ echo "You should check this."
+ return 1
+ fi
+ echo "OK"
+ else
+ echo "NOT RUNNING"
+ fi
+ return 0
+}
+
+#
+# does the config check
+#
+do_check() {
+ [ "$DEBUG" = 1 ] && DEBUGCMD="--debug $VAR/${mod}-debug.log"
+ "$BIN/shinken-arbiter" -v -c "$ETC/nagios.cfg" -c "$ETC/shinken-specific.cfg" $DEBUGCMD 2>&1
+ return $?
+}
+
+
+############################
+
+do_start_() {
+ echo "Starting $1: "
+ status=$(do_status "$1")
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ log_warning_msg "Already running"
+ return
+ fi
+ if test "$1" = "arbiter"
+ then
+ # arbiter is special:
+ # it doesn't actually declare a "workdir" properties in its config
+ # so we have explicitely to cd to the "VAR" directory.
+ # so that the default pidfile ( == nagios lock_file) which is now "arbiterd.pid"
+ # will be created at the correct place.
+ cd "$VAR"
+ # TODO: check if other possibility wouldn't be better:
+ # declare a "workdir" properties for the arbiter module definition.. in shinken-specific.cfg.
+ # but if the lock_file path is absolute then this 'cd' isn't required.
+ fi
+ startoutput=$(do_start "$1")
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo_success
+ else
+ echo "$startoutput"
+ echo_failure
+ fi
+ return $rc
+}
+
+do_stop_() {
+ echo "Stopping $1"
+ statusoutput=$(do_status "$1")
+ rc=$?
+ if [ $rc -ne 0 ]; then
+ failuremsg="Couldn't get status of $1: $statusoutput"
+ else
+ stopoutput=$(do_stop "$1" 2>&1)
+ rc=$?
+ [ $rc -ne 0 ] && failuremsg="Couldn't stop $1: $stopoutput"
+ fi
+ if [ $rc -ne 0 ]; then
+ log_failure_msg "$failuremsg"
+ echo_failure
+ else
+ echo_success
+ fi
+ return $rc
+}
+
+do_restart_() {
+ mod="$1"
+ echo "Restarting $mod"
+ if [ "$mod" = "arbiter" ]; then
+ do_check_ "$mod"
+ checkrc=$?
+ if [ $checkrc -ne 0 ]; then
+ return 1
+ fi
+ fi
+ stopoutput=$(do_stop "$mod")
+ startoutput=$(do_start "$mod")
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo_success
+ else
+ log_failure_msg "$startoutput"
+ echo_failure
+ fi
+ return $rc
+}
+
+do_reload_() {
+ mod="$1"
+ echo "Reloading $mod"
+ if [ "$mod" = "arbiter" ]; then
+ do_check_ "$mod"
+ checkrc=$?
+ if [ $checkrc -ne 0 ]; then
+ return 1
+ fi
+ fi
+ stopoutput=$(do_stop "$mod")
+ startoutput=$(do_start "$mod")
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo_success
+ else
+ log_failure_msg "$startoutput"
+ echo_failure
+ fi
+ return $rc
+}
+
+do_status_() {
+ mod=$1
+ echo "Checking status of $mod"
+ do_status "$1"
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo_success
+ else
+ echo_failure
+ fi
+
+}
+
+do_check_() {
+ echo "Doing config check"
+ output=$(do_check "$1" 2>&1)
+ rc=$?
+ if [ $rc -eq 0 ]; then
+ echo_success
+ else
+ check_res_file=$(mktemp /tmp/shinken_checkconfig_resultXXXXXXXX)
+ echo "$output" > "$check_res_file"
+ mv $check_res_file /tmp/shinken_checkconfig_result
+ check_res_file="/tmp/shinken_checkconfig_result"
+ output=$(echo "$output" | tail -1)
+ log_warning_msg "full result is in ${check_res_file}"
+ log_failure_msg "ConfigCheck failed: $output"
+ echo_failure
+ fi
+ return $rc
+}
+do_checkconfig_() { do_check_ "$1" ; }
+
+
+############################
+
+do_cmd_on() {
+ action=$1
+ mods=$2
+ for mod in $mods
+ do
+ do_${action}_ "$mod"
+ done
+}
+
+
+############################
+## Main:
+
+case "$CMD" in
+ start|stop|restart|status)
+ do_cmd_on "$CMD" "$SUBMODULES"
+ ;;
+ check|checkconfig|reload)
+ do_cmd_on "$CMD" "arbiter"
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+esac
+
diff --git a/files/centos/shinken-arbiter b/files/centos/shinken-arbiter
new file mode 100755
index 0000000..02ca504
--- /dev/null
+++ b/files/centos/shinken-arbiter
@@ -0,0 +1,50 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-arbiter
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken arbiter daemon
+# Description: Shinken is a monitoring tool and the Arbiter
+# is one of its daemon. This one reads the configuration,
+# cuts it into parts and dispatches it. Then it waits
+# for orders from the users to dispatch them too.
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-arbiter"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ arbiter
+
+exit $?
+
diff --git a/files/centos/shinken-broker b/files/centos/shinken-broker
new file mode 100755
index 0000000..b92f0ad
--- /dev/null
+++ b/files/centos/shinken-broker
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-broker
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken broker daemon
+# Description: Shinken is a monitoring tool and the Broker
+# is one of its daemon. This one gets the configuration from the arbiter
+# His purpose is to get the broks from the schedulers specified in the
+# configuration
+### END INIT INFO
+
+### BEGIN INIT INFO Redhat
+# Shinken Starts Shinken Broker
+#
+# chkconfig: 345 99 01
+# description: Start Shinken broker daemon
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-broker"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ broker
+
+exit $?
diff --git a/files/centos/shinken-poller b/files/centos/shinken-poller
new file mode 100755
index 0000000..04a6cfa
--- /dev/null
+++ b/files/centos/shinken-poller
@@ -0,0 +1,57 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-poller
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken poller daemon
+# Description: Shinken is a monitoring tool and the Poller
+# is one of its daemon. This one gets the configuration from the arbiter
+# His purpose is to actually do the checks ordered by the schedulers,
+# and then sends the results to the schedulers specified in the
+# configuration
+### END INIT INFO
+
+### BEGIN INIT INFO Redhat
+# Shinken Starts Shinken Poller
+#
+# chkconfig: 345 99 01
+# description: Start Shinken poller daemon
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-poller"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ poller
+
+exit $?
diff --git a/files/centos/shinken-reactionner b/files/centos/shinken-reactionner
new file mode 100755
index 0000000..db29e3e
--- /dev/null
+++ b/files/centos/shinken-reactionner
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-reactionner
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken reactionner daemon
+# Description: Shinken is a monitoring tool and the Reactionner
+# is one of its daemon. This one gets the configuration from the arbiter
+# His purpose is to get the actually do the actions like sending an email
+# ordered by the schedulers specified in the configuration
+### END INIT INFO
+
+### BEGIN INIT INFO Redhat
+# Shinken Starts Shinken Reactionner
+#
+# chkconfig: 345 99 01
+# description: Start Shinken reactionner daemon
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-reactionner"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ reactionner
+
+exit $?
diff --git a/files/centos/shinken-receiver b/files/centos/shinken-receiver
new file mode 100755
index 0000000..e7b8b5f
--- /dev/null
+++ b/files/centos/shinken-receiver
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-receiver
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken receiver daemon
+# Description: Shinken is a monitoring tool and the Receiver
+# is one of its daemon. This one gets the configuration from the arbiter
+# His purpose is to get the broks from the schedulers specified in the
+# configuration
+### END INIT INFO
+
+### BEGIN INIT INFO Redhat
+# Shinken Starts Shinken Receiver
+#
+# chkconfig: 345 99 01
+# description: Start Shinken receiver daemon
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-receiver"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ receiver
+
+exit $?
diff --git a/files/centos/shinken-scheduler b/files/centos/shinken-scheduler
new file mode 100755
index 0000000..5af33ff
--- /dev/null
+++ b/files/centos/shinken-scheduler
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# Copyright (C) 2009-2011:
+# Gabes Jean, naparuba@gmail.com
+# Gerhard Lausser, Gerhard.Lausser@consol.de
+# Gregory Starck, g.starck@gmail.com
+# Hartmut Goebel, h.goebel@goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken. If not, see .
+
+### BEGIN INIT INFO
+# Provides: shinken-scheduler
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Shinken scheduler daemon
+# Description: Shinken is a monitoring tool and the Scheduler
+# is one of its daemon. This one get configuration from the arbiter
+# His purpose is only to schedule do the checks and actions specified
+# in the configuration received from the arbiter
+### END INIT INFO
+
+### BEGIN INIT INFO Redhat
+# Shinken Starts Shinken Scheduler
+#
+# chkconfig: 345 99 01
+# description: Start Shinken scheduler daemon
+### END INIT INFO
+
+# Author: Gabes Jean
+# Olivier LI-KIANG-CHEONG
+
+
+NAME="shinken-scheduler"
+
+curdir=$(dirname "$0")
+
+export SHINKEN_MODULE_FILE="$NAME" ## for 'shinken' init script to see that it's called by us
+
+"$curdir/shinken" $@ scheduler
+
+exit $?
diff --git a/files/default/resource.cfg b/files/default/resource.cfg
new file mode 100644
index 0000000..bbddef1
--- /dev/null
+++ b/files/default/resource.cfg
@@ -0,0 +1,35 @@
+#
+# This file is managed by Chef. Local modifications will be overwritten.
+#
+$USER1$=/usr/lib/shinken/plugins
+$USER2$=public
+
+#-- Location of the plugins
+$PLUGINSDIR$=/usr/lib64/nagios/plugins
+
+#- Active Directory and LDAP
+$DOMAINUSER$=shinken_user
+$DOMAINPASSWORD$=superpassword
+$LDAPBASE$=dc=eu,dc=society,dc=com
+
+#- MSSQL credentials
+$MSSQLUSER$=someuser
+$MSSQLPASSWORD$=somepassowrd
+
+#-- Mysql credentials
+$MYSQLUSER$=root
+$MYSQLPASSWORD$=root
+
+#-- vSphere (ESX) credentials
+$VCENTER$=vcenter.mydomain.com
+$VCENTERLOGIN$=someuser
+$VCENTERPASSWORD$=somepassowrd
+
+
+#-- Discovery
+# default snmp community
+$SNMPCOMMUNITYREAD$=PUBLIC
+# what to discover by default
+$NMAPTARGETS$=localhost www.google.fr
+
+
diff --git a/files/default/xmppsend b/files/default/xmppsend
new file mode 100755
index 0000000..0b07e98
--- /dev/null
+++ b/files/default/xmppsend
@@ -0,0 +1,78 @@
+#!/usr/bin/python -tt
+#
+# This file is managed by Chef. Local modifications will be overwritten.
+#
+# skvidal@fedoraproject.org, modified by Andrea Veri
+# gplv2+
+
+#nagios definition
+## 'host-notify-by-jabber' command definition
+#define command{
+# command_name host-notify-by-jabber
+# command_line /usr/local/bin/xmppsend -a config.ini "Host '$HOSTALIAS$' is $HOSTSTATE$ - Info : $HOSTOUTPUT$" $CONTACTPAGER$
+# }
+#
+## 'notify-by-jabber' command definition
+#define command{
+# command_name notify-by-jabber
+# command_line /usr/local/bin/xmppsend -a config.ini "$NOTIFICATIONTYPE$ $HOSTNAME$ $SERVICEDESC$ $SERVICESTATE$ $SERVICEOUTPUT$ $LONGDATETIME$" $CONTACTPAGER$
+# }
+#
+
+import warnings
+warnings.simplefilter("ignore")
+
+import xmpp
+from xmpp.protocol import Message
+
+from optparse import OptionParser
+import ConfigParser
+import sys
+import os
+
+parser = OptionParser()
+parser.add_option("-a", dest="authfile", default=None, help="file to retrieve username/password information from")
+opts, args = parser.parse_args()
+
+conf = ConfigParser.ConfigParser()
+if not opts.authfile or not os.path.exists(opts.authfile):
+ print "no config/auth file specified, can't continue"
+ sys.exit(1)
+
+conf.read(opts.authfile)
+if not conf.has_section('xmpp_nagios') or not conf.has_option('xmpp_nagios', 'username') or not conf.has_option('xmpp_nagios', 'password'):
+ print "cannot find at least one of: config section 'xmpp_nagios' or username or password"
+ sys.exit(1)
+
+username = conf.get('xmpp_nagios', 'username')
+password = conf.get('xmpp_nagios', 'password')
+domain = conf.get('xmpp_nagios', 'domain')
+server = conf.get('xmpp_nagios', 'server')
+port = conf.get('xmpp_nagios', 'port')
+
+if len(args) < 1:
+ print "xmppsend message [to whom, multiple args]"
+ sys.exit(1)
+
+msg = args[0]
+
+msg = msg.replace('\\n', '\n')
+
+# Connect to the server
+c = xmpp.Client(domain)
+c.connect( ( server, port ) )
+
+# Authenticate to the server
+jid = xmpp.protocol.JID( username )
+c.auth( jid.getNode( ), password )
+
+if len(args) < 2:
+ r = c.getRoster()
+ for user in r.keys():
+ if user == username:
+ continue
+ c.send(Message(user, '%s' % msg))
+else:
+ for user in args[1:]:
+ c.send(Message(user, '%s' % msg))
+
diff --git a/metadata.rb b/metadata.rb
index 5e0a111..0f7712b 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -3,8 +3,10 @@
license "MIT"
description "Installs/Configures shinken"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "1.0.0"
+version "2.0.0"
depends "apt"
depends "nginx"
-
+depends "mongodb", ">= 0.12"
+depends "python"
+depends "yum"
diff --git a/providers/command.rb b/providers/command.rb
index 93df404..29cfcb0 100644
--- a/providers/command.rb
+++ b/providers/command.rb
@@ -2,6 +2,7 @@
template "shinken/arbiter/commands/#{new_resource.command_identifier}" do
path full_path
source "definitions/commands/command.cfg.erb"
+ mode 00644
variables({
:command_name => new_resource.command_identifier,
diff --git a/providers/contact.rb b/providers/contact.rb
index ef0bce3..5029c53 100644
--- a/providers/contact.rb
+++ b/providers/contact.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}contacts/#{new_resource.contact_key}" do
path full_path
source "definitions/contacts/contact.cfg.erb"
+ mode 00644
variables({
:contact_key => new_resource.contact_key,
diff --git a/providers/contactgroup.rb b/providers/contactgroup.rb
new file mode 100644
index 0000000..5000e6a
--- /dev/null
+++ b/providers/contactgroup.rb
@@ -0,0 +1,54 @@
+action :create do
+
+ template "shinken/arbiter/#{template? ? "templates/": ""}contactgroups/#{new_resource.contactgroup_key}" do
+ path full_path
+ source "definitions/contactgroups/contactgroup.cfg.erb"
+ mode 00644
+
+ variables({
+ :contactgroup_key => new_resource.contactgroup_key,
+ :contactgroup_name => new_resource.contactgroup_name,
+ :contactgroup_alias => new_resource.contactgroup_alias,
+ :members => new_resource.members,
+ :realm => new_resource.realm,
+
+ :register => new_resource.register,
+ :use => new_resource.use
+ })
+
+ action :create
+ notifies :restart, "service[shinken-arbiter]", :delayed
+ end
+
+ node.run_state["shinken"]["arbiter"]["contactgroups"].push(path)
+end
+
+action :delete do
+ file full_path do
+ action :delete
+ end
+end
+
+def template?
+ not new_resource.register
+end
+
+def path
+ paths = ["contactgroups", "#{new_resource.contactgroup_key}.cfg"]
+ paths.unshift("templates") if not new_resource.register
+ ::File.join(paths)
+end
+
+def full_path
+ ::File.join("/etc/shinken/objects-chef", path)
+end
+
+def contactgroup_path
+ paths = ["contactgroups", new_resource.contactgroup_key]
+ paths.unshift("templates") if not new_resource.register
+ ::File.join(paths)
+end
+
+def full_contactgroup_path
+ ::File.join("/etc/shinken/objects-chef", contactgroup_path)
+end
diff --git a/providers/daemon.rb b/providers/daemon.rb
index 54f9a71..c020b82 100644
--- a/providers/daemon.rb
+++ b/providers/daemon.rb
@@ -1,12 +1,13 @@
action :create do
template "shinken/specific/daemon/#{new_resource.name}" do
path full_path
-
source "arbiter/daemon.cfg.erb"
+ mode 00644
variables({
"daemon_type" => new_resource.daemon_type,
"variables" => new_resource.variables,
+ "modules" => new_resource.modules,
"address" => new_resource.address,
"port" => new_resource.port,
"name" => new_resource.name
diff --git a/providers/escalation.rb b/providers/escalation.rb
new file mode 100644
index 0000000..eb57608
--- /dev/null
+++ b/providers/escalation.rb
@@ -0,0 +1,70 @@
+action :create do
+
+ # if not template?
+ # command = shinken_command "shinken/arbiter/escalations/#{new_resource.escalation_key}/command" do
+ # command_name new_resource.check_command
+ # command new_resource.command_line
+ # arguments new_resource.arguments
+ # end
+ # Chef::Log.info(command.command_identifier)
+ # end
+
+
+ template "shinken/arbiter/escalations/#{new_resource.escalation_key}" do
+ path full_path
+ source "definitions/escalations/escalation.cfg.erb"
+ mode 00644
+
+ vars = {
+ :escalation_key => new_resource.escalation_key,
+
+ :first_notification => new_resource.first_notification,
+ :last_notification => new_resource.last_notification,
+ :first_notification_time => new_resource.first_notification_time,
+ :last_notification_time => new_resource.last_notification_time,
+
+ :notification_interval => new_resource.notification_interval,
+ :escalation_period => new_resource.escalation_period,
+ :escalation_options => new_resource.escalation_options,
+ :contacts => new_resource.contacts,
+ :contact_groups => new_resource.contact_groups#,
+
+# :register => new_resource.register,
+# :use => new_resource.use
+ }
+# vars.update({
+# :check_command => command
+# }) if not command.nil?
+
+
+ variables(vars)
+
+ action :create
+ notifies :restart, "service[shinken-arbiter]", :delayed
+ end
+
+ node.run_state["shinken"]["arbiter"]["escalations"].push(path)
+end
+
+action :delete do
+ file full_path do
+ action :delete
+ end
+end
+
+#def template?
+# not new_resource.register
+#end
+
+def path
+ ::File.join("escalations", "#{new_resource.escalation_key}.cfg")
+# paths = ["escalations"]
+# paths.push(new_resource.host_name) if new_resource.host_name
+# paths.push("#{new_resource.escalation_key}.cfg")
+# paths.unshift("templates") if not new_resource.register
+# ::File.join(paths)
+end
+
+def full_path
+ ::File.join("/etc/shinken/objects-chef", path)
+end
diff --git a/providers/host.rb b/providers/host.rb
index 6535359..7431b3b 100644
--- a/providers/host.rb
+++ b/providers/host.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}hosts/#{new_resource.host_key}" do
path full_path
source "definitions/hosts/host.cfg.erb"
+ mode 00644
variables({
:host_key => new_resource.host_key,
@@ -18,6 +19,7 @@
:check_interval => new_resource.check_interval,
:active_checks_enabled => new_resource.active_checks_enabled,
:check_period => new_resource.check_period,
+ :contacts => new_resource.contacts,
:contact_groups => new_resource.contact_groups,
:notification_interval => new_resource.notification_interval,
:notification_period => new_resource.notification_period,
@@ -26,6 +28,13 @@
:event_handler_enabled => new_resource.event_handler_enabled,
:flap_detection_enabled => new_resource.flap_detection_enabled,
:process_perf_data => new_resource.process_perf_data,
+ :notes => new_resource.notes,
+ :notes_url => new_resource.notes_url,
+ :action_url => new_resource.action_url,
+ :icon_image => new_resource.icon_image,
+ :icon_image_alt => new_resource.icon_image_alt,
+ :poller_tag => new_resource.poller_tag,
+ :escalations => new_resource.escalations,
:use => new_resource.use
})
diff --git a/providers/hostgroup.rb b/providers/hostgroup.rb
index ed27778..ffd7d77 100644
--- a/providers/hostgroup.rb
+++ b/providers/hostgroup.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}hostgroups/#{new_resource.hostgroup_key}" do
path full_path
source "definitions/hostgroups/hostgroup.cfg.erb"
+ mode 00644
variables({
:hostgroup_key => new_resource.hostgroup_key,
diff --git a/providers/module.rb b/providers/module.rb
index 4e4ff41..66bcad9 100644
--- a/providers/module.rb
+++ b/providers/module.rb
@@ -1,8 +1,8 @@
action :create do
template "shinken/specific/module/#{new_resource.name}" do
path full_path
-
source "arbiter/module.cfg.erb"
+ mode 00644
variables({
"module_type" => new_resource.module_type,
diff --git a/providers/notificationway.rb b/providers/notificationway.rb
index b4ef128..0fe9f6c 100644
--- a/providers/notificationway.rb
+++ b/providers/notificationway.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}notificationway/#{new_resource.notificationway_name}" do
path full_path
source "definitions/notificationways/notificationway.cfg.erb"
+ mode 00644
variables({
:notificationway_name => new_resource.notificationway_name,
diff --git a/providers/service.rb b/providers/service.rb
index 08748ae..ed599b0 100644
--- a/providers/service.rb
+++ b/providers/service.rb
@@ -2,7 +2,8 @@
if not template?
command = shinken_command "shinken/arbiter/services/#{new_resource.service_key}/command" do
- command new_resource.check_command
+ command_name new_resource.check_command
+ command new_resource.command_line
arguments new_resource.arguments
end
Chef::Log.info(command.command_identifier)
@@ -12,6 +13,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}services/#{new_resource.service_key}" do
path full_path
source "definitions/services/service.cfg.erb"
+ mode 00644
vars = {
:service_key => new_resource.service_key,
@@ -54,10 +56,12 @@
:action_url => new_resource.action_url,
:icon_image => new_resource.icon_image,
:icon_image_alt => new_resource.icon_image_alt,
-
+ :escalations => new_resource.escalations,
+ :service_dependencies => new_resource.service_dependencies,
+ :business_impact => new_resource.business_impact,
:register => new_resource.register,
- :use => ((not template?) ? ["base-service"]:[]) + new_resource.use
+ :use => new_resource.use
}
vars.update({
:check_command => command
diff --git a/providers/servicegroup.rb b/providers/servicegroup.rb
index 7e2beb3..dbd3582 100644
--- a/providers/servicegroup.rb
+++ b/providers/servicegroup.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}servicegroups/#{new_resource.servicegroup_key}" do
path full_path
source "definitions/servicegroups/servicegroup.cfg.erb"
+ mode 00644
variables({
:servicegroup_key => new_resource.servicegroup_key,
diff --git a/providers/timeperiod.rb b/providers/timeperiod.rb
index 6125fef..177ddbb 100644
--- a/providers/timeperiod.rb
+++ b/providers/timeperiod.rb
@@ -3,6 +3,7 @@
template "shinken/arbiter/#{template? ? "templates/": ""}timeperiods/#{new_resource.timeperiod_key}" do
path full_path
source "definitions/timeperiods/timeperiod.cfg.erb"
+ mode 00644
variables({
:timeperiod_key => new_resource.timeperiod_key,
diff --git a/recipes/arbiter-contacts.rb b/recipes/arbiter-contacts.rb
index ddd350e..a7e40a2 100644
--- a/recipes/arbiter-contacts.rb
+++ b/recipes/arbiter-contacts.rb
@@ -44,8 +44,14 @@
path "/etc/shinken/objects-chef/templates/contacts"
end
+directory "shinken/arbiter/contactgroups" do
+ path "/etc/shinken/objects-chef/contactgroups"
+end
+
### Save content through run
node.run_state["shinken"]["arbiter"]["contacts"] = []
+node.run_state["shinken"]["arbiter"]["contactgroups"] = []
+contactgroups = ["all"]
# We'll now populate contacts with real content
search(:shinken_contact_templates, "*:*") do |n|
@@ -60,19 +66,53 @@
end
end
-search(:users, "*:*") do |c|
+search(:shinken_contacts, "*:*") do |n|
+ # we'll use shinken_host LWRP to define host
+ shinken_contact n["id"] do
+
+ contact_name n["id"]
+ contact_alias n["comment"]
+ email n["email"]
+ contactgroups "#{n["groups"].join(',')}"
+ n["groups"].each do |group|
+ if !contactgroups.include?(group)
+ contactgroups << group
+ end
+ end
+
+ (n["shinken"]|| {}).delete_if{|k,v| k == "id"}.each_pair do |k,v|
+ self.send k, v
+ end
+
+ if n.has_key?("use")
+ use n["use"]
+ else
+ use ["generic-contact"]
+ end
+ end
+end
+
+search(:users, "nagios:* AND NOT action:remove") do |c|
shinken_contact c["id"] do
register true
contact_name c["id"]
- contact_alias c["name"]
- email c["mail"]
+ contact_alias c["comment"]
+ email c["nagios"]["email"]
+ pager c["nagios"]["pager"] if c["nagios"].has_key?("pager")
+
+ contactgroups "#{c["groups"].join(',')}"
+ c["groups"].each do |group|
+ if !contactgroups.include?(group)
+ contactgroups << group
+ end
+ end
(c["shinken"]|| {}).delete_if{|k,v| k == "id"}.each_pair do |k,v|
self.send k, v
end
- if c["admin"] == true
+ if c["groups"].include?("sysadmin")
if c["oncall"] == true
use ["oncall", "admin"]
else
@@ -84,5 +124,9 @@
end
end
-
-
+contactgroups.each do |group|
+ shinken_contactgroup group do
+ contactgroup_name group
+ contactgroup_alias group
+ end
+end
diff --git a/recipes/arbiter-escalations.rb b/recipes/arbiter-escalations.rb
new file mode 100644
index 0000000..7801248
--- /dev/null
+++ b/recipes/arbiter-escalations.rb
@@ -0,0 +1,55 @@
+#
+# Cookbook Name:: shinken
+# Recipe:: arbiter-escalations
+#
+# Copyright 2013, Arthur Gautier
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+## Notificationway definition drop
+# This recipe will drop escalations definitions and register them in a main file
+
+### Include shinken-arbiter recipe
+# See [shinken::arbiter](arbiter.html)
+
+include_recipe "shinken::arbiter"
+
+### Layout
+#### Directories
+#
+# we'll use ``/etc/shinken/objects-chef/escalations`` and put subfiles in this
+directory "shinken/arbiter/escalations" do
+ path "/etc/shinken/objects-chef/escalations"
+end
+
+### Save content through run
+node.run_state["shinken"]["arbiter"]["escalations"] = []
+
+
+# We'll now populate escalations with real content
+search(:shinken_escalations, "*:*") do |n|
+ # we'll use shinken_escalation LWRP to define escalation
+ shinken_escalation n["id"] do
+ n.delete_if{|k, v| k == "id"}.each_pair do |k, v|
+ self.send k, v
+ end
+ end
+end
diff --git a/recipes/arbiter-hostgroups.rb b/recipes/arbiter-hostgroups.rb
index 3ef9016..00e39df 100644
--- a/recipes/arbiter-hostgroups.rb
+++ b/recipes/arbiter-hostgroups.rb
@@ -43,6 +43,19 @@
### Save content through run
node.run_state["shinken"]["arbiter"]["hostgroups"] = []
+# find roles and create hostgroup for each role
+hostgroups = Array.new
+
+search(:role, "*:*") do |r|
+ hostgroups << r.name
+end
+
+hostgroups.sort.each do |hg|
+ shinken_hostgroup hg do
+ hostgroup_name hg
+ hostgroup_alias hg
+ end
+end
# We'll now populate hostgroups with real content
search(:shinken_hostgroups, "*:*") do |n|
@@ -53,6 +66,3 @@
end
end
end
-
-
-
diff --git a/recipes/arbiter-hosts.rb b/recipes/arbiter-hosts.rb
index 9f83b08..fe6a947 100644
--- a/recipes/arbiter-hosts.rb
+++ b/recipes/arbiter-hosts.rb
@@ -52,34 +52,72 @@
node.run_state["shinken"]["arbiter"]["hosts"] = []
### Populate
-# We'll now populate hosts with real content
-search(:node, "monitoring:*") do |n|
+# Templates first
+host_templates = search(:shinken_host_templates, "*:*")
+host_templates.sort! {|a,b| a.name <=> b.name }
+
+host_templates.each do |n|
# we'll use shinken_host LWRP to define host
- shinken_host n["fqdn"] do
- host_name n["fqdn"]
- address n["fqdn"]
- (n["monitoring"]["host_definition"]||{}).each_pair do |k, v|
+ shinken_host n["id"] do
+ # We wont register templates
+ register false
+
+ n.delete_if{|k, v| k == "id"}.each_pair do |k, v|
self.send k, v
end
- if (n["monitoring"]["host_definition"]|| {})["use"].nil?
- use ["generic-host"]
- end
end
end
+# sort the hosts to prevent extra reloads
+nodes = search(:node, "roles:monitoring")
+nodes.sort! {|a,b| a.name <=> b.name }
+
# We'll now populate hosts with real content
-search(:shinken_host_templates, "*:*") do |n|
+nodes.each do |n|
# we'll use shinken_host LWRP to define host
- shinken_host n["id"] do
- # We wont register templates
- register false
+ shinken_host n["hostname"] do
+ host_name n["hostname"]
+ address n["ipaddress"]
+ host_alias n["fqdn"]
+ if n["virtualization"].has_key?("role")
+ hostgroups ["+#{n['os']}","#{n['virtualization']['system']}-#{n['virtualization']['role']}",n['roles'].join(",")]
+ else
+ hostgroups ["+#{n['os']}",n['roles'].join(",")]
+ end
- n.delete_if{|k, v| k == "id"}.each_pair do |k, v|
- self.send k, v
+ # setup automatic poller tags
+ if node["shinken"]["auto_poller_tags"]
+ if n.has_key?("shinken") and n["shinken"].has_key?("poller_tag")
+ poller_tag n["shinken"]["poller_tag"]
+ else
+ poller_tag n["domain"]
+ end
end
+ if n.has_key?("nagios")
+ (n["nagios"]["host_definition"]||{}).each_pair do |k, v|
+ self.send k, v
+ end
+
+ if (n["nagios"]["host_definition"]|| {})["use"].nil?
+ use ["#{n['platform']}-host"]
+ end
+ else
+ use ["#{n['platform']}-host"]
+ end
end
end
+# add the manual hosts
+hosts = search(:shinken_hosts, "*:*")
+hosts.sort! {|a,b| a.name <=> b.name }
+hosts.each do |n|
+ # we'll use shinken_host LWRP to define host
+ shinken_host n["host_name"] do
+ n.delete_if{|k, v| k == "id"}.each_pair do |k, v|
+ self.send k, v
+ end
+ end
+end
diff --git a/recipes/arbiter-services.rb b/recipes/arbiter-services.rb
index fb2dc50..894415d 100644
--- a/recipes/arbiter-services.rb
+++ b/recipes/arbiter-services.rb
@@ -49,7 +49,10 @@
### Populate
# We'll now populate services with templates
-search(:shinken_service_templates, "*:*") do |s|
+service_templates = search(:shinken_service_templates, "*:*")
+service_templates.sort! {|a,b| a.name <=> b.name }
+
+service_templates.each do |s|
shinken_service s["id"] do
# We wont register templates
register false
@@ -60,19 +63,29 @@
end
end
-# We'll now populate services with real content
-search(:node, "monitoring:*") do |n|
- (n["monitoring"]["checks"]|| {}).each_pair do |service_key, service|
- # we'll use shinken_host LWRP to define host
- shinken_service "#{n["fqdn"]}/#{service_key}" do
- host_name n["fqdn"]
- service_key service_key
+servicegroups = []
+services = search(:shinken_services, "*:*")
+services.sort! {|a,b| a.name <=> b.name }
+
+services.each do |s|
+ shinken_service s["id"] do
+ register true
- service.each_pair do |k, v|
- self.send k, v
+ s["servicegroups"].each do |group|
+ if !servicegroups.include?(group)
+ servicegroups << group
end
end
+
+ s.delete_if{|k, v| k == "id"}.each_pair do |k, v|
+ self.send k, v
+ end
end
end
-
+servicegroups.each do |group|
+ shinken_servicegroup group do
+ servicegroup_name group
+ servicegroup_alias group
+ end
+end
diff --git a/recipes/arbiter.rb b/recipes/arbiter.rb
index cfd6e2c..8a1c4bd 100644
--- a/recipes/arbiter.rb
+++ b/recipes/arbiter.rb
@@ -33,11 +33,9 @@
include_recipe "shinken::base"
### Package install
-# For now we only handle debian packages
package "shinken-arbiter"
-
### Layout
#### Directories
@@ -82,19 +80,18 @@
shinken_daemon "#{daemon}-#{n[:fqdn]}" do
daemon_type daemon
- address n["fqdn"]
+ if n["shinken"][daemon.to_s]["ipaddress"].nil?
+ address n["ipaddress"]
+ else
+ address n["shinken"][daemon.to_s]["ipaddress"]
+ end
+
port n["shinken"][daemon.to_s]["port"]
variables n["shinken"][daemon.to_s]["variables"]
+ modules n["shinken"][daemon.to_s]["modules"]
end
- (n["shinken"][daemon.to_s]["modules"] || {}).each_pair do |k, v|
- shinken_module k do
- module_type v["type"].to_sym
- variables v["variables"]
- modules v["modules"] || []
- end
- end
end
end
@@ -146,6 +143,7 @@
include_recipe "shinken::arbiter-hosts"
include_recipe "shinken::arbiter-servicegroups"
include_recipe "shinken::arbiter-services"
+include_recipe "shinken::arbiter-escalations"
#### Main configuration file
@@ -161,6 +159,7 @@
:command_files => node.run_state["shinken"]["arbiter"]["commands"],
:contact_files => node.run_state["shinken"]["arbiter"]["contacts"],
:timeperiod_files => node.run_state["shinken"]["arbiter"]["timeperiods"],
+ :escalation_files => node.run_state["shinken"]["arbiter"]["escalations"],
:notiticationway_files => node.run_state["shinken"]["arbiter"]["notificationways"]
})
@@ -168,15 +167,21 @@
notifies :restart, "service[shinken-arbiter]", :delayed
end
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-arbiter" do
+ mode "0755"
+ end
+end
+
### Service stuff
# Declare arbiter service
service "shinken-arbiter" do
# Ensure it is started by default and running
action [:enable, :start]
+ ignore_failure true
# If ``/etc/default/shinken`` is changed, we'll restart
- subscribes :restart, "template[shinken/default/debian]", :delayed \
- if node["platform"] == "debian"
+ subscribes :restart, "template[shinken/default/debian]", :delayed
end
diff --git a/recipes/base.rb b/recipes/base.rb
index ad4a5ee..1bba863 100644
--- a/recipes/base.rb
+++ b/recipes/base.rb
@@ -33,38 +33,28 @@
# at the end.
node.run_state["shinken"] = {}
-### Packaging
-#### Shinken's repository
-# Shinken resides in its own directory
-apt_repository "shinken-dev" do
- uri "http://shinken.apt.znx.fr/"
- distribution "sid"
- components ["main"]
- key "http://shinken.apt.znx.fr/packages@zenexity.com.gpg.key"
-
- action :add
+if node['platform_family'] == "debian"
+ ### Packaging
+ #### Shinken's repository
+ # Shinken resides in its own directory
+ apt_repository "shinken-dev" do
+ uri "http://shinken.apt.znx.fr/"
+ distribution "sid"
+ components ["main"]
+ key "http://shinken.apt.znx.fr/packages@zenexity.com.gpg.key"
+ action :add
+ end
end
-
#### Package install
# We'll install core package which contains common files and common
# configuration
-package "shinken-core"
+package node["shinken"]["core_package"]
-
-### Common files
-directory "/var/cache/shinken" do
- owner "nagios"
- group "nagios"
-end
-
-# On debian we'll need to override /etc/default/shinken file
-if node["platform"] == "debian"
- template "shinken/default/debian" do
- path "/etc/default/shinken"
- source "default/shinken.erb"
- mode "0644"
- end
+template "shinken/default/debian" do
+ path "/etc/default/shinken"
+ source "default/shinken.erb"
+ mode "00644"
end
### Cleanup
@@ -74,6 +64,15 @@
'reactionnerd-windows.ini',
'receiverd-windows.ini',
'schedulerd-windows.ini',
+ 'commands.cfg',
+ 'contactgroups.cfg',
+ 'discovery.cfg',
+ 'discovery_rules.cfg',
+ 'discovery_runs.cfg',
+ 'escalations.cfg',
+ 'servicegroups.cfg',
+ 'templates.cfg',
+ 'timeperiods.cfg',
'shinken-specific-high-availability.cfg',
'shinken-specific-load-balanced-only.cfg'].each do |f|
file ::File.join('/etc/shinken', f) do
@@ -81,3 +80,23 @@
end
end
+directory "/etc/shinken/packs"
+
+directory "/etc/shinken/objects" do
+ action :delete
+ recursive true
+end
+
+cookbook_file "/etc/shinken/resource.cfg" do
+ mode "00644"
+end
+
+if node[:platform] == "centos"
+
+ cookbook_file "/etc/init.d/shinken" do
+ mode "0755"
+ end
+
+ package "python-ldap"
+
+end
diff --git a/recipes/broker-webui.rb b/recipes/broker-webui.rb
index 9ece093..55e454f 100644
--- a/recipes/broker-webui.rb
+++ b/recipes/broker-webui.rb
@@ -33,37 +33,9 @@
### Package install
# For now we only handle debian packages
-package "shinken-webui"
-
-### Webui module declaration
-# Store in db
-node.default["shinken"]["broker"]["modules"]["webui"] = {
- "id" => "webui",
- "modules" => [
- "apache-passwd"
- ],
- "type" => "webui",
- "variables" => {
- "allow_html_output" => 0,
- "auth_secret" => "c4c70386a4959a91e3725583f6ce75b40c67e70b1bf144fd49bc6b63f50c33f7",
- "host" => "127.0.0.1",
- "manage_acl" => 1,
- "max_output_length" => 100,
- "play_sound" => 0,
- "port" => 7767
- }
-}
-
-# Declare module in broker
-# We'll need to merge with existing modules
-# Proc is here just for namespacing code
-node.override["shinken"]["broker"]["variables"]["modules"] = Proc.new{
- elts = node.normal["shinken"]["broker"]["variables"]["modules"].split(",").map{|s| s.strip()}
- elts.push("webui")
- elts.uniq!
- elts.join(",")
-}.call
-
+if node['platform_family'] == "debian"
+ package "shinken-webui"
+end
## Reverse proxy
# We'll now setup a reverse proxy
diff --git a/recipes/broker.rb b/recipes/broker.rb
index 7c766ef..27e07ce 100644
--- a/recipes/broker.rb
+++ b/recipes/broker.rb
@@ -37,21 +37,34 @@
package "shinken-broker"
### Service stuff
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-broker" do
+ mode "0755"
+ end
+end
+
# Declare broker service
service "shinken-broker" do
# Ensure it is started by default and running
action [:enable, :start]
# If ``/etc/default/shinken`` is changed, we'll restart
- subscribes :restart, "template[shinken/default/debian]", :delayed \
- if node["platform"] == "debian"
+ subscribes :restart, "template[shinken/default/debian]", :delayed
end
### Configuration files
template "shinken/broker/ini" do
path "/etc/shinken/brokerd.ini"
-
source "broker/brokerd.ini.erb"
end
+# add the sysadmins to the htpasswd
+users = search(:users, "nagios:* AND password:* AND NOT action:remove")
+contacts = search(:shinken_contacts, "password:*")
+
+template "/etc/shinken/htpasswd.users" do
+ source "htpasswd.users.erb"
+ mode 0644
+ variables(:users => users + contacts)
+end
diff --git a/recipes/mongodb.rb b/recipes/mongodb.rb
new file mode 100644
index 0000000..655a3fc
--- /dev/null
+++ b/recipes/mongodb.rb
@@ -0,0 +1,10 @@
+include_recipe "mongodb::10gen_repo"
+include_recipe "mongodb"
+include_recipe "python"
+
+package "gcc"
+
+python_pip "pymongo" do
+ action :install
+end
+
diff --git a/recipes/plugins.rb b/recipes/plugins.rb
new file mode 100644
index 0000000..ac08929
--- /dev/null
+++ b/recipes/plugins.rb
@@ -0,0 +1 @@
+package "nagios-plugins-nrpe"
diff --git a/recipes/pnp.rb b/recipes/pnp.rb
new file mode 100644
index 0000000..245f165
--- /dev/null
+++ b/recipes/pnp.rb
@@ -0,0 +1,37 @@
+case node[:platform]
+when "centos"
+ include_recipe "yum::repoforge"
+when "debian"
+ include_recipe "apt"
+ apt_repository "backports" do
+ uri "http://backports.debian.org/debian-backports"
+ distribution "#{node['lsb']['codename']}-backports"
+ components ["main"]
+ action :add
+ end
+ apt_repository "dotdeb" do
+ uri "http://packages.dotdeb.org/"
+ distribution node['lsb']['codename']
+ components ["all"]
+ key "http://www.dotdeb.org/dotdeb.gpg"
+ action :add
+ end
+end
+
+package "pnp4nagios"
+package node["shinken"]["pnp"]["fpm"]
+
+service node["shinken"]["pnp"]["fpm"] do
+ action [:enable, :start]
+end
+
+service "npcd" do
+ action [:enable, :start]
+end
+
+if node.has_key?("apache")
+ template "#{node['apache']['dir']}/conf.d/pnp4nagios.conf" do
+ mode 0644
+ notifies :reload, "service[apache2]", :delayed
+ end
+end
diff --git a/recipes/poller.rb b/recipes/poller.rb
index ac3a9f6..1d41d94 100644
--- a/recipes/poller.rb
+++ b/recipes/poller.rb
@@ -24,16 +24,25 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
+### Include base recipe
+# See [shinken::base](base.html)
+
+include_recipe "shinken::base"
package "shinken-poller"
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-poller" do
+ mode "0755"
+ end
+end
+
service "shinken-poller" do
action [:enable, :start]
end
template "shinken/poller/ini" do
path "/etc/shinken/pollerd.ini"
-
source "poller/pollerd.ini.erb"
end
diff --git a/recipes/reactionner.rb b/recipes/reactionner.rb
index ac0682b..2671d39 100644
--- a/recipes/reactionner.rb
+++ b/recipes/reactionner.rb
@@ -24,19 +24,19 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-
package "shinken-reactionner"
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-reactionner" do
+ mode "0755"
+ end
+end
+
service "shinken-reactionner" do
action [:enable, :start]
end
template "shinken/reactionner/ini" do
path "/etc/shinken/reactionnerd.ini"
-
source "reactionner/reactionnerd.ini.erb"
end
-
-
-
-
diff --git a/recipes/receiver.rb b/recipes/receiver.rb
index 4c28d95..9ea0b8b 100644
--- a/recipes/receiver.rb
+++ b/recipes/receiver.rb
@@ -24,16 +24,20 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-
package "shinken-receiver"
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-receiver" do
+ mode "0755"
+ end
+end
+
service "shinken-receiver" do
action [:enable, :start]
end
template "shinken/receiver/ini" do
path "/etc/shinken/receiverd.ini"
-
source "receiver/receiverd.ini.erb"
end
diff --git a/recipes/scheduler.rb b/recipes/scheduler.rb
index 4d9fcf6..0e31ff3 100644
--- a/recipes/scheduler.rb
+++ b/recipes/scheduler.rb
@@ -24,16 +24,20 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-
package "shinken-scheduler"
+if node[:platform] == "centos"
+ cookbook_file "/etc/init.d/shinken-scheduler" do
+ mode "0755"
+ end
+end
+
service "shinken-scheduler" do
action [:enable, :start]
end
template "shinken/scheduler/ini" do
path "/etc/shinken/schedulerd.ini"
-
source "scheduler/schedulerd.ini.erb"
end
diff --git a/recipes/xmpp.rb b/recipes/xmpp.rb
new file mode 100644
index 0000000..363bc23
--- /dev/null
+++ b/recipes/xmpp.rb
@@ -0,0 +1,9 @@
+package "python-xmpp"
+
+cookbook_file "/usr/local/bin/xmppsend" do
+ mode 0755
+end
+
+template "/usr/local/etc/xmppsend.ini" do
+ mode 0644
+end
diff --git a/resources/contactgroup.rb b/resources/contactgroup.rb
new file mode 100644
index 0000000..2c0b235
--- /dev/null
+++ b/resources/contactgroup.rb
@@ -0,0 +1,19 @@
+actions :create, :delete
+
+
+attribute :contactgroup_key, :kind_of => String, :name_attribute => true
+attribute :contactgroup_name, :kind_of => String
+attribute :contactgroup_alias, :kind_of => String
+attribute :members, :kind_of => Array
+attribute :realm, :kind_of => String
+
+attribute :register, :kind_of => [TrueClass, FalseClass], :default => true
+attribute :use, :kind_of => Array
+
+
+def initialize(*opts)
+ super *opts
+ @action = :create
+
+ @run_context.include_recipe "shinken::arbiter-contacts"
+end
diff --git a/resources/daemon.rb b/resources/daemon.rb
index 5046e4e..9b5183b 100644
--- a/resources/daemon.rb
+++ b/resources/daemon.rb
@@ -13,6 +13,7 @@
}
attribute :variables, :kind_of => Hash
+attribute :modules, :kind_of => Array
attribute :address, :kind_of => String, :required => true
attribute :port, :kind_of => Integer, :required => true
diff --git a/resources/escalation.rb b/resources/escalation.rb
new file mode 100644
index 0000000..93eceb1
--- /dev/null
+++ b/resources/escalation.rb
@@ -0,0 +1,45 @@
+actions :create, :delete
+
+def self.validation_callback(items, combination = true)
+ if combination
+ {
+ "is not a valid combination" => Proc.new {|ts|
+ returns = ts.map do |t|
+ items.include?(t.to_sym)
+ end
+ not returns.include?(false)
+ }
+ }
+ else
+ {
+ "is not a valid type" => Proc.new {|ts|
+ items.include?(ts.to_sym)
+ }
+ }
+ end
+end
+
+
+attribute :escalation_key, :kind_of => String, :name_attribute => true
+
+attribute :first_notification, :kind_of => Integer
+attribute :last_notification, :kind_of => Integer
+attribute :first_notification_time, :kind_of => Integer
+attribute :last_notification_time, :kind_of => Integer
+
+attribute :notification_interval, :kind_of => Integer
+attribute :escalation_period, :kind_of => String
+attribute :escalation_options, :callbacks => validation_callback([:warning, :unknown, :critical, :recovery, :flapping, :scheduled])
+attribute :contacts, :kind_of => Array
+attribute :contact_groups, :kind_of => Array
+
+#attribute :register, :kind_of => [TrueClass, FalseClass], :default => true
+#attribute :use, :kind_of => Array, :default => []
+
+
+def initialize(*opts)
+ super *opts
+ @action = :create
+
+# @run_context.include_recipe "shinken::arbiter"
+end
diff --git a/resources/host.rb b/resources/host.rb
index 893785d..9a796d9 100644
--- a/resources/host.rb
+++ b/resources/host.rb
@@ -64,8 +64,10 @@ def self.validation_callback(items, combination = true)
attribute :icon_image_alt, :kind_of => String
attribute :vrml_image, :kind_of => String
attribute :statusmap_image, :kind_of => String
+attribute :poller_tag, :kind_of => String
#attribute :2d_coords, x_coord,y_coord
#attribute :3d_coords, x_coord,y_coord,z_coord
+attribute :escalations, :kind_of => String
attribute :register, :kind_of => [TrueClass, FalseClass], :default => true
attribute :use, :kind_of => Array
diff --git a/resources/service.rb b/resources/service.rb
index 2dd68bf..0d45f10 100644
--- a/resources/service.rb
+++ b/resources/service.rb
@@ -26,12 +26,13 @@ def self.validation_callback(items, combination = true)
attribute :service_key, :kind_of => String, :name_attribute => true
attribute :host_name, :kind_of => String
-attribute :hostgroup_name, :kind_of => String
+attribute :hostgroup_name, :kind_of => Array
attribute :service_description, :kind_of => String
attribute :display_name, :kind_of => String
attribute :servicegroups, :kind_of => Array
attribute :is_volatile, :kind_of => [TrueClass, FalseClass]
attribute :check_command, :kind_of => String
+attribute :command_line, :kind_of => String
attribute :arguments, :kind_of => Array
attribute :initial_state, :callbacks => validation_callback([:ok, :warning, :unknown, :critical], false)
attribute :max_check_attempts, :kind_of => Integer
@@ -65,6 +66,9 @@ def self.validation_callback(items, combination = true)
attribute :action_url, :kind_of => String
attribute :icon_image, :kind_of => String
attribute :icon_image_alt, :kind_of => String
+attribute :escalations, :kind_of => String
+attribute :service_dependencies, :kind_of => String
+attribute :business_impact, :kind_of => Integer
attribute :register, :kind_of => [TrueClass, FalseClass], :default => true
attribute :use, :kind_of => Array, :default => []
diff --git a/templates/default/arbiter/arbiter.cfg.erb b/templates/default/arbiter/arbiter.cfg.erb
index d364749..161f56b 100644
--- a/templates/default/arbiter/arbiter.cfg.erb
+++ b/templates/default/arbiter/arbiter.cfg.erb
@@ -166,7 +166,7 @@ daemon_enabled=1
shinken_user=nagios
shinken_group=nagios
-lock_file=/var/run/nagios/arbiterd.pid
+lock_file=<%= node['shinken']['run_dir'] %>/arbiterd.pid
local_log=/var/log/shinken/arbiterd.log
@@ -211,6 +211,7 @@ cfg_file=objects-chef/<%= nwf %>
cfg_file=objects-chef/<%= tpf %>
<% end %>
-
-
-
+## Escalations
+<% @escalation_files.each do |esf| %>
+cfg_file=objects-chef/<%= esf %>
+<% end %>
diff --git a/templates/default/arbiter/daemon.cfg.erb b/templates/default/arbiter/daemon.cfg.erb
index 3940798..60a168c 100644
--- a/templates/default/arbiter/daemon.cfg.erb
+++ b/templates/default/arbiter/daemon.cfg.erb
@@ -7,10 +7,10 @@ define <%= @daemon_type.to_s %> {
port <%= @port %>
<% if @modules %>
- modules <%= @modules.join(" ") %>
+ modules <%= @modules.join(", ") %>
<% end %>
-<% Hash.new(@variables.to_a.sort).each do |key, value| %>
+<% @variables.to_a.sort.each do |key, value| %>
<%= key %> <%= value %>
<% end %>
diff --git a/templates/default/arbiter/module.cfg.erb b/templates/default/arbiter/module.cfg.erb
index a9dd899..61221e5 100644
--- a/templates/default/arbiter/module.cfg.erb
+++ b/templates/default/arbiter/module.cfg.erb
@@ -4,7 +4,7 @@ define module {
module_name <%= @name %>
module_type <%= @module_type %>
-<% Hash.new(@variables.to_a.sort).each do |key, value| %>
+<% @variables.to_a.sort.each do |key, value| %>
<%= key %> <%= value %>
<% end %>
diff --git a/templates/default/broker/brokerd.ini.erb b/templates/default/broker/brokerd.ini.erb
index a92cc6f..6bfb0a1 100644
--- a/templates/default/broker/brokerd.ini.erb
+++ b/templates/default/broker/brokerd.ini.erb
@@ -47,5 +47,5 @@ max_queue_size=100000
user=nagios
group=nagios
-workdir=/var/lib/nagios
-pidfile=/var/run/nagios/brokerd.pid
+workdir=<%= node['shinken']['work_dir'] %>
+pidfile=<%= node['shinken']['run_dir'] %>/brokerd.pid
diff --git a/templates/default/broker/webui/nginx.cfg.erb b/templates/default/broker/webui/nginx.cfg.erb
index b69b76c..cf78f1e 100644
--- a/templates/default/broker/webui/nginx.cfg.erb
+++ b/templates/default/broker/webui/nginx.cfg.erb
@@ -13,6 +13,20 @@ server {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
+ location /pnp4nagios {
+ alias /usr/share/nagios/html/pnp4nagios/;
+ }
+
+ location ~ ^(/pnp4nagios.*\.php)(.*)$ {
+ root /usr/share/nagios/html/pnp4nagios/;
+ include /etc/nginx/fastcgi_params;
+ fastcgi_split_path_info ^(.+\.php)(.*)$;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+
+ fastcgi_param SCRIPT_FILENAME $document_root/index.php;
+ fastcgi_pass 127.0.0.1:9000;
+ }
+
}
diff --git a/templates/default/default/shinken.erb b/templates/default/default/shinken.erb
index 4337ddb..9ac003f 100644
--- a/templates/default/default/shinken.erb
+++ b/templates/default/default/shinken.erb
@@ -25,17 +25,17 @@
# /etc/default/shinken
# /etc/shinken is where we put all configuration files
-# /var/lib/nagios is where we put some variables files (replaced by /home/superbaloo/dev/packages/build/shinken-1.2.2/debian/tmp/var/run/nagios and /home/superbaloo/dev/packages/build/shinken-1.2.2/debian/tmp/var/log/shinken for now)
-# /var/run/nagios is where we put pid files
+# <%= node['shinken']['work_dir'] %> is where we put some variables files (replaced by /home/superbaloo/dev/packages/build/shinken-1.2.2/debian/tmp<%= node['shinken']['run_dir'] %> and /home/superbaloo/dev/packages/build/shinken-1.2.2/debian/tmp/var/log/shinken for now)
+# <%= node['shinken']['run_dir'] %> is where we put pid files
# /var/log/shinken is where we put log files
# /usr/bin is where the launch scripts will be send
## These vars will override the hardcoded ones in init script ##
ETC=/etc/shinken
-VAR=/var/lib/nagios
-BIN=/usr/bin
-RUN=/var/run/nagios
+VAR=<%= node['shinken']['work_dir'] %>
+BIN=<%= node['shinken']['bin_dir'] %>
+RUN=<%= node['shinken']['run_dir'] %>
LOG=/var/log/shinken
diff --git a/templates/default/definitions/contactgroups/contactgroup.cfg.erb b/templates/default/definitions/contactgroups/contactgroup.cfg.erb
new file mode 100644
index 0000000..df25f0b
--- /dev/null
+++ b/templates/default/definitions/contactgroups/contactgroup.cfg.erb
@@ -0,0 +1,26 @@
+# This file is dropped off by chef, any local changes will be overwritten
+
+define contactgroup {
+<% if not @register %>
+ name <%= @contactgroup_key %>
+<% end %>
+
+<% if not @contactgroup_name.nil? %>
+ contactgroup_name <%= @contactgroup_name %>
+<% end %>
+<% if not @contactgroup_alias.nil? %>
+ alias <%= @contactgroup_alias %>
+<% end %>
+<% if not @members.nil? %>
+ members <%= @members.join(",") %>
+<% end %>
+<% if not @realm.nil? %>
+ realm <%= @realm %>
+<% end %>
+
+ register <%= @register ? "1": "0" %>
+<% if @use %>
+ use <%= @use.join(",") %>
+<% end %>
+}
+
diff --git a/templates/default/definitions/contacts/contact.cfg.erb b/templates/default/definitions/contacts/contact.cfg.erb
index 93655a1..d835164 100644
--- a/templates/default/definitions/contacts/contact.cfg.erb
+++ b/templates/default/definitions/contacts/contact.cfg.erb
@@ -12,6 +12,9 @@ define contact {
<% if not @contact_alias.nil? %>
alias <%= @contact_alias %>
<% end %>
+<% if @contactgroups %>
+ contactgroups <%= @contactgroups %>
+<% end %>
<% if not @host_notifications_enabled.nil? %>
host_notifications_enabled <%= @host_notifications_enabled ? "1": "0" %>
<% end %>
@@ -21,6 +24,9 @@ define contact {
<% if @email %>
email <%= @email %>
<% end %>
+<% if @pager %>
+ pager <%= @pager %>
+<% end %>
<% if not @can_submit_commands.nil? %>
can_submit_commands <%= @can_submit_commands ? "1": "0" %>
<% end %>
diff --git a/templates/default/definitions/escalations/escalation.cfg.erb b/templates/default/definitions/escalations/escalation.cfg.erb
new file mode 100644
index 0000000..986ca0d
--- /dev/null
+++ b/templates/default/definitions/escalations/escalation.cfg.erb
@@ -0,0 +1,34 @@
+# This file is dropped off by chef, any local changes will be overwritten
+
+define escalation {
+ escalation_name <%= @escalation_key %>
+
+<% if not @first_notification.nil? %>
+ first_notification <%= @first_notification %>
+<% end %>
+<% if not @last_notification.nil? %>
+ last_notification <%= @last_notification %>
+<% end %>
+<% if not @first_notification_time.nil? %>
+ first_notification_time <%= @first_notification_time %>
+<% end %>
+<% if not @last_notification_time.nil? %>
+ last_notification_time <%= @last_notification_time %>
+<% end %>
+<% if not @notification_interval.nil? %>
+ notification_interval <%= @notification_interval %>
+<% end %>
+<% if not @escalation_period.nil? %>
+ escalation_period <%= @escalation_period %>
+<% end %>
+<% if not @escalation_options.nil? %>
+ escalation_options <%= @escalation_options.map{|e| e.to_s[0,1]}.join(",") %>
+<% end %>
+<% if not @contacts.nil? and not @contacts.empty? %>
+ contacts <%= @contacts.join(",") %>
+<% end %>
+<% if not @contact_groups.nil? %>
+ contact_groups <%= @contact_groups.join(",") %>
+<% end %>
+}
+
diff --git a/templates/default/definitions/hosts/host.cfg.erb b/templates/default/definitions/hosts/host.cfg.erb
index 82a6d70..453ba87 100644
--- a/templates/default/definitions/hosts/host.cfg.erb
+++ b/templates/default/definitions/hosts/host.cfg.erb
@@ -35,6 +35,9 @@ define host {
<% if not @check_period.nil? %>
check_period <%= @check_period %>
<% end %>
+<% if not @contacts.nil? %>
+ contacts <%= @contacts.join(",") %>
+<% end %>
<% if not @contact_groups.nil? %>
contact_groups <%= @contact_groups.join(",") %>
<% end %>
@@ -59,8 +62,27 @@ define host {
<% if not @process_perf_data.nil? %>
process_perf_data <%= @process_perf_data %>
<% end %>
-
-
+<% if not @notes.nil? %>
+ notes <%= @notes %>
+<% end %>
+<% if not @notes_url.nil? %>
+ notes_url <%= @notes_url %>
+<% end %>
+<% if not @action_url.nil? %>
+ action_url <%= @action_url %>
+<% end %>
+<% if not @icon_image.nil? %>
+ icon_image <%= @icon_image %>
+<% end %>
+<% if not @icon_image_alt.nil? %>
+ icon_image_alt <%= @icon_image_alt %>
+<% end %>
+<% if not @poller_tag.nil? %>
+ poller_tag <%= @poller_tag %>
+<% end %>
+<% if not @escalations.nil? %>
+ escalations <%= @escalations %>
+<% end %>
register <%= @register ? "1": "0" %>
diff --git a/templates/default/definitions/services/service.cfg.erb b/templates/default/definitions/services/service.cfg.erb
index 5c7d2a0..1c34bdd 100644
--- a/templates/default/definitions/services/service.cfg.erb
+++ b/templates/default/definitions/services/service.cfg.erb
@@ -2,134 +2,138 @@
define service {
<% if not @register %>
- name <%= @service_key %>
+ name <%= @service_key %>
<% end %>
-
-
<% if not @service_alias.nil? %>
- alias <%= @service_alias %>
+ alias <%= @service_alias %>
<% end %>
<% if not @host_name.nil? %>
- host_name <%= @host_name %>
+ host_name <%= @host_name %>
+<% end %>
+<% if not @hostgroup_name.nil? %>
+ hostgroup_name <%= @hostgroup_name.join(",") %>
<% end %>
-
<% if not @service_description.nil? %>
- service_description <%= @service_description %>
+ service_description <%= @service_description %>
<% end %>
<% if not @display_name.nil? %>
- display_name <%= @display_name %>
+ display_name <%= @display_name %>
<% end %>
<% if not @servicegroups.nil? %>
- servicegroups <%= @servicegroups.join(",") %>
+ servicegroups <%= @servicegroups.join(",") %>
<% end %>
<% if not @check_command.nil? %>
- check_command <%= @check_command.command_identifier %>
+ check_command <%= @check_command.command_identifier %>
<% end %>
<% if not @initial_state.nil? %>
- initial_state <%= @initial_state.to_s[0,1] %>
+ initial_state <%= @initial_state.to_s[0,1] %>
<% end %>
<% if not @max_check_attempts.nil? %>
- max_check_attempts <%= @max_check_attempts %>
+ max_check_attempts <%= @max_check_attempts %>
<% end %>
<% if not @check_interval.nil? %>
- check_interval <%= @check_interval %>
+ check_interval <%= @check_interval %>
<% end %>
<% if not @retry_interval.nil? %>
- retry_interval <%= @retry_interval %>
+ retry_interval <%= @retry_interval %>
<% end %>
<% if not @active_checks_enabled.nil? %>
- active_checks_enabled <%= @active_checks_enabled ? "1": "0" %>
+ active_checks_enabled <%= @active_checks_enabled ? "1": "0" %>
<% end %>
<% if not @passive_checks_enabled.nil? %>
- passive_checks_enabled <%= @passive_checks_enabled ? "1": "0" %>
+ passive_checks_enabled <%= @passive_checks_enabled ? "1": "0" %>
<% end %>
<% if not @check_period.nil? %>
- check_period <%= @check_period %>
+ check_period <%= @check_period %>
<% end %>
<% if not @obsess_over_service.nil? %>
- obsess_over_service <%= @obsess_over_service ? "1": "0" %>
+ obsess_over_service <%= @obsess_over_service ? "1": "0" %>
<% end %>
<% if not @check_freshness.nil? %>
- check_freshness <%= @check_freshness ? "1": "0" %>
+ check_freshness <%= @check_freshness ? "1": "0" %>
<% end %>
<% if not @freshness_threshold.nil? %>
- freshness_threshold <%= @freshness_threshold %>
+ freshness_threshold <%= @freshness_threshold %>
<% end %>
<% if not @event_handler.nil? %>
- event_handler <%= @event_handler %>
+ event_handler <%= @event_handler %>
<% end %>
<% if not @event_handler_enabled.nil? %>
- event_handler_enabled <%= @event_handler_enabled? "1": "0" %>
+ event_handler_enabled <%= @event_handler_enabled? "1": "0" %>
<% end %>
<% if not @low_flap_threshold.nil? %>
- low_flap_threshold <%= @low_flap_threshold %>
+ low_flap_threshold <%= @low_flap_threshold %>
<% end %>
<% if not @high_flap_threshold.nil? %>
- high_flap_threshold <%= @high_flap_threshold %>
+ high_flap_threshold <%= @high_flap_threshold %>
<% end %>
<% if not @flap_detection_enabled.nil? %>
- flap_detection_enabled <%= @flap_detection_enabled ? "1": "0"%>
+ flap_detection_enabled <%= @flap_detection_enabled ? "1": "0"%>
<% end %>
<% if not @flap_detection_options.nil? %>
- flap_detection_options <%= @flap_detection_options.map{|e| e.to_s[0,1]}.join(",") %>
+ flap_detection_options <%= @flap_detection_options.map{|e| e.to_s[0,1]}.join(",") %>
<% end %>
<% if not @process_perf_data.nil? %>
- process_perf_data <%= @process_perf_data? "1": "0" %>
+ process_perf_data <%= @process_perf_data? "1": "0" %>
<% end %>
<% if not @retain_status_information.nil? %>
- retain_status_information <%= @retain_status_information ? "1": "0" %>
+ retain_status_information <%= @retain_status_information ? "1": "0" %>
<% end %>
<% if not @retain_nonstatus_information.nil? %>
- retain_nonstatus_information <%= @retain_nonstatus_information? "1": "0" %>
+ retain_nonstatus_information <%= @retain_nonstatus_information? "1": "0" %>
<% end %>
<% if not @notification_interval.nil? %>
- notification_interval <%= @notification_interval %>
+ notification_interval <%= @notification_interval %>
<% end %>
<% if not @first_notification_delay.nil? %>
- first_notification_delay <%= @first_notification_delay %>
+ first_notification_delay <%= @first_notification_delay %>
<% end %>
<% if not @notification_period.nil? %>
- notification_period <%= @notification_period %>
+ notification_period <%= @notification_period %>
<% end %>
<% if not @notification_options.nil? %>
- notification_options <%= @notification_options.map{|e| e.to_s[0,1]}.join(",") %>
+ notification_options <%= @notification_options.map{|e| e.to_s[0,1]}.join(",") %>
<% end %>
<% if not @notifications_enabled.nil? %>
- notifications_enabled <%= @notifications_enabled?"1":"0" %>
+ notifications_enabled <%= @notifications_enabled?"1":"0" %>
<% end %>
<% if not @contacts.nil? and not @contacts.empty?%>
- contacts <%= @contacts.join(",") %>
+ contacts <%= @contacts.join(",") %>
<% end %>
<% if not @contact_groups.nil? %>
- contact_groups <%= @contact_groups.join(",") %>
+ contact_groups <%= @contact_groups.join(",") %>
<% end %>
<% if not @stalking_options.nil? %>
- stalking_options <%= @stalking_options.map{|e| e.to_s[0,1]}.join(",") %>
+ stalking_options <%= @stalking_options.map{|e| e.to_s[0,1]}.join(",") %>
<% end %>
<% if not @notes.nil? %>
- notes <%= @notes %>
+ notes <%= @notes %>
<% end %>
<% if not @notes_url.nil? %>
- notes_url <%= @notes_url %>
+ notes_url <%= @notes_url %>
<% end %>
<% if not @action_url.nil? %>
- action_url <%= @action_url %>
+ action_url <%= @action_url %>
<% end %>
<% if not @icon_image.nil? %>
- icon_image <%= @icon_image %>
+ icon_image <%= @icon_image %>
<% end %>
<% if not @icon_image_alt.nil? %>
- icon_image_alt <%= @icon_image_alt %>
+ icon_image_alt <%= @icon_image_alt %>
<% end %>
-
-
-
-
- register <%= @register ? "1": "0" %>
-
+<% if not @escalations.nil? %>
+ escalations <%= @escalations %>
+<% end %>
+<% if not @service_dependencies.nil? %>
+ service_dependencies <%= @service_dependencies %>
+<% end %>
+<% if not @business_impact.nil? %>
+ business_impact <%= @business_impact %>
+<% end %>
+ register <%= @register ? "1": "0" %>
<% if @use %>
- use <%= @use.join(",") %>
+ use <%= @use.join(",") %>
<% end %>
}
diff --git a/templates/default/definitions/timeperiods/timeperiod.cfg.erb b/templates/default/definitions/timeperiods/timeperiod.cfg.erb
index bfde1a6..7bb691f 100644
--- a/templates/default/definitions/timeperiods/timeperiod.cfg.erb
+++ b/templates/default/definitions/timeperiods/timeperiod.cfg.erb
@@ -15,9 +15,11 @@ define timeperiod {
<% if not @exclude.nil? %>
exclude <%= @exclude.join(",") %>
<% end %>
+<% if not @content.nil? %>
<% @content.each do |line| %>
<%= line %>
<% end %>
+<% end %>
<% if not @register.nil? %>
register <%= @register?"1":"0" %>
diff --git a/templates/default/htpasswd.users.erb b/templates/default/htpasswd.users.erb
new file mode 100644
index 0000000..0aeb4ad
--- /dev/null
+++ b/templates/default/htpasswd.users.erb
@@ -0,0 +1,4 @@
+# Autogenerated by Chef.
+<% @users.each do |user| -%>
+<%= user["id"] %>:<%= user["password"].nil? ? "x" : user["password"] %>
+<% end -%>
diff --git a/templates/default/pnp4nagios.conf.erb b/templates/default/pnp4nagios.conf.erb
new file mode 100644
index 0000000..438070a
--- /dev/null
+++ b/templates/default/pnp4nagios.conf.erb
@@ -0,0 +1,30 @@
+# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
+
+Alias /pnp4nagios "/usr/share/nagios/html/pnp4nagios"
+
+
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ #
+ # Use the same value as defined in nagios.conf
+ #
+ AuthName "Monitoring Access"
+ AuthType Basic
+ AuthUserFile /etc/shinken/htpasswd.users
+ Require valid-user
+
+ # Turn on URL rewriting
+ RewriteEngine On
+ Options symLinksIfOwnerMatch
+ # Installation directory
+ RewriteBase /pnp4nagios/
+ # Protect application and system files from being viewed
+ RewriteRule "^(?:application|modules|system)/" - [F]
+ # Allow any files or directories that exist to be displayed directly
+ RewriteCond "%{REQUEST_FILENAME}" !-f
+ RewriteCond "%{REQUEST_FILENAME}" !-d
+ # Rewrite all other URLs to index.php/URL
+ RewriteRule "^.*$" "index.php/$0" [PT]
+
+
diff --git a/templates/default/poller/pollerd.ini.erb b/templates/default/poller/pollerd.ini.erb
index 542c9a9..4888b08 100644
--- a/templates/default/poller/pollerd.ini.erb
+++ b/templates/default/poller/pollerd.ini.erb
@@ -42,5 +42,5 @@ log_level=WARNING
user=nagios
group=nagios
-workdir=/var/lib/nagios
-pidfile=/var/run/nagios/pollerd.pid
+workdir=<%= node['shinken']['work_dir'] %>
+pidfile=<%= node['shinken']['run_dir'] %>/pollerd.pid
diff --git a/templates/default/reactionner/reactionnerd.ini.erb b/templates/default/reactionner/reactionnerd.ini.erb
index 84fbe2c..91a2c9e 100644
--- a/templates/default/reactionner/reactionnerd.ini.erb
+++ b/templates/default/reactionner/reactionnerd.ini.erb
@@ -33,5 +33,5 @@ log_level=WARNING
user=nagios
group=nagios
-workdir=/var/lib/nagios
-pidfile=/var/run/nagios/reactionnerd.pid
+workdir=<%= node['shinken']['work_dir'] %>
+pidfile=<%= node['shinken']['run_dir'] %>/reactionnerd.pid
diff --git a/templates/default/receiver/receiverd.ini.erb b/templates/default/receiver/receiverd.ini.erb
index 97d8e8c..a2c828b 100644
--- a/templates/default/receiver/receiverd.ini.erb
+++ b/templates/default/receiver/receiverd.ini.erb
@@ -33,5 +33,5 @@ log_level=WARNING
user=nagios
group=nagios
-workdir=/var/lib/nagios
-pidfile=/var/run/nagios/receiverd.pid
+workdir=<%= node['shinken']['work_dir'] %>
+pidfile=<%= node['shinken']['run_dir'] %>/receiverd.pid
diff --git a/templates/default/scheduler/schedulerd.ini.erb b/templates/default/scheduler/schedulerd.ini.erb
index d3f038a..ac25d94 100644
--- a/templates/default/scheduler/schedulerd.ini.erb
+++ b/templates/default/scheduler/schedulerd.ini.erb
@@ -31,5 +31,5 @@ log_level=INFO
user=nagios
group=nagios
-workdir=/var/lib/nagios
-pidfile=/var/run/nagios/schedulerd.pid
+workdir=<%= node['shinken']['work_dir'] %>
+pidfile=<%= node['shinken']['run_dir'] %>/schedulerd.pid
diff --git a/templates/default/xmppsend.ini.erb b/templates/default/xmppsend.ini.erb
new file mode 100644
index 0000000..a7149f7
--- /dev/null
+++ b/templates/default/xmppsend.ini.erb
@@ -0,0 +1,6 @@
+[xmpp_nagios]
+username=<%= node["shinken"]["xmpp"]["username"] %>
+domain=<%= node["shinken"]["xmpp"]["domain"] %>
+password=<%= node["shinken"]["xmpp"]["password"] %>
+server=<%= node["shinken"]["xmpp"]["server"] %>
+port=<%= node["shinken"]["xmpp"]["port"] %>
\ No newline at end of file