Update monitoring configs

This commit is contained in:
Vladimir Vitkov 2019-10-27 22:10:55 +02:00
parent 0dbb8ddf63
commit fba000685a
15 changed files with 245 additions and 12 deletions

1
monitoring/icinga2/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
features-available

View File

@ -0,0 +1,19 @@
object CheckCommand "check_net_int" {
import "by_ssh"
vars.by_ssh_timeout = "420"
timeout = "420"
# vars.by_ssh_command = "sudo /usr/lib64/nagios/plugins/check_net_int.sh -w $int_warn$ -c $int_crit$"
vars.by_ssh_command = "sudo /usr/lib/nagios/plugins/check_interface_load.sh -w 10000 -c 20000"
vars.int_warn=""
vars.int_crit=""
}
object CheckCommand "check_open_ports" {
import "by_ssh"
vars.by_ssh_timeout = "420"
timeout = "420"
vars.by_ssh_command = "sudo /usr/lib/nagios/plugins/check_network_ports.sh -p \"$ports$\" -H $host$"
vars.ports=""
vars.host=""
}

View File

@ -0,0 +1,18 @@
object Host "vin-external.openfest.org" {
import "generic-host"
address = "185.117.82.237"
# check_command = "xxx_health"
# vars.extra_port_check = ""
vars.by_ssh_port = "22"
# vars.specification = "router"
vars.net_interfaces = [ "bond0", "bond0.20", "bond0.21", "bond0.22", "bond0.23", "bond0.24", "bond0.25", "bond0.26", "bond0.4001", "eno1", "enp1s0f4", "enp1s0f4d1" ]
vars.open_ports = "80 179 2004 53 22 7002 8443 443"
vars.notification["slack"] = {
groups = [ "icingaadmins"]
}
}

View File

@ -8,26 +8,34 @@
* Check `hosts.conf` for an example. * Check `hosts.conf` for an example.
*/ */
apply Notification "mail-icingaadmin" to Host { #apply Notification "mail-icingaadmin" to Host {
import "mail-host-notification" # import "mail-host-notification"
user_groups = host.vars.notification.mail.groups # user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users # users = host.vars.notification.mail.users
//interval = 2h //interval = 2h
//vars.notification_logtosyslog = true //vars.notification_logtosyslog = true
assign where host.vars.notification.mail # assign where host.vars.notification.mail
} #}
apply Notification "mail-icingaadmin" to Service { //apply Notification "mail-icingaadmin" to Service {
import "mail-service-notification" // import "mail-service-notification"
user_groups = host.vars.notification.mail.groups // user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users // users = host.vars.notification.mail.users
//interval = 2h //interval = 2h
//vars.notification_logtosyslog = true //vars.notification_logtosyslog = true
assign where host.vars.notification.mail // assign where host.vars.notification.mail
//}
apply Notification "slack" to Service {
import "slack-service-notification"
user_groups = host.vars.notification.slack.groups
interval = 1m
vars.notification_logtosyslog = true
assign where host.vars.notification.slack
} }

View File

@ -0,0 +1,24 @@
apply Service "network_interfaces_traffic" {
import "generic-service"
check_interval = 5m
retry_interval = 5m
check_command = "check_net_int"
vars.int_warn="925"
vars.int_crit="950"
assign where host.vars.net_interfaces
vars.notif_prio = "high"
}
apply Service "network_open_ports" {
import "generic-service"
check_interval = 5m
retry_interval = 5m
check_command = "check_open_ports"
vars.ports=host.vars.open_ports
vars.host=host.address
assign where host.vars.open_ports
vars.notif_prio = "high"
}

View File

@ -102,7 +102,7 @@ apply Service "swap" {
check_command = "swap" check_command = "swap"
assign where host.name == NodeName assign where host.vars.swap_size
} }
apply Service "users" { apply Service "users" {

View File

@ -0,0 +1,20 @@
object NotificationCommand "slack-service-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/slack-service-notification.sh" ]
env = {
"NOTIFICATIONTYPE" = "$notification.type$"
"SERVICEDESC" = "$service.name$"
"HOSTALIAS" = "$host.display_name$",
"HOSTNAME" = "$host.name$",
"HOSTADDRESS" = "$address$",
"SERVICESTATE" = "$service.state$",
"LONGDATETIME" = "$icinga.long_date_time$",
"SERVICEOUTPUT" = "$service.output$",
"NOTIFICATIONAUTHORNAME" = "$notification.author$",
"NOTIFICATIONCOMMENT" = "$notification.comment$",
"HOSTDISPLAYNAME" = "$host.display_name$",
"SERVICEDISPLAYNAME" = "$service.display_name$",
}
}

View File

@ -0,0 +1,10 @@
template Notification "slack-service-notification" {
command = "slack-service-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
period = "24x7"
}

