Merge branch 'master' of bitbucket.org:tmakinen/puppet
This commit is contained in:
commit
88846f0be4
3 changed files with 160 additions and 60 deletions
|
@ -5,6 +5,7 @@ MAXAGE="<%= mysql_backup_maxage %>"
|
||||||
|
|
||||||
DATE=`date "+%Y-%m-%d"`
|
DATE=`date "+%Y-%m-%d"`
|
||||||
HOME="`getent passwd ${USER} | cut -d : -f 6`"
|
HOME="`getent passwd ${USER} | cut -d : -f 6`"
|
||||||
|
OPTS=""
|
||||||
|
|
||||||
if [ ! -d ${DESTDIR} ]; then
|
if [ ! -d ${DESTDIR} ]; then
|
||||||
echo "ERR: MySQL backup directory [${DESTDIR}] does not exist" 1>&2
|
echo "ERR: MySQL backup directory [${DESTDIR}] does not exist" 1>&2
|
||||||
|
@ -15,6 +16,11 @@ umask 077
|
||||||
|
|
||||||
tmpwatch -m -f ${MAXAGE} ${DESTDIR}
|
tmpwatch -m -f ${MAXAGE} ${DESTDIR}
|
||||||
|
|
||||||
|
mysqldump -E > /dev/null 2>&1
|
||||||
|
if [ $? -ne 2 ]; then
|
||||||
|
OPTS="${OPTS} -E"
|
||||||
|
fi
|
||||||
|
|
||||||
DESTDIR=${DESTDIR}/${DATE}
|
DESTDIR=${DESTDIR}/${DATE}
|
||||||
mkdir -p ${DESTDIR}
|
mkdir -p ${DESTDIR}
|
||||||
|
|
||||||
|
@ -24,5 +30,5 @@ for db in `mysql -e 'show databases' -s` ; do
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
mysqldump --add-drop-table ${db} | gzip > ${DESTDIR}/${db}.${DATE}.gz
|
mysqldump --add-drop-table ${OPTS} ${db} | gzip > ${DESTDIR}/${db}.${DATE}.gz
|
||||||
done
|
done
|
||||||
|
|
|
@ -33,6 +33,10 @@ class nagios::common {
|
||||||
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
||||||
$htdocs = "/usr/share/nagios3/htdocs"
|
$htdocs = "/usr/share/nagios3/htdocs"
|
||||||
}
|
}
|
||||||
|
"openbsd": {
|
||||||
|
# no params set as we don't support server on openbsd yet
|
||||||
|
$libdir = "/usr/local/libexec/nagios"
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
fail("Nagios not supported on ${::operatingsystem}")
|
fail("Nagios not supported on ${::operatingsystem}")
|
||||||
}
|
}
|
||||||
|
@ -67,6 +71,9 @@ class nagios::server::manual inherits nagios::common {
|
||||||
target => "/etc/nagios3/stylesheets",
|
target => "/etc/nagios3/stylesheets",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
fail("nagios::server not supported in ${::operatingsystem}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "usermod-nagios-httpsd":
|
exec { "usermod-nagios-httpsd":
|
||||||
|
|
|
@ -70,6 +70,18 @@ class nagios::target::https inherits nagios::target {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure imaps service target.
|
||||||
|
#
|
||||||
|
class nagios::target::imaps inherits nagios::target {
|
||||||
|
|
||||||
|
@@nagios::service { "${::homename}_imaps":
|
||||||
|
command => "check_imap!--ssl -p 993",
|
||||||
|
description => "IMAPS",
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Configure smtp service target.
|
# Configure smtp service target.
|
||||||
#
|
#
|
||||||
class nagios::target::smtp inherits nagios::target {
|
class nagios::target::smtp inherits nagios::target {
|
||||||
|
@ -96,31 +108,43 @@ class nagios::target::nrpe inherits nagios::target {
|
||||||
"centos","redhat","fedora": {
|
"centos","redhat","fedora": {
|
||||||
$service = "nrpe"
|
$service = "nrpe"
|
||||||
$nrpedir = "/etc/nrpe.d"
|
$nrpedir = "/etc/nrpe.d"
|
||||||
package { [ "nrpe",
|
|
||||||
"nagios-plugins-disk",
|
|
||||||
"nagios-plugins-load",
|
|
||||||
"nagios-plugins-procs",
|
|
||||||
"nagios-plugins-users", ]:
|
|
||||||
ensure => installed,
|
|
||||||
before => [ File["/etc/nrpe.d"], Service["nrpe"] ],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"ubuntu","debian": {
|
"ubuntu","debian": {
|
||||||
$service = "nagios-nrpe-server"
|
$service = "nagios-nrpe-server"
|
||||||
$nrpedir = "/etc/nagios/nrpe.d"
|
$nrpedir = "/etc/nagios/nrpe.d"
|
||||||
package { [ "nagios-nrpe-server",
|
}
|
||||||
"nagios-plugins-basic", ]:
|
"openbsd": {
|
||||||
ensure => installed,
|
$service = "nrpe"
|
||||||
before => [ File["/etc/nrpe.d"], Service["nrpe"] ],
|
$nrpedir = "/etc/nrpe.d"
|
||||||
|
exec { "add-nrpe-include-dir":
|
||||||
|
command => "echo 'include_dir=${nrpedir}/' >> /etc/nrpe.cfg",
|
||||||
|
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||||
|
user => "root",
|
||||||
|
unless => "egrep '^include_dir=${nrpedir}/' /etc/nrpe.cfg",
|
||||||
|
require => Package["nrpe"],
|
||||||
|
notify => Service[$service],
|
||||||
|
before => File[$nrpedir],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package { "nrpe":
|
||||||
|
ensure => installed,
|
||||||
|
name => $::operatingsystem ? {
|
||||||
|
"debian" => "nagios-nrpe-server",
|
||||||
|
"ubuntu" => "nagios-nrpe-server",
|
||||||
|
default => "nrpe",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
file { "/etc/nrpe.d":
|
file { "/etc/nrpe.d":
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
mode => "0644",
|
mode => "0644",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "root",
|
group => $::operatingsystem ? {
|
||||||
|
"openbsd" => "wheel",
|
||||||
|
default => "root",
|
||||||
|
},
|
||||||
purge => true,
|
purge => true,
|
||||||
force => true,
|
force => true,
|
||||||
recurse => true,
|
recurse => true,
|
||||||
|
@ -137,62 +161,125 @@ class nagios::target::nrpe inherits nagios::target {
|
||||||
ensure => present,
|
ensure => present,
|
||||||
mode => "0644",
|
mode => "0644",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "root",
|
group => $::operatingsystem ? {
|
||||||
|
"openbsd" => "wheel",
|
||||||
|
default => "root",
|
||||||
|
},
|
||||||
content => "allowed_hosts=${nagios_allow}\n",
|
content => "allowed_hosts=${nagios_allow}\n",
|
||||||
require => File["/etc/nrpe.d"],
|
require => File["/etc/nrpe.d"],
|
||||||
notify => Service["nrpe"],
|
notify => Service["nrpe"],
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "${nrpedir}/check_disk.cfg":
|
nagios::target::nrpe::service { "check_disk -w 20% -c 10% -p /":
|
||||||
ensure => present,
|
|
||||||
mode => "0644",
|
|
||||||
owner => "root",
|
|
||||||
group => "root",
|
|
||||||
content => "command[check_disk]=${nagios::common::libdir}/check_disk -w 20% -c 10% -p /\n",
|
|
||||||
require => File["/etc/nrpe.d"],
|
|
||||||
notify => Service["nrpe"],
|
|
||||||
}
|
|
||||||
@@nagios::service { "${::homename}_disk":
|
|
||||||
command => "check_nrpe!check_disk",
|
|
||||||
description => "Disk",
|
description => "Disk",
|
||||||
|
package => $::operatingsystem ? {
|
||||||
|
"openbsd" => undef,
|
||||||
|
"debian" => "nagios-plugins-basic",
|
||||||
|
"ubuntu" => "nagios-plugins-basic",
|
||||||
|
default => "nagios-plugins-disk",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
nagios::target::nrpe::service { "check_load -r -w 3,2,1 -c 6,4,2":
|
||||||
file { "${nrpedir}/check_load.cfg":
|
|
||||||
ensure => present,
|
|
||||||
mode => "0644",
|
|
||||||
owner => "root",
|
|
||||||
group => "root",
|
|
||||||
content => "command[check_load]=${nagios::common::libdir}/check_load -r -w 3,2,1 -c 6,4,2\n",
|
|
||||||
require => File["/etc/nrpe.d"],
|
|
||||||
notify => Service["nrpe"],
|
|
||||||
}
|
|
||||||
@@nagios::service { "${::homename}_load":
|
|
||||||
command => "check_nrpe!check_load",
|
|
||||||
description => "Load",
|
description => "Load",
|
||||||
|
package => $::operatingsystem ? {
|
||||||
|
"openbsd" => undef,
|
||||||
|
"debian" => "nagios-plugins-basic",
|
||||||
|
"ubuntu" => "nagios-plugins-basic",
|
||||||
|
default => "nagios-plugins-load",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
nagios::target::nrpe::service { "check_swap -w 75% -c 50%":
|
||||||
file { "${nrpedir}/check_swap.cfg":
|
|
||||||
ensure => present,
|
|
||||||
mode => "0644",
|
|
||||||
owner => "root",
|
|
||||||
group => "root",
|
|
||||||
content => "command[check_swap]=${nagios::common::libdir}/check_swap -w 75% -c 50%\n",
|
|
||||||
require => File["/etc/nrpe.d"],
|
|
||||||
notify => Service["nrpe"],
|
|
||||||
}
|
|
||||||
@@nagios::service { "${::homename}_swap":
|
|
||||||
command => "check_nrpe!check_swap",
|
|
||||||
description => "Swap",
|
description => "Swap",
|
||||||
|
package => $::operatingsystem ? {
|
||||||
|
"openbsd" => undef,
|
||||||
|
"debian" => "nagios-plugins-basic",
|
||||||
|
"ubuntu" => "nagios-plugins-basic",
|
||||||
|
default => "nagios-plugins-swap",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# @@nagios::service { "${::homename}_users":
|
|
||||||
# command => "check_nrpe!check_users",
|
|
||||||
# description => "Users",
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# @@nagios::service { "${::homename}_procs":
|
|
||||||
# command => "check_nrpe!check_total_procs",
|
|
||||||
# description => "Processes",
|
|
||||||
# }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Add new nagios nrpe service check
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# Check command.
|
||||||
|
# $description:
|
||||||
|
# Service description. Defaults to command name without
|
||||||
|
# check_ prefix.
|
||||||
|
# $package:
|
||||||
|
# Package providing check command.
|
||||||
|
# $source:
|
||||||
|
# Source file for check command.
|
||||||
|
#
|
||||||
|
# === Example usage
|
||||||
|
#
|
||||||
|
# nagios::target::nrpe::service { "check_disk -w 20% -c 10% -p /":
|
||||||
|
# description => "Disk",
|
||||||
|
# package => $::operatingsystem ? {
|
||||||
|
# "openbsd" => undef,
|
||||||
|
# "debian" => "nagios-plugins-basic",
|
||||||
|
# "ubuntu" => "nagios-plugins-basic",
|
||||||
|
# default => "nagios-plugins-disk",
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
define nagios::target::nrpe::service($source=undef,
|
||||||
|
$description=undef,
|
||||||
|
$package=undef) {
|
||||||
|
|
||||||
|
include nagios::target::nrpe
|
||||||
|
|
||||||
|
$binary = regsubst($name, '^([^ ]+) .*', '\1')
|
||||||
|
$service = regsubst($binary, '^check_(.+)', '\1')
|
||||||
|
|
||||||
|
if !$description {
|
||||||
|
$description = $service
|
||||||
|
}
|
||||||
|
|
||||||
|
if $source {
|
||||||
|
file { "${nagios::common::libdir}/${binary}":
|
||||||
|
ensure => present,
|
||||||
|
source => $source,
|
||||||
|
mode => "0755",
|
||||||
|
owner => "root",
|
||||||
|
group => $::operatingsystem ? {
|
||||||
|
"openbsd" => "wheel",
|
||||||
|
default => "root",
|
||||||
|
},
|
||||||
|
require => Package["nrpe"],
|
||||||
|
notify => Service["nrpe"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $package and !defined(Package[$package]) {
|
||||||
|
package { $package:
|
||||||
|
ensure => present,
|
||||||
|
require => Package["nrpe"],
|
||||||
|
before => Service["nrpe"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "${nagios::target::nrpe::nrpedir}/${binary}.cfg":
|
||||||
|
ensure => present,
|
||||||
|
mode => "0644",
|
||||||
|
owner => "root",
|
||||||
|
group => $::operatingsystem ? {
|
||||||
|
"openbsd" => "wheel",
|
||||||
|
default => "root",
|
||||||
|
},
|
||||||
|
content => "command[${binary}]=${nagios::common::libdir}/${name}\n",
|
||||||
|
require => File["/etc/nrpe.d"],
|
||||||
|
notify => Service["nrpe"],
|
||||||
|
}
|
||||||
|
|
||||||
|
@@nagios::service { "${::homename}_${service}":
|
||||||
|
command => "check_nrpe!${binary}",
|
||||||
|
description => $description,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue