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"`
|
||||
HOME="`getent passwd ${USER} | cut -d : -f 6`"
|
||||
OPTS=""
|
||||
|
||||
if [ ! -d ${DESTDIR} ]; then
|
||||
echo "ERR: MySQL backup directory [${DESTDIR}] does not exist" 1>&2
|
||||
|
@ -15,6 +16,11 @@ umask 077
|
|||
|
||||
tmpwatch -m -f ${MAXAGE} ${DESTDIR}
|
||||
|
||||
mysqldump -E > /dev/null 2>&1
|
||||
if [ $? -ne 2 ]; then
|
||||
OPTS="${OPTS} -E"
|
||||
fi
|
||||
|
||||
DESTDIR=${DESTDIR}/${DATE}
|
||||
mkdir -p ${DESTDIR}
|
||||
|
||||
|
@ -24,5 +30,5 @@ for db in `mysql -e 'show databases' -s` ; do
|
|||
continue
|
||||
;;
|
||||
esac
|
||||
mysqldump --add-drop-table ${db} | gzip > ${DESTDIR}/${db}.${DATE}.gz
|
||||
mysqldump --add-drop-table ${OPTS} ${db} | gzip > ${DESTDIR}/${db}.${DATE}.gz
|
||||
done
|
||||
|
|
|
@ -33,6 +33,10 @@ class nagios::common {
|
|||
$cgibin = "/usr/lib/cgi-bin/nagios3"
|
||||
$htdocs = "/usr/share/nagios3/htdocs"
|
||||
}
|
||||
"openbsd": {
|
||||
# no params set as we don't support server on openbsd yet
|
||||
$libdir = "/usr/local/libexec/nagios"
|
||||
}
|
||||
default: {
|
||||
fail("Nagios not supported on ${::operatingsystem}")
|
||||
}
|
||||
|
@ -67,6 +71,9 @@ class nagios::server::manual inherits nagios::common {
|
|||
target => "/etc/nagios3/stylesheets",
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("nagios::server not supported in ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
#
|
||||
class nagios::target::smtp inherits nagios::target {
|
||||
|
@ -96,23 +108,32 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
"centos","redhat","fedora": {
|
||||
$service = "nrpe"
|
||||
$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": {
|
||||
$service = "nagios-nrpe-server"
|
||||
$nrpedir = "/etc/nagios/nrpe.d"
|
||||
package { [ "nagios-nrpe-server",
|
||||
"nagios-plugins-basic", ]:
|
||||
ensure => installed,
|
||||
before => [ File["/etc/nrpe.d"], Service["nrpe"] ],
|
||||
}
|
||||
"openbsd": {
|
||||
$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",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +141,10 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
ensure => directory,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
purge => true,
|
||||
force => true,
|
||||
recurse => true,
|
||||
|
@ -137,62 +161,125 @@ class nagios::target::nrpe inherits nagios::target {
|
|||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
content => "allowed_hosts=${nagios_allow}\n",
|
||||
require => File["/etc/nrpe.d"],
|
||||
notify => Service["nrpe"],
|
||||
}
|
||||
|
||||
file { "${nrpedir}/check_disk.cfg":
|
||||
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",
|
||||
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",
|
||||
}
|
||||
|
||||
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",
|
||||
nagios::target::nrpe::service { "check_load -r -w 3,2,1 -c 6,4,2":
|
||||
description => "Load",
|
||||
package => $::operatingsystem ? {
|
||||
"openbsd" => undef,
|
||||
"debian" => "nagios-plugins-basic",
|
||||
"ubuntu" => "nagios-plugins-basic",
|
||||
default => "nagios-plugins-load",
|
||||
}
|
||||
|
||||
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",
|
||||
nagios::target::nrpe::service { "check_swap -w 75% -c 50%":
|
||||
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",
|
||||
}
|
||||
|
||||
|
||||
# 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",
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# @@nagios::service { "${::homename}_procs":
|
||||
# command => "check_nrpe!check_total_procs",
|
||||
# description => "Processes",
|
||||
# }
|
||||
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