View File

@ -3,6 +3,9 @@
* the other configuration files. * the other configuration files.
*/ */
/* XXX: Nice comment */
const SysconfDir = "etc"
/* The directory which contains the plugins from the Monitoring Plugins project. */ /* The directory which contains the plugins from the Monitoring Plugins project. */
const PluginDir = "/usr/lib/nagios/plugins" const PluginDir = "/usr/lib/nagios/plugins"

View File

@ -0,0 +1,12 @@
/**
* The GraphiteWriter type writes check result metrics and
* performance data to a graphite tcp socket.
*/
library "perfdata"
object GraphiteWriter "graphite" {
// host = "127.0.0.1"
// port = 2003
// enable_send_thresholds = true
}

View File

@ -0,0 +1,6 @@
/**
* The PerfdataWriter type writes performance data files and rotates
* them in a regular interval.
*/
object PerfdataWriter "perfdata" { }

View File

@ -0,0 +1,107 @@
#!/bin/bash
ICINGA_HOSTNAME="vin.openfest.org/icingaweb2"
SLACK_WEBHOOK_URL="https://hooks.slack.com/services/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"
SLACK_CHANNEL="#video"
SLACK_BOTNAME="icinga2"
if [ "$NOTIFICATIONTYPE" = "ACKNOWLEDGEMENT" ] || [ "$NOTIFICATIONTYPE" = "DOWNTIMESTART" ] || [ "$NOTIFICATIONTYPE" = "DOWNTIMEEND" ]
then
COLOR="#FFB6C1"
read -d '' PAYLOAD << EOF
{
"channel": "${SLACK_CHANNEL}",
"username": "${SLACK_BOTNAME}",
"attachments": [
{
"fallback": "${NOTIFICATIONTYPE}: ${SERVICESTATE}: ${HOSTDISPLAYNAME} - ${SERVICEDISPLAYNAME}",
"color": "${COLOR}",
"fields": [
{
"title": "${NOTIFICATIONTYPE}",
"value": "${NOTIFICATIONCOMMENT} - ${NOTIFICATIONAUTHORNAME}"
},
{
"title": "Service output",
"value": "${SERVICEOUTPUT}",
"short": false
},
{
"title": "Host",
"value": "<${ICINGA_HOSTNAME}/monitoring/host/services?host=${HOSTNAME}|${HOSTDISPLAYNAME}>",
"short": true
},
{
"title": "Service",
"value": "<${ICINGA_HOSTNAME}/monitoring/service/show?host=${HOSTNAME}&service=${SERVICEDESC}|${SERVICEDISPLAYNAME}>",
"short": true
},
{
"title": "State",
"value": "${SERVICESTATE}",
"short": true
}
]
}
]
}
EOF
else
#Set the message icon based on ICINGA service state
if [ "$SERVICESTATE" = "CRITICAL" ]
then
COLOR="danger"
elif [ "$SERVICESTATE" = "WARNING" ]
then
COLOR="warning"
elif [ "$SERVICESTATE" = "OK" ]
then
COLOR="good"
elif [ "$SERVICESTATE" = "UNKNOWN" ]
then
COLOR="#800080"
else
COLOR=""
fi
#Send message to Slack
read -d '' PAYLOAD << EOF
{
"channel": "${SLACK_CHANNEL}",
"username": "${SLACK_BOTNAME}",
"attachments": [
{
"fallback": "${SERVICESTATE}: ${HOSTDISPLAYNAME} - ${SERVICEDISPLAYNAME}",
"color": "${COLOR}",
"fields": [
{
"title": "Service output",
"value": "${SERVICEOUTPUT}",
"short": false
},
{
"title": "Host",
"value": "<${ICINGA_HOSTNAME}/monitoring/host/services?host=${HOSTNAME}|${HOSTDISPLAYNAME}>",
"short": true
},
{
"title": "Service",
"value": "<${ICINGA_HOSTNAME}/monitoring/service/show?host=${HOSTNAME}&service=${SERVICEDESC}|${SERVICEDISPLAYNAME}>",
"short": true
},
{
"title": "State",
"value": "${SERVICESTATE}",
"short": true
}
]
}
]
}
EOF
fi
curl --connect-timeout 30 --max-time 60 -s -S -X POST -H 'Content-type: application/json' --data "${PAYLOAD}" "${SLACK_WEBHOOK_URL}"

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1,4 @@
[graphite]
metric_prefix = icinga
url = https://vin.openfest.org:8443/render?
args_template = "&target=$target$&source=0&width=300&height=120&hideAxes=true&lineWidth=1&hideLegend=true&hideAxes=false&colorList=049BAF&bgcolor=white&fgcolor=blue&minorLine=green"