Added support for checking ESXi hosts with Nagios
This commit is contained in:
parent
6f1c01ea81
commit
aadf34cbe8
2 changed files with 146 additions and 2 deletions
|
@ -245,12 +245,22 @@ define command{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 'notify-host-by-prowl' command definition
|
||||||
define command{
|
define command{
|
||||||
command_name notify-host-by-prowl
|
command_name notify-host-by-prowl
|
||||||
command_line /usr/bin/curl -s -o /dev/null -F apikey="$CONTACTADDRESS1$" -F application="Nagios" -F event="$NOTIFICATIONTYPE$ Host Alert" -F description="$HOSTNAME$ is $HOSTSTATE$ '$HOSTOUTPUT$'" "https://prowl.weks.net/publicapi/add"
|
command_line /usr/bin/curl -s -o /dev/null -F apikey="$CONTACTADDRESS1$" -F application="Nagios" -F event="$NOTIFICATIONTYPE$ Host Alert" -F description="$HOSTNAME$ is $HOSTSTATE$ '$HOSTOUTPUT$'" "https://prowl.weks.net/publicapi/add"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 'notify-service-by-prowl' command definition
|
||||||
define command{
|
define command{
|
||||||
command_name notify-service-by-prowl
|
command_name notify-service-by-prowl
|
||||||
command_line /usr/bin/curl -s -o /dev/null -F apikey="$CONTACTADDRESS1$" -F application="Nagios" -F event="$NOTIFICATIONTYPE$ Service Alert" -F description="$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ '$SERVICEOUTPUT$'" "https://prowl.weks.net/publicapi/add"
|
command_line /usr/bin/curl -s -o /dev/null -F apikey="$CONTACTADDRESS1$" -F application="Nagios" -F event="$NOTIFICATIONTYPE$ Service Alert" -F description="$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ '$SERVICEOUTPUT$'" "https://prowl.weks.net/publicapi/add"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 'check_esxi_hardware' command definition
|
||||||
|
define command{
|
||||||
|
command_name check_esxi_hardware
|
||||||
|
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U file:$ARG1$ -P file:$ARG1$ -V $ARG2$
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
|
# Install Nagios server.
|
||||||
|
#
|
||||||
class nagios::server {
|
class nagios::server {
|
||||||
|
|
||||||
case $operatingsystem {
|
case $operatingsystem {
|
||||||
"centos","redhat","fedora": {
|
"centos","redhat","fedora": {
|
||||||
$etcdir = "/etc/nagios"
|
$etcdir = "/etc/nagios"
|
||||||
$confdir = "${etcdir}/conf.d"
|
$confdir = "${etcdir}/conf.d"
|
||||||
|
$private = "${etcdir}/private.d"
|
||||||
$package = "nagios"
|
$package = "nagios"
|
||||||
$service = "nagios"
|
$service = "nagios"
|
||||||
$scriptalias = "/nagios/cgi-bin/"
|
$scriptalias = "/nagios/cgi-bin/"
|
||||||
|
$libdir = $architecture ? {
|
||||||
|
"x86_64" => "/usr/lib64/nagios/plugins",
|
||||||
|
default => "/usr/lib/nagios/plugins",
|
||||||
|
}
|
||||||
$cgibin = $architecture ? {
|
$cgibin = $architecture ? {
|
||||||
"x86_64" => "/usr/lib64/nagios/cgi-bin",
|
"x86_64" => "/usr/lib64/nagios/cgi-bin",
|
||||||
default => "/usr/lib/nagios/cgi-bin",
|
default => "/usr/lib/nagios/cgi-bin",
|
||||||
|
@ -16,9 +23,11 @@ class nagios::server {
|
||||||
"ubuntu","debian": {
|
"ubuntu","debian": {
|
||||||
$etcdir = "/etc/nagios3"
|
$etcdir = "/etc/nagios3"
|
||||||
$confdir = "${etcdir}/conf.d"
|
$confdir = "${etcdir}/conf.d"
|
||||||
|
$private = "${etcdir}/private.d"
|
||||||
$package = "nagios3"
|
$package = "nagios3"
|
||||||
$service = "nagios3"
|
$service = "nagios3"
|
||||||
$scriptalias = "/cgi-bin/nagios3/"
|
$scriptalias = "/cgi-bin/nagios3/"
|
||||||
|
$libdir = "/usr/lib/nagios/plugins"
|
||||||
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
||||||
$htdocs = "/usr/share/nagios3/htdocs"
|
$htdocs = "/usr/share/nagios3/htdocs"
|
||||||
}
|
}
|
||||||
|
@ -113,6 +122,19 @@ class nagios::server {
|
||||||
require => Package["nagios"],
|
require => Package["nagios"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file { "/etc/nagios/private.d":
|
||||||
|
name => $private,
|
||||||
|
ensure => directory,
|
||||||
|
mode => "0640",
|
||||||
|
owner => "root",
|
||||||
|
group => "nagios",
|
||||||
|
purge => true,
|
||||||
|
force => true,
|
||||||
|
recurse => true,
|
||||||
|
source => "puppet:///modules/custom/empty",
|
||||||
|
require => Package["nagios"],
|
||||||
|
}
|
||||||
|
|
||||||
file { "${confdir}/contactgroup_all.cfg":
|
file { "${confdir}/contactgroup_all.cfg":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
mode => "0640",
|
mode => "0640",
|
||||||
|
@ -221,7 +243,13 @@ class nagios::server {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Define nagios email contact.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# Email address.
|
||||||
|
#
|
||||||
define nagios::contact::email($confdir=$nagios::server::confdir) {
|
define nagios::contact::email($confdir=$nagios::server::confdir) {
|
||||||
|
|
||||||
file { "${confdir}/contact_${name}.cfg":
|
file { "${confdir}/contact_${name}.cfg":
|
||||||
|
@ -247,6 +275,13 @@ define nagios::contact::email($confdir=$nagios::server::confdir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Define nagios prowl contact.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# Prowl API key.
|
||||||
|
#
|
||||||
define nagios::contact::prowl($confdir=$nagios::server::confdir) {
|
define nagios::contact::prowl($confdir=$nagios::server::confdir) {
|
||||||
|
|
||||||
file { "${confdir}/contact_${name}.cfg":
|
file { "${confdir}/contact_${name}.cfg":
|
||||||
|
@ -272,7 +307,18 @@ define nagios::contact::prowl($confdir=$nagios::server::confdir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
define nagios::host($confdir, $osname, $osicon) {
|
# Define nagios target host.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# Hostname of target.
|
||||||
|
# $osname:
|
||||||
|
# Operating system name for hostextinfo.
|
||||||
|
# $osicon:
|
||||||
|
# Operating system icon name for hostextinfo.
|
||||||
|
#
|
||||||
|
define nagios::host($confdir, $osname="NONE", $osicon="NONE") {
|
||||||
|
|
||||||
file { "${confdir}/host_${name}.cfg":
|
file { "${confdir}/host_${name}.cfg":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
|
@ -317,6 +363,17 @@ define nagios::host($confdir, $osname, $osicon) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Define nagios target service.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $host:
|
||||||
|
# Target hostname.
|
||||||
|
# $command:
|
||||||
|
# Check command.
|
||||||
|
# $description:
|
||||||
|
# Service description.
|
||||||
|
#
|
||||||
define nagios::service($confdir, $host, $command, $description) {
|
define nagios::service($confdir, $host, $command, $description) {
|
||||||
|
|
||||||
file { "${confdir}/service_${name}.cfg":
|
file { "${confdir}/service_${name}.cfg":
|
||||||
|
@ -338,6 +395,8 @@ define nagios::service($confdir, $host, $command, $description) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure nagios target.
|
||||||
|
#
|
||||||
class nagios::target {
|
class nagios::target {
|
||||||
|
|
||||||
@@nagios::host { $fqdn:
|
@@nagios::host { $fqdn:
|
||||||
|
@ -351,6 +410,8 @@ class nagios::target {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure nagios nrpe target.
|
||||||
|
#
|
||||||
class nagios::target::nrpe {
|
class nagios::target::nrpe {
|
||||||
|
|
||||||
if !$nagios_allow {
|
if !$nagios_allow {
|
||||||
|
@ -402,6 +463,8 @@ class nagios::target::nrpe {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure ssh service target.
|
||||||
|
#
|
||||||
class nagios::target::ssh {
|
class nagios::target::ssh {
|
||||||
|
|
||||||
include nagios::target
|
include nagios::target
|
||||||
|
@ -415,6 +478,8 @@ class nagios::target::ssh {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure http service target.
|
||||||
|
#
|
||||||
class nagios::target::http {
|
class nagios::target::http {
|
||||||
|
|
||||||
include nagios::target
|
include nagios::target
|
||||||
|
@ -428,6 +493,8 @@ class nagios::target::http {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure https service target.
|
||||||
|
#
|
||||||
class nagios::target::https {
|
class nagios::target::https {
|
||||||
|
|
||||||
include nagios::target
|
include nagios::target
|
||||||
|
@ -441,6 +508,8 @@ class nagios::target::https {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure smtp service target.
|
||||||
|
#
|
||||||
class nagios::target::smtp {
|
class nagios::target::smtp {
|
||||||
|
|
||||||
include nagios::target
|
include nagios::target
|
||||||
|
@ -452,3 +521,68 @@ class nagios::target::smtp {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Install check_esxi_hardware.py plugin.
|
||||||
|
#
|
||||||
|
class nagios::plugin::esxi {
|
||||||
|
|
||||||
|
package { "pywbem":
|
||||||
|
ensure => installed,
|
||||||
|
name => $::operatingsystem ? {
|
||||||
|
"debian" => "python-pywbem",
|
||||||
|
"ubuntu" => "python-pywbem",
|
||||||
|
default => "pywbem",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "${nagios::server::libdir}/check_esxi_hardware.py":
|
||||||
|
ensure => present,
|
||||||
|
mode => "0755",
|
||||||
|
owner => "root",
|
||||||
|
group => "root",
|
||||||
|
source => "puppet:///files/nagios/check_esxi_hardware.py",
|
||||||
|
require => Package["nagios"],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Define ESXi target host.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# Target hostname.
|
||||||
|
# $user:
|
||||||
|
# ESXi host username.
|
||||||
|
# $pass:
|
||||||
|
# ESXi host password.
|
||||||
|
# $vendor:
|
||||||
|
# ESXi host vendor. Defaults to "auto".
|
||||||
|
#
|
||||||
|
define nagios::host::esxi($user, $pass, $vendor="auto") {
|
||||||
|
|
||||||
|
file { "${nagios::server::private}/esxi_${name}.cfg":
|
||||||
|
ensure => present,
|
||||||
|
mode => "0640",
|
||||||
|
owner => "root",
|
||||||
|
group => "nagios",
|
||||||
|
content => "${user} ${pass}\n",
|
||||||
|
require => File["/etc/nagios/private.d"],
|
||||||
|
}
|
||||||
|
|
||||||
|
nagios::host { $name:
|
||||||
|
confdir => $nagios::server::confdir,
|
||||||
|
notify => Service["nagios"],
|
||||||
|
}
|
||||||
|
|
||||||
|
nagios::service { "${name}_esxi":
|
||||||
|
host => $name,
|
||||||
|
command => "check_esxi_hardware!${nagios::server::private}/esxi_${name}.cfg!${vendor}",
|
||||||
|
description => "ESXi",
|
||||||
|
confdir => $nagios::server::confdir,
|
||||||
|
notify => Service["nagios"],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue