Last active
January 6, 2017 02:27
-
-
Save marsyang1/c9c74e0126c2ff7e00e5f6a9d0c76cce to your computer and use it in GitHub Desktop.
docker icinga2 setting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This file defines global constants which can be used in | |
* the other configuration files. | |
*/ | |
/* The directory which contains the plugins from the Monitoring Plugins project. */ | |
const PluginDir = "/usr/lib64/nagios/plugins" | |
/* The directory which contains the Manubulon plugins. | |
* Check the documentation, chapter "SNMP Manubulon Plugin Check Commands", for details. | |
*/ | |
const ManubulonPluginDir = "/usr/lib64/nagios/plugins" | |
/* The directory which you use to store additional plugins which ITL provides user contributed command definitions for. | |
* Check the documentation, chapter "Plugins Contribution", for details. | |
*/ | |
const PluginContribDir = "/usr/lib64/nagios/plugins" | |
/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`. | |
* This should be the common name from the API certificate. | |
*/ | |
const NodeName = "docker-icinga2" | |
/* Our local zone name. */ | |
const ZoneName = NodeName | |
/* Secret key for remote node tickets */ | |
const TicketSalt = "" | |
const RemoteNodeSvnOld = "remote-svn-old" | |
const RemoteNodeSvn = "remote-svn" | |
const RemoteNodeTest = "remote-test" | |
const RemoteNodeTest234 = "remote-test-234" | |
const RemoteZone = "remote-zone" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Host NodeName { | |
/* Import the default host template defined in `templates.conf`. */ | |
import "generic-host" | |
/* Specify the address attributes for checks e.g. `ssh` or `http`. */ | |
address = "127.0.0.1" | |
address6 = "::1" | |
var node_notes = "This is Icinga 2 running" | |
if (NodeName.contains("docker")) { | |
notes = node_notes + " inside Docker :)" | |
} else if (NodeName == "icinga2a") { | |
notes = node_notes + " as cluster master :)" | |
} else if (NodeName == "icinga2b") { | |
notes = node_notes + " as cluster checker :)" | |
} else if (regex("^icinga2*", NodeName)) { | |
notes = node_notes + " inside Vagrant :)" | |
} | |
vars.http_vhosts["Icinga Web 2"] = { | |
http_uri = "/icingaweb2" | |
} | |
/* Define disks and attributes for service apply rules in `services.conf`. */ | |
vars.disks["disk"] = { | |
/* No parameters. */ | |
} | |
vars.disks["disk /"] = { | |
disk_partitions = "/" | |
} | |
} | |
object Host RemoteNodeSvnOld { | |
import "generic-host" | |
address = "127.0.0.1" | |
} | |
object Host RemoteNodeSvn { | |
import "generic-host" | |
address = "127.0.0.1" | |
} | |
object Host RemoteNodeTest { | |
import "generic-host" | |
address = "127.0.0.1" | |
} | |
object Host RemoteNodeTest234 { | |
import "generic-host" | |
address = "127.0.0.1" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Service apply rules. | |
* | |
* The CheckCommand objects `ping4`, `ping6`, etc | |
* are provided by the plugin check command templates. | |
* Check the documentation for details. | |
* | |
* Tip: Use `icinga2 object list --type Service` to | |
* list all service objects after running | |
* configuration validation (`icinga2 daemon -C`). | |
*/ | |
/* | |
* This is an example host based on your | |
* local host's FQDN. Specify the NodeName | |
* constant in `constants.conf` or use your | |
* own description, e.g. "db-host-1". | |
*/ | |
/* | |
* These are generic `ping4` and `ping6` | |
* checks applied to all hosts having the | |
* `address` resp. `address6` attribute | |
* defined. | |
*/ | |
apply Service "ping4" { | |
import "generic-service" | |
check_command = "ping4" | |
assign where host.address | |
} | |
apply Service "ping6" { | |
import "generic-service" | |
check_command = "ping6" | |
assign where host.address6 | |
} | |
/* | |
* Apply the `ssh` service to all hosts | |
* with the `address` attribute defined and | |
* the custom attribute `os` set to `Linux`. | |
*/ | |
apply Service "ssh" { | |
import "generic-service" | |
check_command = "ssh" | |
assign where (host.address || host.address6) && host.vars.os == "Linux" | |
} | |
apply Service for (http_vhost => config in host.vars.http_vhosts) { | |
import "generic-service" | |
check_command = "http" | |
vars += config | |
} | |
apply Service for (disk => config in host.vars.disks) { | |
import "generic-service" | |
check_command = "disk" | |
vars += config | |
} | |
apply Service "icinga" { | |
import "generic-service" | |
check_command = "icinga" | |
assign where host.name == NodeName | |
} | |
apply Service "load" { | |
import "generic-service" | |
check_command = "load" | |
/* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */ | |
vars.backup_downtime = "02:00-03:00" | |
assign where host.name == NodeName | |
} | |
apply Service "procs" { | |
import "generic-service" | |
check_command = "procs" | |
assign where host.name == NodeName | |
} | |
apply Service "swap" { | |
import "generic-service" | |
check_command = "swap" | |
assign where host.name == NodeName | |
} | |
apply Service "users" { | |
import "generic-service" | |
check_command = "users" | |
assign where host.name == NodeName | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -d -p 10001:80 --name icinga2 \ | |
-v /home/vagrant/docker-workshop/icinga2_home/constants.conf:/etc/icinga2/constants.conf \ | |
-v /home/vagrant/docker-workshop/icinga2_home/zones.conf:/etc/icinga2/zones.conf \ | |
-v /home/vagrant/docker-workshop/icinga2_home/hosts.conf:/etc/icinga2/conf.d/hosts.conf \ | |
-v /home/vagrant/docker-workshop/icinga2_home/templates.conf:/etc/icinga2/conf.d/templates.conf \ | |
icinga/icinga2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generic template examples. | |
*/ | |
/** | |
* Provides default settings for hosts. By convention | |
* all hosts should import this template. | |
* | |
* The CheckCommand object `hostalive` is provided by | |
* the plugin check command templates. | |
* Check the documentation for details. | |
*/ | |
template Host "generic-host" { | |
max_check_attempts = 3 | |
check_interval = 1m | |
retry_interval = 5s | |
check_command = "hostalive" | |
} | |
/** | |
* Provides default settings for services. By convention | |
* all services should import this template. | |
*/ | |
template Service "generic-service" { | |
max_check_attempts = 5 | |
check_interval = 1m | |
retry_interval = 30s | |
} | |
/** | |
* Provides default settings for users. By convention | |
* all users should inherit from this template. | |
*/ | |
template User "generic-user" { | |
} | |
/** | |
* Provides default settings for host notifications. | |
* By convention all host notifications should import | |
* this template. | |
*/ | |
template Notification "mail-host-notification" { | |
command = "mail-host-notification" | |
states = [ Up, Down ] | |
types = [ Problem, Acknowledgement, Recovery, Custom, | |
FlappingStart, FlappingEnd, | |
DowntimeStart, DowntimeEnd, DowntimeRemoved ] | |
period = "24x7" | |
} | |
/** | |
* Provides default settings for service notifications. | |
* By convention all service notifications should import | |
* this template. | |
*/ | |
template Notification "mail-service-notification" { | |
command = "mail-service-notification" | |
states = [ OK, Warning, Critical, Unknown ] | |
types = [ Problem, Acknowledgement, Recovery, Custom, | |
FlappingStart, FlappingEnd, | |
DowntimeStart, DowntimeEnd, DowntimeRemoved ] | |
period = "24x7" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Endpoint and Zone configuration for a cluster setup | |
* This local example requires `NodeName` defined in | |
* constants.conf. | |
*/ | |
object Endpoint NodeName { | |
host = NodeName | |
} | |
object Zone ZoneName { | |
endpoints = [ NodeName ] | |
} | |
object Endpoint RemoteNodeTest234 { | |
host = RemoteNodeTest234 | |
} | |
object Endpoint RemoteNodeSvnOld { | |
host = RemoteNodeSvnOld | |
} | |
object Endpoint RemoteNodeSvn { | |
host = RemoteNodeSvn | |
} | |
object Endpoint RemoteNodeTest { | |
host = RemoteNodeTest | |
} | |
object Zone RemoteZone { | |
endpoints = [ RemoteNodeTest234 , RemoteNodeSvn , RemoteNodeSvnOld , RemoteNodeTest ] | |
} | |
/* | |
* Defines a global zone containing templates, | |
* etc. synced to all nodes, if they accept | |
* configuration. All remote nodes need | |
* this zone configured too. | |
*/ | |
/* | |
object Zone "global-templates" { | |
global = true | |
} | |
*/ | |
/* | |
* Read the documentation on how to configure | |
* a cluster setup with multiple zones. | |
*/ | |
/* | |
object Endpoint "master.example.org" { | |
host = "master.example.org" | |
} | |
object Endpoint "satellite.example.org" { | |
host = "satellite.example.org" | |
} | |
object Zone "master" { | |
endpoints = [ "master.example.org" ] | |
} | |
object Zone "satellite" { | |
parent = "master" | |
endpoints = [ "satellite.example.org" ] | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment