1
0
Fork 0
forked from infra/ansible

Nagios: remove nagios_server role

Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
Greg Sutcliffe 2026-07-02 13:39:18 +01:00
commit 9b65ab416b
Signed by: gwmngilfen
SSH key fingerprint: SHA256:dNHcz65ApR68w2TkCIAXDBdt4oNL62Fyx48U7dXWuk0
130 changed files with 0 additions and 7456 deletions

View file

@ -63,7 +63,6 @@
- { role: dhcp_server, when: datacenter == 'rdu3' }
- { role: tftp_server, when: datacenter == 'rdu3' }
- { role: firmware_proxy, when: datacenter == 'rdu3' }
- { role: nagios_server, when: datacenter == 'ibiblio' or datacenter == 'rdu3' }
- { role: zabbix/datanommer, when: datacenter == 'rdu3' }
tasks:

View file

@ -1,78 +0,0 @@
===================================
Nagios 4 Configuration for Fedora
===================================
The Fedora Infrastructure Nagios is built on a set of configurations
originally written for Nagios 2 and then upgraded over time to Nagios
3 and then 4.08. With additional changes made in the 4.2 series of
Nagios this needed a better rewrite as various parts came from
pre-puppet and then various puppet modules added on top.
In order to get this rewrite done, we will use as much of the original
layout of the Fedora ansible nagios module but with rewrites to better
match current Nagios configurations so that it can be maintained.
Role directory layout
=====================
The original layout branched out from
roles/nagios/client/
roles/nagios/server/
With the usual trees below this. This breaks ansible best practices
and how most new modules are set up so the rewrite uses:
roles/nagios_client/
roles/nagios_server/
=====================
Nagios Server Files
=====================
The Nagios Server Files require a large layout change. The original
Nagios system used multiple independant modes and files which caused
problems when hosts were removed. The new system will use hosts set up
from the Fedora Ansible Inventory with hostgroups set up to match
groups.
roles/nagios_server/{files,handlers,tasks,templates}
r.../n.../files/httpd ==> /etc/httpd/conf.d files
r.../n.../files/nagios ==> /etc/nagios/ files
r.../n.../files/nagios/commands command files
r.../n.../files/nagios/hosts host files
r.../n.../files/nagios/hostgroups groups made from hosts
r.../n.../files/nagios/services services
r.../n.../files/nagios/servicegroups groups made from services
r.../n.../files/nagios/contacts files for people
r.../n.../files/nagios/contactgroups groups made from contacts
similar layout for templates
handlers has the ways to restart and check configuration
tasks has the main rules for building stuff.
===================
Nagios Module Steps
===================
1. Check to see if the nagios user is configured. Someone years ago
chose that our monitoring uses UID/GID 420. Har Har.
Setup any other groups and permissions
2. Install the needed packages for the server.
3. Setup the directories on the server
/etc/nagios/{child}
4. Synchonise over the static files
/etc/nagios/commands/
/etc/nagios/services/
/etc/nagios/servicegroups/
/etc/nagios/contacts/
/etc/nagios/contactgroups/
/usr/lib64/nagios/plugins/
/usr/local/bin
/usr/share/nagios/html/
5. Build template files
/etc/nagios/commands/
/etc/nagios/hosts/{ansible-inventory, ansible-vars, other}
/etc/nagios/hostgroups/
6. Fix selinux policy
7. Restart services

View file

@ -1,28 +0,0 @@
# noc1
ScriptAlias /nagios/cgi-bin/ /usr/lib64/nagios/cgi-bin/
ScriptAlias /tac.cgi /usr/lib64/nagios/cgi-bin/tac.cgi
<Location />
AuthName "Nagios GSSAPI Login"
GssapiCredStore keytab:/etc/krb5.HTTP_nagios.stg.fedoraproject.org.keytab
AuthType GSSAPI
# This is off because Apache (and thus mod_auth_gssapi) doesn't know this is proxied over TLS
GssapiSSLonly Off
GssapiLocalName on
Require valid-user
</Location>
<Location ~ "/(nagios)/cgi-bin/">
Options ExecCGI
</Location>
<Directory "/usr/share/nagios/html">
Options None
</Directory>
RewriteEngine on
RewriteRule ^/$ /nagios/ [R]
Alias /nagios /usr/share/nagios/html/

View file

@ -1,28 +0,0 @@
# noc1
ScriptAlias /nagios/cgi-bin/ /usr/lib64/nagios/cgi-bin/
ScriptAlias /tac.cgi /usr/lib64/nagios/cgi-bin/tac.cgi
<Location />
AuthName "Nagios GSSAPI Login"
GssapiCredStore keytab:/etc/krb5.HTTP_nagios.fedoraproject.org.keytab
AuthType GSSAPI
# This is off because Apache (and thus mod_auth_gssapi) doesn't know this is proxied over TLS
GssapiSSLonly Off
GssapiLocalName on
Require valid-user
</Location>
<Location ~ "/(nagios)/cgi-bin/">
Options ExecCGI
</Location>
<Directory "/usr/share/nagios/html">
Options None
</Directory>
RewriteEngine on
RewriteRule ^/$ /nagios/ [R]
Alias /nagios /usr/share/nagios/html/

View file

@ -1,2 +0,0 @@
User-Agent: *
Disallow: /

View file

@ -1,15 +0,0 @@
define command {
command_name check_by_ssh_check_raid
command_line $USER1$/check_by_ssh -t 30 -H $HOSTADDRESS$ "$USER1$/check_raid.py"
}
define command {
command_name check_by_ssh_check_disk
command_line $USER1$/check_by_ssh -t 30 -H $HOSTADDRESS$ "$USER1$/check_disk -w $ARG1$% -c $ARG2$% -p $ARG3$"
}
# 'check_postgres_conns' command definition
define command{
command_name check_postgres_conns
command_line $USER1$/check_by_ssh -t 30 -H $HOSTADDRESS$ "$USER1$/check_procs -u postgres -w $ARG1$ -c $ARG2$ -a $ARG3$"
}

View file

@ -1,11 +0,0 @@
# 'check_dns' command definition
define command{
command_name check_dns
command_line $USER1$/check_dns -H www.yahoo.com -s $HOSTADDRESS$
}
# 'check_dns_fpo' command definition
define command{
command_name check_dns_fpo
command_line $USER1$/check_dns -t 30 -H fedoraproject.org -A -s $HOSTADDRESS$
}

View file

@ -1,8 +0,0 @@
# 'check_git' command definition
# I'd like this to actually interact with GIT, but I can't find any
# proper documentation on the protocol to craft send/expect/quit
# strings.
define command{
command_name check_git
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 9418
}

View file

@ -1,89 +0,0 @@
##
## This file has the commands to check and restart general httpd services
## and websites.
##
################################################################################
# COMMAND DEFINITIONS
#
# SYNTAX:
#
# define command{
# template <templatename>
# name <objectname>
# command_name <commandname>
# command_line <commandline>
# }
#
# WHERE:
#
# <templatename> = object name of another command definition that should be
# used as a template for this definition (optional)
# <objectname> = object name of command definition, referenced by other
# command definitions that use it as a template (optional)
# <commandname> = name of the command, as recognized/used by Nagios
# <commandline> = command line
#
################################################################################
# 'reload httpd'
define command {
command_name restart_httpd
command_line $USER1$/restart_httpd $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$ "$HOSTALIAS$" "$SERVICEDESC$" "$SERVICESTATE$"
}
#
# 'check_website_publiclist' command definition
define command{
command_name check_website_publiclist
command_line $USER1$/check_http -w 60 -c 80 -I $HOSTADDRESS$ -H $ARG1$ -u "$ARG2$" -s "$ARG3$"
}
# 'check_website' command definition
define command{
command_name check_website
command_line $USER1$/check_http -w 30 -c 40 -I $HOSTADDRESS$ -H $ARG1$ -u "$ARG2$" -s "$ARG3$"
}
define command{
command_name check_website_follow
command_line $USER1$/check_http -w 30 -c 40 -I $HOSTADDRESS$ -H $ARG1$ -u "$ARG2$" -s "$ARG3$" -f follow
}
define command{
command_name check_website_ppc
command_line $USER1$/check_http -w 300 -c 400 -I $HOSTADDRESS$ -H $ARG1$ -u "$ARG2$" -s "$ARG3$"
}
define command{
command_name check_website_ssl
command_line $USER1$/check_http -w 30 -c 40 --ssl --sni -I $HOSTADDRESS$ -H $ARG1$ -u $ARG2$ -s "$ARG3$"
}
define command{
command_name check_ssl_cert
command_line $USER1$/check_http --sni -I $HOSTADDRESS$ -H $ARG1$ -C $ARG2$
}
define command{
command_name check_ssl_cert_otherport
command_line $USER1$/check_http --sni -I $HOSTADDRESS$ -H $ARG1$ -C $ARG2$ -p $ARG3$
}
define command{
command_name check_website_publiclist_ssl
command_line $USER1$/check_http -w 40 -c 60 --ssl -I $HOSTADDRESS$ -H $ARG1$ -u $ARG2$ -s "$ARG3$"
}
# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$
}
# 'check_https' command definition
define command{
command_name check_https
command_line $USER1$/check_http -H $HOSTADDRESS$ --ssl
}

View file

@ -1,34 +0,0 @@
################################################################################
# COMMAND DEFINITIONS
#
# SYNTAX:
#
# define command{
# template <templatename>
# name <objectname>
# command_name <commandname>
# command_line <commandline>
# }
#
# WHERE:
#
# <templatename> = object name of another command definition that should be
# used as a template for this definition (optional)
# <objectname> = object name of command definition, referenced by other
# command definitions that use it as a template (optional)
# <commandname> = name of the command, as recognized/used by Nagios
# <commandline> = command line
#
################################################################################
# 'check_koji'
define command{
command_name check_koji
command_line $USER1$/check_koji
}
# 'check_koji_wellness'
define command {
command_name check_koji_wellness.py
command_line $USER1$/check_koji_wellness.py $ARG1$ $ARG2$
}

View file

@ -1,36 +0,0 @@
# 'check_local_disk' command definition
define command{
command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
}
# 'check_local_load' command definition
define command{
command_name check_local_load
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
}
# 'check_local_procs' command definition
define command{
command_name check_local_procs
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
}
# 'check_local_users' command definition
define command{
command_name check_local_users
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}
# 'check_local_swap' command definition
define command{
command_name check_local_swap
command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$
}
# 'check_local_mrtgtraf' command definition
define command{
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
}

View file

@ -1,29 +0,0 @@
################################################################################
# COMMAND DEFINITIONS
#
# SYNTAX:
#
# define command{
# template <templatename>
# name <objectname>
# command_name <commandname>
# command_line <commandline>
# }
#
# WHERE:
#
# <templatename> = object name of another command definition that should be
# used as a template for this definition (optional)
# <objectname> = object name of command definition, referenced by other
# command definitions that use it as a template (optional)
# <commandname> = name of the command, as recognized/used by Nagios
# <commandline> = command line
#
################################################################################
# 'check_mailman_api'
define command{
command_name check_mailman_api
command_line $USER1$/check_http -H localhost -p 8001 -u /3.0
}

View file

@ -1,59 +0,0 @@
################################################################################
# COMMAND DEFINITIONS
#
# SYNTAX:
#
# define command{
# template <templatename>
# name <objectname>
# command_name <commandname>
# command_line <commandline>
# }
#
# WHERE:
#
# <templatename> = object name of another command definition that should be
# used as a template for this definition (optional)
# <objectname> = object name of command definition, referenced by other
# command definitions that use it as a template (optional)
# <commandname> = name of the command, as recognized/used by Nagios
# <commandline> = command line
#
################################################################################
define command{
command_name true
command_line /bin/true
}
define command{
command_name check_dummy
command_line $USER1$/check_dummy $ARG1$ $ARG2$
}
# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
# 'check_nntp' command definition
define command{
command_name check_nntp
command_line $USER1$/check_nntp -H $HOSTADDRESS$
}
# 'check_telnet' command definition
define command{
command_name check_telnet
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 23
}
# 'check_dhcp' command definition
define command{
command_name check_dhcp
command_line $USER1$/check_dhcp $ARG1$
}

View file

@ -1,86 +0,0 @@
################################################################################
#
# SAMPLE NOTIFICATION COMMANDS
#
# These are some example notification commands. They may or may not work on
# your system without modification. As an example, some systems will require
# you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
#
################################################################################
# 'host-notify-by-email' command definition
define command{
command_name host-notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nSource: $$(hostname)\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$
}
# 'notify-by-epager' command definition
define command{
command_name notify-by-epager
command_line /usr/bin/printf "%b" "Service: $SERVICEDESC$\nHost: $HOSTNAME$\nInfo: $SERVICEOUTPUT$\nSource: $$(hostname -s)\nDate: $LONGDATETIME$" | /bin/mail -s "$NOTIFICATIONTYPE$: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$
}
# 'host-notify-by-epager' command definition
define command{
command_name host-notify-by-epager
command_line /usr/bin/printf "%b" "Host '$HOSTNAME$' is $HOSTSTATE$\nInfo: $HOSTOUTPUT$\nSource: $$(hostname -s)\nTime: $LONGDATETIME$" | /bin/mail -s "$NOTIFICATIONTYPE$ alert - Host $HOSTNAME$ is $HOSTSTATE$" $CONTACTPAGER$
}
# 'host-notify-by-ircbot' command definition
define command{
command_name host-notify-by-ircbot
command_line /usr/bin/printf "%b" "#fedora-noc $NOTIFICATIONTYPE$ - $HOSTNAME$ is $HOSTSTATE$: $HOSTOUTPUT$ ($$(hostname -s)) $HOSTACKAUTHOR$ $SERVICEACKAUTHOR$" | /usr/local/bin/irc-colorize.py | nc -w 1 value01 5050
}
# 'host-notify-by-matrixbot' command definition
define command{
command_name host-notify-by-matrixbot
command_line /usr/bin/echo '{"notificationtype": "$NOTIFICATIONTYPE$", "hostname": "$HOSTNAME$", "servicestate": "$HOSTSTATE$", "serviceoutput": "$HOSTOUTPUT$", "hostackauthor": "$HOSTACKAUTHOR$"}' | /usr/local/bin/matrix-notify.sh false
}
# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nSource: $$(hostname)\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
# 'notify-by-ircbot' command definition
define command{
command_name notify-by-ircbot
command_line /usr/bin/printf "%b" "#fedora-noc $NOTIFICATIONTYPE$ - $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$: $SERVICEOUTPUT$ ($$(hostname -s)) $HOSTACKAUTHOR$ $SERVICEACKAUTHOR$" | /usr/local/bin/irc-colorize.py | nc -w 1 value01 5050
}
# 'notify-by-matrixbot' command definition
define command{
command_name notify-by-matrixbot
command_line /usr/bin/echo '{"notificationtype": "$NOTIFICATIONTYPE$", "hostname": "$HOSTNAME$", "servicedesc": "$SERVICEDESC$", "servicestate": "$SERVICESTATE$", "serviceoutput": "$SERVICEOUTPUT$", "hostackauthor": "$HOSTACKAUTHOR$", "serviceackauthor": "$SERVICEACKAUTHOR$"}' | /usr/local/bin/matrix-notify.sh true
}
# 'host-notify-by-fedora-messaging' command definition
#define command{
# command_name host-notify-by-fedora-messaging
# command_line /usr/bin/echo '{"type": "$NOTIFICATIONTYPE$", "host": "$HOSTNAME$", "state": "$HOSTSTATE$", "output": "$HOSTOUTPUT$", "host_ack_author": "$HOSTACKAUTHOR$", "service_ack_author": "$SERVICEACKAUTHOR$"}' | fedora-messaging-logger --cert-prefix nagios --modname nagios --topic host.state.change --json-input
# }
# 'notify-by-fedora-messaging' command definition
#define command{
# command_name notify-by-fedora-messaging
# command_line /usr/bin/echo '{"type": "$NOTIFICATIONTYPE$", "host": "$HOSTNAME$", "state": "$SERVICESTATE$", "service": "$SERVICEDESC$", "output": "$SERVICEOUTPUT$", "host_ack_author" "$HOSTACKAUTHOR$", "service_ack_author": "$SERVICEACKAUTHOR$"}' | fedora-messaging-logger --cert-prefix nagios --modname nagios --topic service.state.change --json-input
# }
# 'notify-by-xmpp' command definition
#define command{
# command_name notify-by-xmpp
# command_line /usr/local/bin/xmppsend -a /etc/nagios/private/xmppnagios.ini "Service: $SERVICEDESC$\nHost: $HOSTNAME$\nInfo: $SERVICEOUTPUT$\nDate: $LONGDATETIME$" $CONTACTEMAIL$
# }
# 'host-notify-by-xmpp' command definition
#define command{
# command_name host-notify-by-xmpp
# command_line /usr/local/bin/xmppsend -a /etc/nagios/private/xmppnagios.ini "Host '$HOSTNAME$' is $HOSTSTATE$\nInfo: $HOSTOUTPUT$\nDate: $LONGDATETIME$" $CONTACTEMAIL$
# }

View file

@ -1,17 +0,0 @@
# 'test nrpe'
define command{
command_name test_nrpe
command_line $USER1$/check_nrpe -t 30 -H $HOSTADDRESS$
}
# 'check by nrpe'
define command{
command_name check_by_nrpe
command_line $USER1$/check_nrpe -t 30 -H $HOSTADDRESS$ -c $ARG1$
}
# 'check-host-alive-nrpe' is better for hosts that are on vpn.
define command{
command_name check-host-alive-nrpe
command_line $USER1$/check_nrpe -t 30 -H $HOSTADDRESS$
}

View file

@ -1,26 +0,0 @@
################################################################################
#
# SAMPLE PERFORMANCE DATA COMMANDS
#
# These are sample performance data commands that can be used to send performance
# data output to two text files (one for hosts, another for services). If you
# plan on simply writing performance data out to a file, consider using the
# host_perfdata_file and service_perfdata_file options in the main config file.
#
################################################################################
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/log/nagios/host-perfdata.out
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/log/nagios/service-perfdata.out
}

View file

@ -1,31 +0,0 @@
# This command checks to see if a host is "alive" by pinging it
# The check must result in a 100% packet loss or 5 second (3000ms) round trip
# average time to produce a critical error.
# Note: Only one ICMP echo packet is sent (determined by the '-p 1' argument)
# 'check-host-alive' command definition
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
define command{
command_name check-host-alive4
command_line $USER1$/check_ping -4 -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 2
}
define command{
command_name check-host-alive6
command_line $USER1$/check_ping -6 -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 2
}
# 'check_ping' command definition
define command{
command_name check_ping4
command_line $USER1$/check_ping -4 -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
define command{
command_name check_ping6
command_line $USER1$/check_ping -6 -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}

View file

@ -1,28 +0,0 @@
################################################################################
# COMMAND DEFINITIONS
#
# SYNTAX:
#
# define command{
# template <templatename>
# name <objectname>
# command_name <commandname>
# command_line <commandline>
# }
#
# WHERE:
#
# <templatename> = object name of another command definition that should be
# used as a template for this definition (optional)
# <objectname> = object name of command definition, referenced by other
# command definitions that use it as a template (optional)
# <commandname> = name of the command, as recognized/used by Nagios
# <commandline> = command line
#
################################################################################
define command {
command_name restart_rsyslog
command_line $USER1$/restart_rsyslog $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$ "$HOSTALIAS$" "$SERVICEDESC$" "$SERVICESTATE$"
}

View file

@ -1,12 +0,0 @@
# 'check_smtp' command definition
define command{
command_name check_smtp
command_line $USER1$/check_smtp -H $HOSTADDRESS$
}
# 'check_email_delivery' command definition
define command{
command_name check_email_delivery
command_line $USER1$/check_email_delivery_epn -H $ARG1$ --mailto $ARG2$ --mailfrom $ARG3$ --username $ARG4$ --password $ARG5$ -w $ARG6$ -c $ARG7$
}

View file

@ -1,10 +0,0 @@
# 'check_ssh' command definition
define command{
command_name check_ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$
}
define command{
command_name check-host-alive-ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$
}

View file

@ -1,6 +0,0 @@
# 'check_tcp' command definition
define command{
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

View file

@ -1,5 +0,0 @@
# 'check_testcloud'
define command{
command_name check_testcloud
command_line $USER1$/check_testcloud
}

View file

@ -1,5 +0,0 @@
# 'check_udp' command definition
define command{
command_name check_udp
command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$
}

View file

@ -1,22 +0,0 @@
define hostescalation{
host_name *
hostgroup_name *
contact_groups fedora-sysadmin-email,fedora-sysadmin-emergency,fedora-sysadmin-ircbot,fedora-sysadmin-matrixbot
first_notification 2
last_notification 0
notification_interval 60
escalation_period 24x7
escalation_options d,u,r
}
define serviceescalation{
host_name *
service_description *
contact_groups fedora-sysadmin-email,fedora-sysadmin-emergency,fedora-sysadmin-ircbot,fedora-sysadmin-matrixbot
first_notification 2
last_notification 0
notification_interval 60
escalation_period 24x7
escalation_options w,u,c,r
}

View file

@ -1,362 +0,0 @@
###############################################################################
# MINIMAL.CFG
#
# MINIMALISTIC OBJECT CONFIG FILE (Template-Based Object File Format)
#
# Last Modified: 08-10-2005
#
#
# NOTE: This config file is intended to be used to test a Nagios installation
# that has been compiled with support for the template-based object
# configuration files.
#
# This config file is intended to servce as an *extremely* simple
# example of how you can create your object configuration file(s).
# If you're interested in more complex object configuration files for
# Nagios, look in the sample-config/template-object/ subdirectory of
# the distribution.
#
###############################################################################
###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################
# This defines a timeperiod where all times are valid for checks,
# notifications, etc. The classic "24x7" support nightmare. :-)
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################
# This is a sample service notification command that can be used to send email
# notifications (about service alerts) to contacts.
# 'check_ssh' command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
# This is a sample host notification command that can be used to send email
# notifications (about host alerts) to contacts.
define command{
command_name host-notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $OUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$
}
# Command to check to see if a host is "alive" (up) by pinging it
define command{
command_name check-host-alive4
command_line $USER1$/check_ping -4 -H $HOSTADDRESS$ -w 300,99% -c 500,100% -p 2
}
# Generic command to check a device by pinging it
define command{
command_name check_ping
command_line $USER1$/check_ping -4 -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
# Command used to check disk space usage on local partitions
define command{
command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
}
# Command used to check the number of currently logged in users on the
# local machine
define command{
command_name check_local_users
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
}
# Command to check the number of running processing on the local machine
define command{
command_name check_local_procs
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$
}
# Command to check the load on the local machine
define command{
command_name check_local_load
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
}
###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.
define contact{
contact_name nagios-admin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email admin@fedoraproject.org
}
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios-admin
}
###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################
# Generic host definition template - This is NOT a real host, just a template!
define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
# Since this is a simple configuration file, we only monitor one host - the
# local host (this machine).
define host{
use generic-host ; Name of host template to use
host_name localhost
alias localhost
address 127.0.0.1
check_command check-host-alive4
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################
# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.
define hostgroup{
hostgroup_name test
alias Test Servers
members localhost
}
###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################
# Generic service definition template - This is NOT a real service, just a template!
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# Define a service to "ping" the local machine
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 4
check_interval 5
retry_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_ping!100.0,20%!500.0,60%
}
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description Root Partition
is_volatile 0
check_period 24x7
max_check_attempts 4
check_interval 5
retry_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_local_disk!20%!10%!/
}
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description Current Users
is_volatile 0
check_period 24x7
max_check_attempts 4
check_interval 5
retry_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_local_users!20!50
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description Total Processes
is_volatile 0
check_period 24x7
max_check_attempts 4
check_interval 5
retry_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_local_procs!250!400
}
# Define a service to check the load on the local machine.
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description Current Load
is_volatile 0
check_period 24x7
max_check_attempts 4
check_interval 5
retry_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
# EOF

File diff suppressed because it is too large Load diff

View file

@ -1,147 +0,0 @@
###############################################################################
# TIMEPERIODS.CFG - SAMPLE TIMEPERIOD DEFINITIONS
#
#
# NOTES: This config file provides you with some example timeperiod definitions
# that you can reference in host, service, contact, and dependency
# definitions.
#
# You don't need to keep timeperiods in a separate file from your other
# object definitions. This has been done just to make things easier to
# understand.
#
###############################################################################
###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
define timeperiod{
timeperiod_name 12x7-GMT
alias 12 Hours a day, 7 days a week
sunday 08:00-20:00
monday 08:00-20:00
tuesday 08:00-20:00
wednesday 08:00-20:00
thursday 08:00-20:00
friday 08:00-20:00
saturday 08:00-20:00
}
define timeperiod{
timeperiod_name 12x7-USET
alias 12 Hours a day, 7 days a week
sunday 12:00-24:00
monday 12:00-24:00
tuesday 12:00-24:00
wednesday 12:00-24:00
thursday 12:00-24:00
friday 12:00-24:00
saturday 12:00-24:00
}
define timeperiod{
timeperiod_name 12x7-USPT
alias 12 Hours a day, 7 days a week
sunday 00:00-03:00,15:00-24:00
monday 00:00-03:00,15:00-24:00
tuesday 00:00-03:00,15:00-24:00
wednesday 00:00-03:00,15:00-24:00
thursday 00:00-03:00,15:00-24:00
friday 00:00-03:00,15:00-24:00
saturday 00:00-03:00,15:00-24:00
}
define timeperiod{
timeperiod_name 16x7-AU
alias 15 Hours a day, 7 days a week
sunday 00:00-14:00,22:00-24:00
monday 00:00-14:00,22:00-24:00
tuesday 00:00-14:00,22:00-24:00
wednesday 00:00-14:00,22:00-24:00
thursday 00:00-14:00,22:00-24:00
friday 00:00-14:00,22:00-24:00
saturday 00:00-14:00,22:00-24:00
}
# Members of sysadmin-main already get nagios messages
define timeperiod{
timeperiod_name never
alias Never
}
# This defines a timeperiod where all times are valid for checks,
# notifications, etc. The classic "24x7" support nightmare. :-)
# 'workhours' timeperiod definition
define timeperiod{
timeperiod_name workhours
alias Normal Work Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
# 'none' timeperiod definition
define timeperiod{
timeperiod_name none
alias No Time Is A Good Time
}
# Some U.S. holidays
# Note: The timeranges for each holiday are meant to *exclude* the holidays from being
# treated as a valid time for notifications, etc. You probably don't want your pager
# going off on New Year's. Although you're employer might... :-)
define timeperiod{
name us-holidays
timeperiod_name us-holidays
alias U.S. Holidays
january 1 00:00-00:00 ; New Years
monday -1 may 00:00-00:00 ; Memorial Day (last Monday in May)
july 4 00:00-00:00 ; Independence Day
monday 1 september 00:00-00:00 ; Labor Day (first Monday in September)
thursday 4 november 00:00-00:00 ; Thanksgiving (4th Thursday in November)
december 25 00:00-00:00 ; Christmas
}
# This defines a modified "24x7" timeperiod that covers every day of the
# year, except for U.S. holidays (defined in the timeperiod above).
define timeperiod{
timeperiod_name 24x7_sans_holidays
alias 24x7 Sans Holidays
use us-holidays ; Get holiday exceptions from other timeperiod
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}

View file

@ -1,5 +0,0 @@
define contactgroup {
contactgroup_name copr
alias COPR Notifications
members copr-sig
}

View file

@ -1,6 +0,0 @@
define contactgroup{
contactgroup_name fedora-sysadmin-email
alias Fedora Sysadmin Email Contacts
# sysadmin-main: @ausil @kevin
members admin,kevin
}

View file

@ -1,6 +0,0 @@
define contactgroup{
contactgroup_name fedora-sysadmin-ircbot
alias Fedora Sysadmin irc Contacts
members ircbot,matrixbot
}

View file

@ -1,6 +0,0 @@
define contactgroup{
contactgroup_name fedora-sysadmin-matrixbot
alias Fedora Sysadmin Matrix Contacts
members matrixbot
}

View file

@ -1,11 +0,0 @@
define contactgroup{
contactgroup_name fedora-sysadmin-pager
alias Fedora Sysadmin Pager Contacts
members kevinp
}
define contactgroup{
contactgroup_name fedora-sysadmin-emergency
alias Fedora Sysadmin Pager Contacts
members kevin-emergency
}

View file

@ -1,5 +0,0 @@
define contactgroup{
contactgroup_name null
alias null
members null
}

View file

@ -1,5 +0,0 @@
define contactgroup {
contactgroup_name sysadmin-qa-email
alias Fedora SysAdmin QA Email Contacts
members sysadmin-qa
}

View file

@ -1,7 +0,0 @@
This directory contains nagios contacts.
Note that this repo is open to the world as is the nagios instance,
so any email addresses or phone numbers here will be public.
Interested parties are urged to use a email address that filters out
all non nagios emails to avoid spam.

View file

@ -1,13 +0,0 @@
define contact{
contact_name admin
alias Fedora Sysadmins
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email sysadmin-members@fedoraproject.org
}

View file

@ -1,11 +0,0 @@
define contact {
contact_name copr-sig
alias Copr Team
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email copr-team@redhat.com
}

View file

@ -1,10 +0,0 @@
#define contact{
# contact_name fedora-messaging
# alias FMBUS
# service_notification_period 24x7
# host_notification_period 24x7
# service_notification_options w,u,c,r
# host_notification_options d,u,r
# service_notification_commands notify-by-fedora-messaging
# host_notification_commands host-notify-by-fedora-messaging
#}

View file

@ -1,11 +0,0 @@
define contact{
contact_name frostyx
alias frostyx
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager jkadlcik@redhat.com
}

View file

@ -1,10 +0,0 @@
define contact{
contact_name ircbot
alias ZOD
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-ircbot
host_notification_commands host-notify-by-ircbot
}

View file

@ -1,35 +0,0 @@
define contact{
contact_name kevin
alias Kevin Fenzi
service_notification_period none
host_notification_period none
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email kevin-pager@scrye.com
}
define contact{
contact_name kevin-emergency
alias Kevin Fenzi
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager kevin-urgent@scrye.com
}
define contact{
contact_name kevinp
alias Kevin Fenzi
service_notification_period 12x7-USPT
host_notification_period 12x7-USPT
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager kevin-urgent@scrye.com
}

View file

@ -1,10 +0,0 @@
define contact{
contact_name matrixbot
alias NON
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-matrixbot
host_notification_commands host-notify-by-matrixbot
}

View file

@ -1,11 +0,0 @@
define contact{
contact_name msuchy
alias msuchy
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager msuchy@redhat.com
}

View file

@ -1,38 +0,0 @@
define contact{
contact_name nb
alias Nick Bebout
service_notification_period never
host_notification_period never
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email nick@bebout.net
}
#define contact{
# contact_name nb-emergency
# alias Nick Bebout
# service_notification_period never
# host_notification_period never
# service_notification_options w,u,c,r
# host_notification_options d,u,r
# service_notification_commands notify-by-epager
# host_notification_commands host-notify-by-epager
# email nb5@txt.att.net
# pager nb5@txt.att.net
#}
#define contact{
# contact_name nbp
# alias Nick Bebout
# service_notification_period never
# host_notification_period never
# service_notification_options w,u,c,r
# host_notification_options d,u,r
# service_notification_commands notify-by-epager
# host_notification_commands host-notify-by-epager
# email nb5@txt.att.net
# pager nb5@txt.att.net
#}

View file

@ -1,11 +0,0 @@
define contact{
contact_name nikromen
alias nikromen
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager jkyjovsk@redhat.com
}

View file

@ -1,11 +0,0 @@
define contact{
contact_name null
alias null
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email nobody@fedoraproject.org
}

View file

@ -1,11 +0,0 @@
define contact{
contact_name praiskup
alias praiskup
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-epager
host_notification_commands host-notify-by-epager
pager praiskup@redhat.com
}

View file

@ -1,12 +0,0 @@
define contact{
contact_name smooge
alias Stephen Smoogen
service_notification_period never
host_notification_period never
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email smooge+nagios@smoogespace.com
}

View file

@ -1,13 +0,0 @@
define contact {
contact_name sysadmin-qa
alias Fedora QA SysAdmins
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email sysadmin-qa-members@fedoraproject.org
}

View file

@ -1,99 +0,0 @@
define host {
name defaulttemplate
#check_command check-host-alive4
check_command check-host-alive-nrpe
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name aws
check_command check-host-alive-ssh
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name mincheck
check_command check-host-alive4
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name mincheck6
check_command check-host-alive6
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name ppc-secondarytemplate
check_command check-host-alive4
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name retracetemplate
check_command check-host-alive4
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define host {
name defaultbuilders
max_check_attempts 8
checks_enabled 1
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
notifications_enabled 1
notification_options d,r
contact_groups fedora-sysadmin-ircbot
register 0
}

View file

@ -1,89 +0,0 @@
#!/usr/bin/python3
""" NRPE check for datanommer/fedora-messaging health.
Given a category like 'bodhi', 'buildsys', or 'git', return an error if
datanommer hasn't seen a message of that type in such and such time.
You can alternatively provide a 'topic' which might look like
org.fedoraproject.prod.bodhi.update.comment.
Requires: python-requests
Requires: python-dateutil
Usage:
$ check_datanommer_timesince CATEGORY WARNING_THRESH CRITICAL_THRESH
:Author: Aurelien Bompard <abompard@fedoraproject.org>
"""
import sys
from datetime import datetime, timezone
import requests
import dateutil.parser
DATAGREPPER_URL = "https://apps.fedoraproject.org/datagrepper"
def query_messages(identifier, delta):
params = {"delta": delta, "rows_per_page": 1, "page": 1}
# If it has a '.', then assume it is a topic.
if "." in identifier:
params["topic"] = identifier
else:
params["category"] = identifier
response = requests.get(f"{DATAGREPPER_URL}/v2/search", params=params)
if not response.ok:
print(
f"UNKNOWN: Could not query {DATAGREPPER_URL}: error {response.status_code}"
)
sys.exit(3)
result = response.json()
return result
def parse_args():
def _usage():
print(f"Usage: {sys.argv[0]} CATEGORY WARNING_THRESHOLD CRITICAL_THRESHOLD")
sys.exit(3)
if len(sys.argv) != 4:
_usage()
try:
int(sys.argv[2])
int(sys.argv[3])
except ValueError:
_usage()
if int(sys.argv[2]) > int(sys.argv[3]):
_usage()
return sys.argv[1], int(sys.argv[2]), int(sys.argv[3])
def main():
identifier, warning_threshold, critical_threshold = parse_args()
result = query_messages(identifier, critical_threshold)
if result["total"] == 0:
print(f"CRIT: no {identifier} messages in {critical_threshold} seconds")
sys.exit(2)
last_timestamp = result["raw_messages"][0]["headers"]["sent-at"]
last_timestamp = dateutil.parser.parse(last_timestamp)
seconds_since = int((datetime.now(timezone.utc) - last_timestamp).total_seconds())
reason = f"last {identifier} message was {seconds_since} seconds ago"
if seconds_since > warning_threshold:
print(f"WARN: {reason}")
sys.exit(1)
print(f"OK: {reason}")
sys.exit(0)
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"UNKNOWN: {e}")
sys.exit(3)

View file

@ -1,45 +0,0 @@
#!/bin/bash
#
# 29-02-2012
# Author: Christos Triantafyllidis <christos.triantafyllidis@gmail.com>
#
# Default values
STUNNEL_EXEC=${STUNNEL_EXEC:-/usr/bin/stunnel}
CHECK_DIG_EXEC=${CHECK_DIG_EXEC:-/usr/lib64/nagios/plugins/check_dig}
lport=8443
ARGS=""
while getopts "L:H:p:l:T:a:A:w:c:t:v" options
do
case $options in
L ) lport=$OPTARG ;;
H ) host=$OPTARG ;;
p ) port=$OPTARG ;;
* ) ARGS="$ARGS -$options $OPTARG";;
esac
done
# Create a ssl tunnel to the request socket
TMPFILE=`mktemp /tmp/$(basename $0)_${host}_${port}_XXXXX`
echo "
client = yes
verify = 0
syslog = no
pid=$TMPFILE.pid
[${host}_${port}]
accept=${lport}
connect=${host}:${port}
sslVersion = TLSv1.2
" > $TMPFILE
$STUNNEL_EXEC $TMPFILE
# Use check_dig via the stunnel
$CHECK_DIG_EXEC -H localhost -p ${lport} $ARGS
e_status=$?
# cleanup
kill -9 `cat $TMPFILE.pid`
rm -f $TMPFILE $TMPFILE.pid
exit $e_status

View file

@ -1,472 +0,0 @@
#!/usr/bin/perl
use strict;
my $VERSION = '0.6.2';
my $COPYRIGHT = 'Copyright (C) 2005-2008 Jonathan Buhacoff <jonathan@buhacoff.net>';
my $LICENSE = 'http://www.gnu.org/licenses/gpl.txt';
my %status = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );
# look for required modules
exit $status{UNKNOWN} unless load_modules(qw/Getopt::Long/);
# get options from command line
Getopt::Long::Configure("bundling");
my $verbose = 0;
my $help = "";
my $help_usage = "";
my $show_version = "";
my $host = "";
my $smtp_server = "";
my $smtp_port = "";
my $imap_server = "";
my $smtp_username = "";
my $smtp_password = "";
my $smtp_tls = "";
my $imap_port = "";
my $imap_username = "";
my $imap_password = "";
my $username = "";
my $password = "";
my $ssl = "";
my $imap_ssl = "";
my $mailto = "";
my $mailfrom = "";
my @header = ();
my $body = "";
my $warnstr = "";
my $critstr = "";
my $waitstr = "";
my $delay_warn = 95;
my $delay_crit = 300;
my $smtp_warn = 15;
my $smtp_crit = 30;
my $imap_warn = 15;
my $imap_crit = 30;
my $timeout = "";
my @alert_plugins = ();
my $imap_interval = 5;
my $imap_retries = 5;
my @plugins = ();
my @token_formats = ();
my $tokenfile = "";
my $default_crit = 30;
my $default_warn = 15;
my $default_wait = 5;
my $default_timeout = 60;
#my $libexec = "/usr/local/nagios/libexec";
my $libexec = "/usr/lib64/nagios/plugins";
my $ok;
$ok = Getopt::Long::GetOptions(
"V|version"=>\$show_version,
"v|verbose+"=>\$verbose,"h|help"=>\$help,"usage"=>\$help_usage,
"w|warning=s"=>\$warnstr,"c|critical=s"=>\$critstr, "t|timeout=s"=>\$timeout,
"libexec=s"=>\$libexec,
# plugin settings
"p|plugin=s"=>\@plugins, "T|token=s"=>\@token_formats,
"A|alert=i"=>\@alert_plugins,
"F|file=s"=>\$tokenfile,
# common settings
"H|hostname=s"=>\$host,
"U|username=s"=>\$username,"P|password=s"=>\$password,
# smtp settings
"smtp-server=s"=>\$smtp_server,"smtp-port=i"=>\$smtp_port,
"mailto=s"=>\$mailto, "mailfrom=s",\$mailfrom,
"header=s"=>\@header, "body=s"=>\$body,
# smtp-tls settings
"smtptls!"=>\$smtp_tls,
"smtp-username=s"=>\$smtp_username,"smtp-password=s"=>\$smtp_password,
# delay settings
"wait=s"=>\$waitstr,
# imap settings
"imap-server=s"=>\$imap_server,"imap-port=i"=>\$imap_port,
"imap-username=s"=>\$imap_username,"imap-password=s"=>\$imap_password,
"imap-check-interval=i"=>\$imap_interval,"imap-retries=i"=>\$imap_retries,
"imapssl!"=>\$imap_ssl,
);
if( $show_version ) {
print "$VERSION\n";
if( $verbose ) {
print "Warning threshold: $delay_warn seconds\n";
print "Critical threshold: $delay_crit seconds\n";
print "Default wait: $default_wait seconds\n";
print "Default timeout: $default_timeout seconds\n";
}
exit $status{UNKNOWN};
}
if( $help ) {
exec "perldoc", $0 or print "Try `perldoc $0`\n";
exit $status{UNKNOWN};
}
if( $host ) {
$smtp_server = $host if $smtp_server eq "";
$imap_server = $host if $imap_server eq "";
}
if( $username ) {
$smtp_username = $username if $smtp_username eq "";
$imap_username = $username if $imap_username eq "";
}
if( $password ) {
$smtp_password = $password if $smtp_password eq "";
$imap_password = $password if $imap_password eq "";
}
if( $ssl ) {
$imap_ssl = $ssl if $imap_ssl eq "";
$smtp_tls = $ssl if $smtp_tls eq "";
}
if( $help_usage
||
(
scalar(@plugins) == 0
&&
(
$smtp_server eq "" || $mailto eq "" || $mailfrom eq ""
|| $imap_server eq "" || $username eq "" || $password eq ""
)
)
) {
print "Usage 1: $0 -H host \n\t".
"--mailto recipient\@your.net --mailfrom sender\@your.net --body 'message' \n\t".
"--username username --password password \n\t".
"[-w <seconds>] [-c <seconds>]\n\t" .
"[--imap-check-interval <seconds> ] [--imap-retries <times> ]\n";
print "Usage 2: $0 \n\t".
"-p 'first plugin command with %TOKEN1% embedded' \n\t".
"-p 'second plugin command with %TOKEN1% embedded' \n\t".
"[-w <seconds1>,<seconds2>] [-c <seconds1>,<seconds2>] \n";
exit $status{UNKNOWN};
}
# determine thresholds
my @warning_times = split(",", $warnstr);
my @critical_times = split(",", $critstr);
my @alarm_times = split(",", $timeout);
my @wait_times = split(",", $waitstr);
my ($dw,$sw,$rw) = split(",", $warnstr);
my ($dc,$sc,$rc) = split(",", $critstr);
my ($wait) = split(",", $waitstr);
$delay_warn = $dw if defined $dw and $dw ne "";
$smtp_warn = $sw if defined $sw and $sw ne "";
$imap_warn = $rw if defined $rw and $rw ne "";
$delay_crit = $dc if defined $dc and $dc ne "";
$smtp_crit = $sc if defined $sc and $sc ne "";
$imap_crit = $rc if defined $rc and $rc ne "";
my $smtp_thresholds = "";
$smtp_thresholds .= "-w $smtp_warn " if defined $smtp_warn and $smtp_warn ne "";
$smtp_thresholds .= "-c $smtp_crit " if defined $smtp_crit and $smtp_crit ne "";
my $imap_thresholds = "";
$imap_thresholds .= "-w $imap_warn " if defined $imap_warn and $imap_warn ne "";
$imap_thresholds .= "-c $imap_crit " if defined $imap_crit and $imap_crit ne "";
$imap_thresholds .= "--imap-check-interval $imap_interval " if defined $imap_interval and $imap_interval ne "";
$imap_thresholds .= "--imap-retries $imap_retries " if defined $imap_retries and $imap_retries ne "";
if( scalar(@alarm_times) == 1 ) {
$default_timeout = shift(@alarm_times);
}
# determine which other options to include
my $smtp_options = "";
$smtp_options .= "-H $smtp_server " if defined $smtp_server and $smtp_server ne "";
$smtp_options .= "-p $smtp_port " if defined $smtp_port and $smtp_port ne "";
$smtp_options .= "--tls " if defined $smtp_tls and $smtp_tls;
$smtp_options .= "-U $username " if defined $smtp_username and $smtp_username ne "";
$smtp_options .= "-P $password " if defined $smtp_password and $smtp_password ne "";
$smtp_options .= "--mailto $mailto " if defined $mailto and $mailto ne "";
$smtp_options .= "--mailfrom $mailfrom " if defined $mailfrom and $mailfrom ne "";
my $imap_options = "";
$imap_options .= "-H $imap_server " if defined $imap_server and $imap_server ne "";
$imap_options .= "-p $imap_port " if defined $imap_port and $imap_port ne "";
$imap_options .= "-U $username " if defined $imap_username and $imap_username ne "";
$imap_options .= "-P $password " if defined $imap_password and $imap_password ne "";
$imap_options .= "--ssl " if defined $imap_ssl and $imap_ssl;
# create the report object
my $report = new PluginReport;
my @report_plugins = (); # populated later with either (smtp,imap) or (plugin1,plugin2,...)
my $time_start; # initialized later with time the work actually starts
# create token formats for use with the plugins
my @alpha = qw/a b c d e f g h i j k l m n o p q r s t u v w x y z/;
my @numeric = qw/0 1 2 3 4 5 6 7 8 9/;
my @hex = qw/0 1 2 3 4 5 6 7 8 9 a b c d e f/;
my @pgp_even = qw/aardvark absurd accrue acme adrift adult afflict ahead aimless Algol allow alone ammo ancient apple artist assume Athens atlas Aztec baboon backfield backward banjo beaming bedlamp beehive beeswax befriend Belfast berserk billiard bison blackjack blockade blowtorch bluebird bombast bookshelf brackish breadline breakup brickyard briefcase Burbank button buzzard cement chairlift chatter checkup chisel choking chopper Christmas clamshell classic classroom cleanup clockwork cobra commence concert cowbell crackdown cranky crowfoot crucial crumpled crusade cubic dashboard deadbolt deckhand dogsled dragnet drainage dreadful drifter dropper drumbeat drunken Dupont dwelling eating edict egghead eightball endorse endow enlist erase escape exceed eyeglass eyetooth facial fallout flagpole flatfoot flytrap fracture framework freedom frighten gazelle Geiger glitter glucose goggles goldfish gremlin guidance hamlet highchair hockey indoors indulge inverse involve island jawbone keyboard kickoff kiwi klaxon locale lockup merit minnow miser Mohawk mural music necklace Neptune newborn nightbird Oakland obtuse offload optic orca payday peachy pheasant physique playhouse Pluto preclude prefer preshrunk printer prowler pupil puppy python quadrant quiver quota ragtime ratchet rebirth reform regain reindeer rematch repay retouch revenge reward rhythm ribcage ringbolt robust rocker ruffled sailboat sawdust scallion scenic scorecard Scotland seabird select sentence shadow shamrock showgirl skullcap skydive slingshot slowdown snapline snapshot snowcap snowslide solo southward soybean spaniel spearhead spellbind spheroid spigot spindle spyglass stagehand stagnate stairway standard stapler steamship sterling stockman stopwatch stormy sugar surmount suspense sweatband swelter tactics talon tapeworm tempest tiger tissue tonic topmost tracker transit trauma treadmill Trojan trouble tumor tunnel tycoon uncut unearth unwind uproot upset upshot vapor village virus Vulcan waffle wallet watchword wayside willow woodlark Zulu/;
my @pgp_odd = qw/adroitness adviser aftermath aggregate alkali almighty amulet amusement antenna applicant Apollo armistice article asteroid Atlantic atmosphere autopsy Babylon backwater barbecue belowground bifocals bodyguard bookseller borderline bottomless Bradbury bravado Brazilian breakaway Burlington businessman butterfat Camelot candidate cannonball Capricorn caravan caretaker celebrate cellulose certify chambermaid Cherokee Chicago clergyman coherence combustion commando company component concurrent confidence conformist congregate consensus consulting corporate corrosion councilman crossover crucifix cumbersome customer Dakota decadence December decimal designing detector detergent determine dictator dinosaur direction disable disbelief disruptive distortion document embezzle enchanting enrollment enterprise equation equipment escapade Eskimo everyday examine existence exodus fascinate filament finicky forever fortitude frequency gadgetry Galveston getaway glossary gossamer graduate gravity guitarist hamburger Hamilton handiwork hazardous headwaters hemisphere hesitate hideaway holiness hurricane hydraulic impartial impetus inception indigo inertia infancy inferno informant insincere insurgent integrate intention inventive Istanbul Jamaica Jupiter leprosy letterhead liberty maritime matchmaker maverick Medusa megaton microscope microwave midsummer millionaire miracle misnomer molasses molecule Montana monument mosquito narrative nebula newsletter Norwegian October Ohio onlooker opulent Orlando outfielder Pacific pandemic Pandora paperweight paragon paragraph paramount passenger pedigree Pegasus penetrate perceptive performance pharmacy phonetic photograph pioneer pocketful politeness positive potato processor provincial proximate puberty publisher pyramid quantity racketeer rebellion recipe recover repellent replica reproduce resistor responsive retraction retrieval retrospect revenue revival revolver sandalwood sardonic Saturday savagery scavenger sensation sociable souvenir specialist speculate stethoscope stupendous supportive surrender suspicious sympathy tambourine telephone therapist tobacco tolerance tomorrow torpedo tradition travesty trombonist truncated typewriter ultimate undaunted underfoot unicorn unify universe unravel upcoming vacancy vagabond vertigo Virginia visitor vocalist voyager warranty Waterloo whimsical Wichita Wilmington Wyoming yesteryear Yucatan/;
my %formats = (
'a' => sub { pick_random(@alpha) },
'n' => sub { pick_random(@numeric) },
'c' => sub { pick_random(@alpha,@numeric) },
'h' => sub { pick_random(@hex) },
'U' => sub { time },
'X' => sub { pick_random(@pgp_even) },
'Y' => sub { pick_random(@pgp_odd) },
);
if( scalar(@plugins) ) {
# scan the plugin commands for use of tokens to count how many we need
my $token_count = 0;
foreach my $p (@plugins) {
my @matches = sort ($p =~ m/%TOKEN(\d+)%/g);
my $max = pop @matches;
$token_count = $max if defined($max) && $max > $token_count;
}
# create the tokens
my @tokens = ();
foreach my $t (1..$token_count) {
my $format = shift @token_formats;
$format = "U-X-Y" unless $format;
my @format_characters = split(//, $format);
my $token = "";
foreach my $c (@format_characters) {
if( defined $formats{$c} ) {
$token .= &{$formats{$c}};
}
else {
$token .= $c;
}
}
push @tokens, $token;
}
# substitute the tokens into each plugin command
foreach my $p (@plugins) {
foreach my $t (1..$token_count) {
my $token = $tokens[$t-1];
$p =~ s/%TOKEN$t%/$token/g;
}
}
# mark plugins that are allowed to generate alerts. default behavior is to alert for all plugins.
my %alert_plugins = ();
if( scalar(@alert_plugins) > 0 ) {
%alert_plugins = map { $_ => 1 } @alert_plugins;
}
else {
%alert_plugins = map { $_ => 1 } (1..scalar(@plugins));
}
# run each plugin and store its output in a report
$time_start = time;
my $i = 0;
foreach my $p( @plugins ) {
$i++;
my $plugin_timeout = shift(@alarm_times) || $default_timeout;
# run the plugin
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $plugin_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $plugin_timeout;
my $output = `$p`;
chomp $output;
if( $output !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - plugin $i error: $output\n";
print "Plugin $i: $p\n" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'UNKNOWN',$i,$output) if $tokenfile;
exit $status{UNKNOWN};
}
if( $output =~ m/CRITICAL/ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY CRITICAL - plugin $i failed: $output\n";
print "Plugin $i: $p" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'CRITICAL',$i,$output) if $tokenfile;
exit $status{CRITICAL};
}
if( $output =~ m/WARNING/ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY WARNING - plugin $i warning: $output\n";
print "Plugin $i: $p\n" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'WARNING',$i,$output) if $tokenfile;
exit $status{WARNING};
}
$report->{"plugin".$i} = $output;
alarm 0;
};
if( $@ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY CRITICAL - Could not run plugin $i: $@\n";
print "Plugin $i: $p\n" if $verbose;
exit $status{CRITICAL};
}
# if this wasn't the last plugin, wait before continuing
if( $i < scalar(@plugins) ) {
my $wait = shift(@wait_times) || $default_wait;
sleep $wait;
}
# compatibility with the "not using plugins" method... pretend to calculate the total round trip time (the delay) using data from the plugins ...
$report->{max} = 0;
$report->{delay} = 0;
}
# register the list of reports
foreach my $r ( 1..scalar(@plugins)) {
push @report_plugins, "plugin".$r;
}
# record tokens in a file if option is enabled
my $tmp_long_report = join(", ", map { "$_: $report->{$_}" } @report_plugins ) if $tokenfile;
record_tokens($tokenfile,\@tokens,$time_start,time,'OK',scalar(@plugins),$tmp_long_report) if $tokenfile;
}
else {
# not using plugins.
$time_start = time;
# send email via SMTP
my $id = $time_start; # XXX should include localhost name maybe or some random number in case the same mailbox is used for multiple delivery tests
my $smtp_plugin = "$libexec/check_smtp_send";
$smtp_plugin = "$libexec/check_smtp_send.pl" unless -e $smtp_plugin;
my $smtp_timeout = shift(@alarm_times) || $default_timeout;
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $smtp_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $smtp_timeout;
my $smtp = `$smtp_plugin $smtp_options --header 'Subject: Nagios Message SMTP $smtp_server ID $id.' --body 'Nagios Email Delivery Plugin\n$body' $smtp_thresholds`;
if( $smtp !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - smtp unknown: $smtp\n";
exit $status{UNKNOWN};
}
if( $smtp =~ m/CRITICAL/ ) {
print "EMAIL DELIVERY CRITICAL - smtp failed: $smtp\n";
exit $status{CRITICAL};
}
chomp $smtp;
$report->{smtp} = $smtp;
alarm 0;
};
if( $@ ) {
print "EMAIL DELIVERY CRITICAL - Could not connect to SMTP server $smtp_server: $@\n";
exit $status{CRITICAL};
}
# wait before checking the delivery
$wait = shift(@wait_times) || $default_wait;
sleep $wait;
# check email via IMAP
my $imap_plugin = "$libexec/check_imap_receive";
$imap_plugin = "$libexec/check_imap_receive.pl" unless -e $imap_plugin;
my $imap_timeout = shift(@alarm_times) || $default_timeout;
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $imap_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $imap_timeout;
my $imap = `$imap_plugin $imap_options -s SUBJECT -s 'Nagios Message SMTP $smtp_server ID' --capture-max 'Nagios Message SMTP $smtp_server ID (\\d+)' --nodelete-captured $imap_thresholds`;
if( $imap !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - imap unknown: $imap\n";
exit $status{UNKNOWN};
}
if( $imap =~ m/CRITICAL/ ) {
print "EMAIL DELIVERY CRITICAL - imap failed: $imap\n";
exit $status{CRITICAL};
}
if( $imap =~ m/ (\d+) max/ ) {
my $last_received = $1;
$report->{max} = $1;
my $delay = time - $last_received;
$report->{delay} = $delay;
}
chomp $imap;
$report->{imap} = $imap;
alarm 0;
};
if( $@ ) {
print "EMAIL DELIVERY CRITICAL - Could not connect to IMAP server $imap_server: $@\n";
exit $status{CRITICAL};
}
# register the list of reports
push @report_plugins, ("smtp","imap");
}
# calculate elapsed time and issue warnings
my $time_end = time;
my $elapsedtime = $time_end - $time_start;
$report->{seconds} = $elapsedtime;
my @warning = ();
my @critical = ();
push @warning, "most recent received $report->{delay} seconds ago" if( defined($report->{delay}) && $report->{delay} > $delay_warn );
push @critical, "most recent received $report->{delay} seconds ago" if( defined($report->{delay}) && $report->{delay} > $delay_crit );
push @warning, "no emails found" if( !defined($report->{delay}) );
# print report and exit with known status
my $short_report = $report->text(qw/seconds delay/);
my $long_report = join("", map { "$_: $report->{$_}\n" } @report_plugins );
if( scalar @critical ) {
my $alerts = join(", ", @critical);
print "EMAIL DELIVERY CRITICAL - $alerts; $short_report\n";
print $long_report if $verbose;
exit $status{CRITICAL};
}
if( scalar @warning ) {
my $alerts = join(", ", @warning);
print "EMAIL DELIVERY WARNING - $alerts; $short_report\n";
print $long_report if $verbose;
exit $status{WARNING};
}
print "EMAIL DELIVERY OK - $short_report\n";
print $long_report if $verbose;
exit $status{OK};
# utility to load required modules. exits if unable to load one or more of the modules.
sub load_modules {
my @missing_modules = ();
foreach( @_ ) {
eval "require $_";
push @missing_modules, $_ if $@;
}
if( @missing_modules ) {
print "Missing perl modules: @missing_modules\n";
return 0;
}
return 1;
}
# returns one random character from a set of characters
sub pick_random {
my @set = @_;
my $size = scalar @set;
my $string = $set[int(rand($size))];
return $string;
}
# appens tokens and times to a tab-separated value file
sub record_tokens {
my ($tokenfile,$tokens,$time_start,$time_end,$status,$plugin_num,$output) = @_;
if( $tokenfile ) {
my @tokens = @$tokens;
$time_end = "" unless defined $time_end;
$status = "" unless defined $status;
$plugin_num = "" unless defined $plugin_num;
$output = "" unless defined $output;
print "saving ".scalar(@tokens)." tokens into $tokenfile\n" if $verbose;
open(TOKENFILE,">>$tokenfile");
foreach(@tokens) {
print TOKENFILE "$_\t$time_start\t$time_end\t$status\t$plugin_num\t$output\n";
}
close(TOKENFILE);
}
}
# NAME
# PluginReport
# SYNOPSIS
# $report = new PluginReport;
# $report->{label1} = "value1";
# $report->{label2} = "value2";
# print $report->text(qw/label1 label2/);
package PluginReport;
sub new {
my ($proto,%p) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{$_} = $p{$_} foreach keys %p;
return $self;
}
sub text {
my ($self,@labels) = @_;
my @report = map { "$self->{$_} $_" } grep { defined $self->{$_} } @labels;
my $text = join(", ", @report);
return $text;
}
package main;
1;

View file

@ -1,25 +0,0 @@
#!/usr/bin/python
from __future__ import print_function
from builtins import str
import sys
try:
import retask.queue
queue = retask.queue.Queue('fedora-packages')
queue.connect()
items = queue.length
if items > 500:
print("CRITICAL: %i tasks in fcomm queue" % items)
sys.exit(2)
elif items > 250:
print("WARNING: %i tasks in fcomm queue" % items)
sys.exit(1)
else:
print("OK: %i tasks in fcomm queue" % items)
sys.exit(0)
except Exception as e:
print("UNKNOWN:", str(e))
sys.exit(3)

View file

@ -1,76 +0,0 @@
#!/usr/bin/python3
""" Nagios check for haproxy over-subscription.
fedmsg-gateway is the primary concern as it can eat up a ton of simultaneous
connections.
:Author: Ralph Bean <rbean@redhat.com>
"""
import socket
import sys
def _numeric(value):
""" Type casting utility """
try:
return int(value)
except ValueError:
try:
return float(value)
except ValueError:
return value
def query(sockname):
""" Read stats from the haproxy socket and return a dict """
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(sockname)
send_string = 'show info\n'
sock.send(send_string.encode())
try:
response = sock.recv(2048).strip().decode()
lines = response.split('\n')
data = dict(map(str.strip, line.split(':')) for line in lines)
data = {k:_numeric(v) for (k, v) in data.items()}
return data
except Exception as err:
print(str(err))
finally:
sock.close()
return None
def nagios_check(data):
""" Print warnings and return nagios exit codes. """
current = data['CurrConns']
maxconn = data['Maxconn']
percent = 100 * float(current) / float(maxconn)
details = "%.2f%% subscribed. %i current of %i maxconn." % (
percent, current, maxconn,
)
if percent < 50:
print("HAPROXY SUBS OK: " + details)
return 0
if percent < 75:
print("HAPROXY SUBS WARN: " + details)
return 1
if percent <= 100:
print("HAPROXY SUBS CRIT: " + details)
return 2
print("HAPROXY SUBS UNKNOWN: " + details)
return 3
if __name__ == '__main__':
try:
data = query(sockname="/var/run/haproxy-stat")
except Exception as err:
print("HAPROXY SUBS UNKNOWN: " + str(err))
sys.exit(3)
sys.exit(nagios_check(data))

View file

@ -1,387 +0,0 @@
#!/usr/bin/perl
use strict;
my $VERSION = '0.6.0';
my $COPYRIGHT = 'Copyright (C) 2005-2008 Jonathan Buhacoff <jonathan@buhacoff.net>';
my $LICENSE = 'http://www.gnu.org/licenses/gpl.txt';
my %status = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );
# look for required modules
exit $status{UNKNOWN} unless load_modules(qw/Getopt::Long Mail::IMAPClient/);
# get options from command line
Getopt::Long::Configure("bundling");
my $verbose = 0;
my $help = "";
my $help_usage = "";
my $show_version = "";
my $imap_server = "";
my $default_imap_port = "143";
my $default_imap_ssl_port = "993";
my $imap_port = "";
my $username = "";
my $password = "";
my $mailbox = "INBOX";
my @search = ();
my $search_critical_min = 1;
my $capture_max = "";
my $capture_min = "";
my $delete = 1;
my $no_delete_captured = "";
my $warntime = 15;
my $criticaltime = 30;
my $timeout = 60;
my $interval = 5;
my $max_retries = 10;
my $download = "";
my $download_max = "";
my $ssl = 0;
my $tls = 0;
my $ok;
$ok = Getopt::Long::GetOptions(
"V|version"=>\$show_version,
"v|verbose+"=>\$verbose,"h|help"=>\$help,"usage"=>\$help_usage,
"w|warning=i"=>\$warntime,"c|critical=i"=>\$criticaltime,"t|timeout=i"=>\$timeout,
# imap settings
"H|hostname=s"=>\$imap_server,"p|port=i"=>\$imap_port,
"U|username=s"=>\$username,"P|password=s"=>\$password, "m|mailbox=s"=>\$mailbox,
"imap-check-interval=i"=>\$interval,"imap-retries=i"=>\$max_retries,
"ssl!"=>\$ssl, "tls!"=>\$tls,
# search settings
"s|search=s"=>\@search,
"search-critical-min=i"=>\$search_critical_min,
"capture-max=s"=>\$capture_max, "capture-min=s"=>\$capture_min,
"delete!"=>\$delete, "nodelete-captured"=>\$no_delete_captured,
"download!"=>\$download, "download_max=i"=>\$download_max,
);
if( $show_version ) {
print "$VERSION\n";
if( $verbose ) {
print "Default warning threshold: $warntime seconds\n";
print "Default critical threshold: $criticaltime seconds\n";
print "Default timeout: $timeout seconds\n";
}
exit $status{UNKNOWN};
}
if( $help ) {
exec "perldoc", $0 or print "Try `perldoc $0`\n";
exit $status{UNKNOWN};
}
my @required_module = ();
push @required_module, 'IO::Socket::SSL' if ($ssl or $tls);
push @required_module, 'Email::Simple' if ($download);
exit $status{UNKNOWN} unless load_modules(@required_module);
if( $help_usage
||
( $imap_server eq "" || $username eq "" || $password eq "" || scalar(@search)==0 )
) {
print "Usage: $0 -H host [-p port] -U username -P password -s HEADER -s X-Nagios -s 'ID: 1234.' [-w <seconds>] [-c <seconds>] [--imap-check-interval <seconds>] [--imap-retries <tries>]\n";
exit $status{UNKNOWN};
}
# initialize
my $report = new PluginReport;
my $time_start = time;
# connect to IMAP server
my $imap;
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $timeout;
if( $ssl ) {
$imap_port = $default_imap_ssl_port unless $imap_port;
my $socket = IO::Socket::SSL->new("$imap_server:$imap_port");
die IO::Socket::SSL::errstr() unless $socket;
$socket->autoflush(1);
$imap = Mail::IMAPClient->new(Socket=>$socket, Debug => 0 );
$imap->State(Mail::IMAPClient->Connected);
$imap->_read_line() if "$Mail::IMAPClient::VERSION" le "2.2.9"; # necessary to remove the server's "ready" line from the input buffer for old versions of Mail::IMAPClient. Using string comparison for the version check because the numeric didn't work on Darwin and for Mail::IMAPClient the next version is 2.3.0 and then 3.00 so string comparison works
$imap->User($username);
$imap->Password($password);
$imap->login() or die "$@";
}
elsif( $tls ) {
# XXX THIS PART IS NOT DONE YET ... NEED TO OPEN A REGULAR IMAP CONNECTION, THEN ISSUE THE "STARTTLS" COMMAND MANUALLY, SWITCHING THE SOCKET TO IO::SOCKET::SSL, AND THEN GIVING IT BACK TO MAIL::IMAPCLIENT ...
$imap_port = $default_imap_port unless $imap_port;
$imap = Mail::IMAPClient->new(Debug => 0 );
$imap->Server("$imap_server:$imap_port");
$imap->User($username);
$imap->Password($password);
$imap->connect() or die "$@";
}
else {
$imap_port = $default_imap_port unless $imap_port;
$imap = Mail::IMAPClient->new(Debug => 0 );
$imap->Server("$imap_server:$imap_port");
$imap->User($username);
$imap->Password($password);
$imap->connect() or die "$@";
}
alarm 0;
};
if( $@ ) {
chomp $@;
print "IMAP RECEIVE CRITICAL - Could not connect to $imap_server port $imap_port: $@\n";
exit $status{CRITICAL};
}
unless( $imap ) {
print "IMAP RECEIVE CRITICAL - Could not connect to $imap_server port $imap_port: $@\n";
exit $status{CRITICAL};
}
my $time_connected = time;
# select a mailbox
unless( $imap->select($mailbox) ) {
print "IMAP RECEIVE CRITICAL - Could not select $mailbox: $@ $!\n";
$imap->logout();
exit $status{CRITICAL};
}
# search for messages
my $tries = 0;
my @msgs;
until( scalar(@msgs) != 0 || $tries >= $max_retries ) {
eval {
$imap->select( $mailbox );
# if download flag is on, we download recent messages and search ourselves
if( $download ) {
@msgs = download_and_search($imap,@search);
}
else {
@msgs = $imap->search(@search);
die "Invalid search parameters: $@" if $@;
}
};
if( $@ ) {
chomp $@;
print "Cannot search messages: $@\n";
$imap->close();
$imap->logout();
exit $status{UNKNOWN};
}
$report->{found} = scalar(@msgs);
$tries++;
sleep $interval unless (scalar(@msgs) != 0 || $tries >= $max_retries);
}
sub download_and_search {
my ($imap,@search) = @_;
my $ims = new ImapMessageSearch;
$ims->querytokens(@search);
my @found = ();
@msgs = $imap->messages or die "Cannot list messages: $@\n";
@msgs = @msgs[0..$download_max-1] if $download_max;
foreach my $m (@msgs) {
my $message = $imap->message_string($m);
push @found, $m if $ims->match($message);
}
return @found;
}
# capture data in messages
my $captured_max_id = "";
my $captured_min_id = "";
if( $capture_max || $capture_min ) {
my $max = undef;
my $min = undef;
my %captured = ();
for (my $i=0;$i < scalar(@msgs); $i++) {
my $message = $imap->message_string($msgs[$i]);
if( $message =~ m/$capture_max/ ) {
if( !defined($max) || $1 > $max ) {
$captured{ $i } = 1;
$max = $1;
$captured_max_id = $msgs[$i];
}
}
if( $message =~ m/$capture_min/ ) {
if( !defined($min) || $1 < $min ) {
$captured{ $i } = 1;
$min = $1;
$captured_min_id = $msgs[$i];
}
}
print $message if $verbose > 1;
}
$report->{captured} = scalar keys %captured;
$report->{max} = $max if defined $max;
$report->{min} = $min if defined $min;
}
# delete messages
if( $delete ) {
my $deleted = 0;
for (my $i=0;$i < scalar(@msgs); $i++) {
next if ($no_delete_captured && ($captured_max_id eq $msgs[$i]));
next if ($no_delete_captured && ($captured_min_id eq $msgs[$i]));
$imap->delete_message($msgs[$i]);
$deleted++;
}
$report->{deleted} = $deleted;
$imap->expunge() if $deleted;
}
# deselect the mailbox
$imap->close();
# disconnect from IMAP server
$imap->logout();
# calculate elapsed time and issue warnings
my $time_end = time;
my $elapsedtime = $time_end - $time_start;
$report->{seconds} = $elapsedtime;
my @warning = ();
my @critical = ();
push @warning, "no messages" if( scalar(@msgs) == 0 );
push @critical, "found less than $search_critical_min" if ( scalar(@msgs) < $search_critical_min );
push @warning, "connection time more than $warntime" if( $time_connected - $time_start > $warntime );
push @critical, "connection time more than $criticaltime" if( $time_connected - $time_start > $criticaltime );
# print report and exit with known status
my $short_report = $report->text(qw/seconds found captured max min deleted/);
if( scalar @critical ) {
my $crit_alerts = join(", ", @critical);
print "IMAP RECEIVE CRITICAL - $crit_alerts; $short_report\n";
exit $status{CRITICAL};
}
if( scalar @warning ) {
my $warn_alerts = join(", ", @warning);
print "IMAP RECEIVE WARNING - $warn_alerts; $short_report\n";
exit $status{WARNING};
}
print "IMAP RECEIVE OK - $short_report\n";
exit $status{OK};
# utility to load required modules. exits if unable to load one or more of the modules.
sub load_modules {
my @missing_modules = ();
foreach( @_ ) {
eval "require $_";
push @missing_modules, $_ if $@;
}
if( @missing_modules ) {
print "Missing perl modules: @missing_modules\n";
return 0;
}
return 1;
}
# NAME
# PluginReport
# SYNOPSIS
# $report = new PluginReport;
# $report->{label1} = "value1";
# $report->{label2} = "value2";
# print $report->text(qw/label1 label2/);
package PluginReport;
sub new {
my ($proto,%p) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{$_} = $p{$_} foreach keys %p;
return $self;
}
sub text {
my ($self,@labels) = @_;
my @report = map { "$self->{$_} $_" } grep { defined $self->{$_} } @labels;
my $text = join(", ", @report);
return $text;
}
package ImapMessageSearch;
require Email::Simple;
sub new {
my ($proto,%p) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{querystring} = [];
$self->{querytokens} = [];
$self->{queryfnlist} = [];
$self->{mimemessage} = undef;
$self->{$_} = $p{$_} foreach keys %p;
return $self;
}
sub querystring {
my ($self,$string) = @_;
$self->{querystring} = $string;
return $self->querytokens( parseimapsearch($string) );
}
sub querytokens {
my ($self,@tokens) = @_;
$self->{querytokens} = [@tokens];
$self->{queryfnlist} = [create_search_expressions(@search)];
return $self;
}
sub match {
my ($self,$message_string) = @_;
my $message_mime = Email::Simple->new($message_string);
return $self->matchmime($message_mime);
}
sub matchmime {
my ($self,$message_mime) = @_;
my $match = 1;
foreach my $x (@{$self->{queryfnlist}}) {
$match = $match and $x->($message_mime);
}
return $match;
}
# this should probably become its own Perl module... see also Net::IMAP::Server::Command::Search
sub create_search_expressions {
my (@search) = @_;
return () unless scalar(@search);
my $token = shift @search;
if( $token eq 'TEXT' ) {
my $value = shift @search;
return (sub {shift->as_string =~ /\Q$value\E/i},create_search_expressions(@search));
}
if( $token eq 'BODY' ) {
my $value = shift @search;
return (sub {shift->body =~ /\Q$value\E/i},create_search_expressions(@search));
}
if( $token eq 'SUBJECT' ) {
my $value = shift @search;
return (sub {shift->header('Subject') =~ /\Q$value\E/i},create_search_expressions(@search));
}
if( $token eq 'HEADER' ) {
my $name = shift @search;
my $value = shift @search;
return (sub {shift->header($name) =~ /\Q$value\E/i},create_search_expressions(@search));
}
if( $token eq 'NOT' ) {
my @exp = create_search_expressions(@search);
my $next = shift @exp;
return (sub { ! $next->(@_) }, @exp);
}
if( $token eq 'OR' ) {
my @exp = create_search_expressions(@search);
my $next1 = shift @exp;
my $next2 = shift @exp;
return (sub { $next1->(@_) or $next2->(@_) }, @exp);
}
}
package main;
1;

View file

@ -1,99 +0,0 @@
#!/usr/bin/python
# mmcgrath#redhat.com
# Aug 08 2007
# License: GPL
from optparse import OptionParser
import commands
import sys
parser = OptionParser(version='0.1')
parser.add_option('-t', '--temperature',
dest = 'temp',
default = False,
action = 'store_true',
help = 'Check Temperatures')
parser.add_option('-f', '--fans',
dest = 'fans',
default = False,
action = 'store_true',
help = 'Check Fans')
(opts, args) = parser.parse_args()
class ipmiValue:
def __init__(self, param='', value='', status=''):
self.param = param
try:
self.value = (int(value.split(' ')[0], 10) * 9) / 5 + 32
except ValueError:
self.value = value
self.status = status
class ipmi:
def __init__(self):
self.rawOutput = commands.getstatusoutput('/usr/bin/ipmitool sdr')[1].split('\n')
self.sdr = []
for i in self.rawOutput:
try:
param = i.split('|')[0].strip()
value = i.split('|')[1].strip()
status = i.split('|')[2].strip()
self.sdr.append(ipmiValue(param, value, status))
except IndexError:
print "ERROR - Invalid output from ipmi tool (is it installed? /usr/bin/ipmitool)"
sys.exit(3)
def temps(self):
''' Return Known Temperatures '''
temps = []
for i in self.sdr:
if i.param.find('Temp') != -1 and i.status.find('ns') == -1:
temps.append(i)
return temps
def fans(self):
''' Return Known Fan Speeds '''
temps = []
for i in self.sdr:
if i.param.find('FAN') != -1 and i.status.find('ns') == -1:
temps.append(i)
return temps
str = False
exitCode = 0
if opts.temp:
ok=True
str='Temps (F)'
i = ipmi()
for temp in i.temps():
str = '%s:%s' % (str, temp.value)
if temp.status != 'ok':
ok=temp.status
if ok:
str = str + ' OK!'
else:
str = str + ' %s' % ok
exitCode = 2
if opts.fans:
ok=True
str='Fans (RPM)'
i = ipmi()
for fan in i.fans():
str = '%s:%s' % (str, fan.value)
if fan.status != 'ok':
ok=fan.status
if ok:
str = str + ' OK!'
else:
str = str + ' %s' % ok
exitCode = 2
if str:
print str
sys.exit(0)
else:
print 'Please see -h for help'
sys.exit(2)

View file

@ -1,86 +0,0 @@
#!/usr/bin/env python
import sys
import re
import requests
koji_host = sys.argv[1]
try:
koji_pkg = sys.argv[2]
except IndexError:
koji_pkg = 'koji'
NAGIOS = {
'OK': 0,
'WARN': 1,
'CRIT': 2
}
TARGETS = {
'web': 'https://%s/koji/' % koji_host,
'hub': 'https://%s/kojihub/' % koji_host,
'pkg': 'https://%s/packages/%s/' % (koji_host, koji_pkg)
}
def do_request(url, method='GET', headers=None, body=None):
try:
res = getattr(requests, method.lower())(url, headers=headers, data=body)
except requests.exceptions.ConnectionError as e:
return (500, e.message)
return (res.status_code, res.text)
def check_web():
url = TARGETS['web']
(status_code, data) = do_request(url)
if status_code != 200:
return (NAGIOS['CRIT'], 'Unable to access "%s"' % url)
if not re.search(r'<div class="pageHeader">[a-zA-Z\s]+</div>', data):
return (NAGIOS['WARN'], 'Unable to match content from "%s"' % url)
return (NAGIOS['OK'], '')
def check_hub(method='system.listMethods'):
url = TARGETS['hub']
xmlrpc = '''<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>%s</methodName>
<params></params>
</methodCall>''' % method
headers = {
'Content-Type': 'text/xml'
}
(status_code, data) = do_request(url, method='POST', headers=headers, body=xmlrpc)
if status_code != 200:
return (NAGIOS['CRIT'], 'Unable to access "%s"' % url)
if len(re.findall(r'<value><string>[a-zA-Z0-9\._]+</string></value>', data)) == 0:
return (NAGIOS['WARN'], 'Unable to parse content from "%s"' % url)
return (NAGIOS['OK'], None)
def check_pkg():
url = TARGETS['pkg']
(status_code, data) = do_request(url)
if status_code != 200:
return (NAGIOS['CRIT'], 'Unable to access "%s"' % url)
if len(re.findall(r'<img src="/icons/folder.gif" alt="\[DIR\]"> <a href="[0-9.\/]+">[0-9.\/]+</a>', data)) == 0:
return (NAGIOS['WARN'], 'Unable to match content from "%s"' % url)
return (NAGIOS['OK'], None)
def main():
ok = NAGIOS['OK']
for (code, msg) in (check_web(), check_hub(), check_pkg()):
if code != ok:
return (code, msg)
return (ok, None)
if __name__ == '__main__':
(code, reason) = main()
if code != NAGIOS['OK']:
sys.stderr.write('%s\n' % reason)
else:
sys.stdout.write('All checks passed.\n')
sys.exit(code)

View file

@ -1,19 +0,0 @@
#!/usr/bin/python
from __future__ import print_function
import fcntl
import sys
try:
f = open('/mnt/koji/.nagios_test', 'r')
f.close()
f = open('/mnt/koji/.nagios_test', 'w')
except IOError as e:
print(e)
print("Could not create file")
sys.exit(2)
fcntl.flock(f, fcntl.LOCK_EX)
f.close()
print("File Locked Successfully")
sys.exit(0)

View file

@ -1,123 +0,0 @@
#! /usr/bin/perl -w
# check_lock_file_age.pl Copyright (C) 2010 Ricky Elrod <codeblock@fedoraproject.org>
#
# Fork of check_file_age.pl
#
# Checks a lock file's size and modification time to make sure it's not empty
# and that it's sufficiently recent.
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
# along with this program (or with Nagios); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA
use strict;
use English;
use Getopt::Long;
use File::stat;
use vars qw($PROGNAME);
use lib "/usr/lib64/nagios/plugins";
use utils qw (%ERRORS &print_revision &support);
sub print_help ();
sub print_usage ();
my ($opt_c, $opt_f, $opt_w, $opt_h, $opt_V);
my ($result, $message, $age, $size, $st);
$PROGNAME="check_lock_file_age";
$opt_w = 1;
$opt_c = 5;
$opt_f = "";
Getopt::Long::Configure('bundling');
GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"f=s" => \$opt_f, "file" => \$opt_f,
"w=f" => \$opt_w, "warning-age=f" => \$opt_w,
"c=f" => \$opt_c, "critical-age=f" => \$opt_c);
if ($opt_V) {
print_revision($PROGNAME, '1.4.14');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if (($opt_c and $opt_w) and ($opt_c < $opt_w)) {
print "Warning time must be less than Critical time.\n";
exit $ERRORS{'UNKNOWN'};
}
$opt_f = shift unless ($opt_f);
if (! $opt_f) {
print "LOCK_FILE_AGE UNKNOWN: No file specified\n";
exit $ERRORS{'UNKNOWN'};
}
# Check that file exists (can be directory or link)
unless (-e $opt_f) {
print "LOCK_FILE_AGE OK: File not found (Lock file removed) - $opt_f\n";
exit $ERRORS{'OK'};
}
$st = File::stat::stat($opt_f);
$age = time - $st->mtime;
$result = 'OK';
# Convert minutes to seconds
if($opt_c) { $opt_c *= 60; }
if($opt_w) { $opt_w *= 60; }
if ($opt_c and $age > $opt_c) {
$result = 'CRITICAL';
}
elsif ($opt_w and $age > $opt_w) {
$result = 'WARNING';
}
# If the age is higher than 2 minutes, convert seconds -> minutes
# If it's higher than a day, use days.
# Just a nicety, to make people not have to do math ;)
if($age > 86400) { $age = int(($age/86400))." days"; }
elsif($age > 120) { $age = int(($age/60))." minutes"; }
else { $age = "$age seconds"; }
print "LOCK_FILE_AGE $result: $opt_f is $age old.\n";
exit $ERRORS{$result};
sub print_usage () {
print "Usage:\n";
print " $PROGNAME [-w <secs>] [-c <secs>] -f <file>\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";
}
sub print_help () {
print_revision($PROGNAME, '1.4.14');
print "Copyright (c) 2010 Ricky Elrod\n\n";
print_usage();
print "\n";
print " <mins> File must be no more than this many minutes old (default: warn 1m, crit 5m)\n";
print "\n";
support();
}

View file

@ -1,49 +0,0 @@
#!/bin/bash
#
# 19-07-2010
# Author: Cherwin Nooitmeer <cherwin@gmail.com>
#
# exit codes
e_ok=0
e_warning=1
e_critical=2
e_unknown=3
# regular expression that matches queue IDs (e.g. D71EF7AC80F8)
queue_id='^[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]'
usage="Invalid command line usage"
if [ -z $1 ]; then
echo $usage
exit $e_unknown
fi
while getopts ":w:c:" options
do
case $options in
w ) warning=$OPTARG ;;
c ) critical=$OPTARG ;;
* ) echo $usage
exit $e_unknown ;;
esac
done
# determine queue size
qsize=$(mailq | egrep -c $queue_id)
if [ -z $qsize ]
then
exit $e_unknown
fi
if [ $qsize -ge $critical ]; then
retval=$e_critical
elif [ $qsize -ge $warning ]; then
retval=$e_warning
elif [ $qsize -lt $warning ]; then
retval=$e_ok
fi
echo "$qsize mail(s) in queue | mail_queue=$qsize"
exit $retval

View file

@ -1,45 +0,0 @@
#!/usr/bin/python2
#
# very simple python script to parse out /proc/mdstat
# and give results for nagios to monitor
#
import sys
import string
devices = []
try:
mdstat = string.split(open('/proc/mdstat').read(), '\n')
except IOError:
# seems we have no software raid on this machines
sys.exit(0)
error = ""
i = 0
for line in mdstat:
if line[0:2] == 'md':
device = string.split(line)[0]
devices.append(device)
status = string.split(mdstat[i+1])[3]
if string.count(status, "_"):
# see if we can figure out what's going on
err = string.split(mdstat[i+2])
msg = "device=%s status=%s" % (device, status)
if len(err) > 0:
msg = msg + " rebuild=%s" % err[0]
if not error:
error = msg
else:
error = error + ", " + msg
i = i + 1
if not error:
print "DEVICES %s OK" % " ".join(devices)
sys.exit(0)
else:
print error
sys.exit(2)

View file

@ -1,84 +0,0 @@
#!/bin/bash
# check_readonlyfs: Check for readonly filesystems
# Copyright (C) 2010 Davide Madrisan <davide.madrisan@gmail.com>
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME --no-network-fs"
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "readonly filesystem checker plugin for Nagios"
echo ""
support
}
NETFS=1
# Grab the command line arguments
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help|-h)
print_help
exit $STATE_OK
;;
--version|-V)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
--no-network-fs|-n)
NETFS="0"
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
[ -r /proc/mounts ] || { echo "cannot read /proc/mounts!"; exit $STATE_UNKNOWN; }
nerr=0
IFS_SAVE="$IFS"
rofs_list=""
while read dev mp fs mopt ignore; do
[ "$dev" = none ] && continue
case $fs in binfmt_misc|devpts|iso9660|proc|selinuxfs|rpc_pipefs|sysfs|tmpfs|usbfs)
continue ;;
esac
case $fs in autofs|nfs|nfs4|smbfs)
# skip the network filesystems
[ "$NETFS" = 0 ] && continue ;;
esac
IFS=","; set -- $mopt; IFS="$IFS_SAVE"
while :; do
case "$1" in
ro) rofs_list="$rofs_list $mp"; nerr=$(( $nerr + 1 )) ;;
"") shift; break ;;
esac
shift
done
done < <(LC_ALL=C /bin/cat /proc/mounts 2>/dev/null)
[ $nerr -eq 0 ] && { echo OK; exit $STATE_OK; } || echo "$rofs_list: read only fs"
exit $exitstatus

View file

@ -1,290 +0,0 @@
#!/usr/bin/perl
use strict;
my $VERSION = '0.4.5';
my $COPYRIGHT = 'Copyright (C) 2005-2008 Jonathan Buhacoff <jonathan@buhacoff.net>';
my $LICENSE = 'http://www.gnu.org/licenses/gpl.txt';
my %status = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );
# look for required modules
exit $status{UNKNOWN} unless load_modules(qw/Getopt::Long Net::SMTP/);
Getopt::Long::Configure("bundling");
my $verbose = 0;
my $help = "";
my $help_usage = "";
my $show_version = "";
my $smtp_server = "";
my $default_smtp_port = "25";
my $default_smtp_ssl_port = "465";
my $default_smtp_tls_port = "587";
my $smtp_port = "";
my @mailto = ();
my $mailfrom = "";
my @header = ();
my $body = "";
my $stdin = "";
my $expect_response = "250";
my $warntime = 15;
my $criticaltime = 30;
my $timeout = 60;
my $tls = 0;
my $ssl = 0;
my $auth_method = undef;
my $username = "";
my $password = "";
my $ok;
$ok = Getopt::Long::GetOptions(
"V|version"=>\$show_version,
"v|verbose+"=>\$verbose,"h|help"=>\$help,"usage"=>\$help_usage,
"w|warning=i"=>\$warntime,"c|critical=i"=>\$criticaltime,"t|timeout=i"=>\$timeout,
# smtp settings
"H|hostname=s"=>\$smtp_server,"p|port=i"=>\$smtp_port,
"mailto=s"=>\@mailto, "mailfrom=s",\$mailfrom,
"header=s"=>\@header, "body=s"=>\$body, "stdin"=>\$stdin,
# SSL/TLS/auth options
"tls!"=>\$tls, "ssl!"=>\$ssl, "auth=s"=>\$auth_method,
"U|username=s"=>\$username,"P|password=s"=>\$password,
# Server response
"E|expect-response=s"=>\$expect_response,
);
if( $show_version ) {
print "$VERSION\n";
if( $verbose ) {
print "Default warning threshold: $warntime seconds\n";
print "Default critical threshold: $criticaltime seconds\n";
print "Default timeout: $timeout seconds\n";
}
exit $status{UNKNOWN};
}
if( $help ) {
exec "perldoc", $0 or print "Try `perldoc $0`\n";
exit $status{UNKNOWN};
}
my @required_module = ();
push @required_module, 'Net::SMTP::SSL' if $ssl;
push @required_module, ('MIME::Base64','Authen::SASL') if $ssl && $username;
push @required_module, 'Net::SMTP::TLS' if $tls;
push @required_module, 'Net::SMTP_auth' if $auth_method;
exit $status{UNKNOWN} unless load_modules(@required_module);
# split up @mailto if commas were used instead of multiple options
@mailto = split(/,/,join(',',@mailto));
if( $help_usage ||
(
$smtp_server eq "" || scalar(@mailto)==0 || $mailfrom eq ""
)
) {
print "Usage: $0 -H host [-p port] --mailto recipient\@your.net [--mailto recipient2\@your.net ...] --mailfrom sender\@your.net --body 'some text' [-w <seconds>] [-c <seconds>]\n";
exit $status{UNKNOWN};
}
# initialize
my $report = new PluginReport;
my $time_start = time;
my $actual_response = undef;
my @warning = ();
my @critical = ();
# connect to SMTP server
# create the smtp handle using Net::SMTP, Net::SMTP::SSL, or Net::SMTP::TLS
my $smtp;
eval {
if( $tls ) {
$smtp_port = $default_smtp_tls_port unless $smtp_port;
$smtp = Net::SMTP::TLS->new($smtp_server, Timeout=>$timeout, Port=>$smtp_port, User=>$username, Password=>$password);
}
elsif( $ssl ) {
$smtp_port = $default_smtp_ssl_port unless $smtp_port;
$smtp = Net::SMTP::SSL->new($smtp_server, Port => $smtp_port, Timeout=>$timeout,Debug=>0);
if( $smtp && $username ) {
$smtp->auth($username, $password);
}
}
elsif( $auth_method ) {
$smtp_port = $default_smtp_port unless $smtp_port;
$smtp = Net::SMTP_auth->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>0);
if( $smtp ) {
$smtp->auth($auth_method, $username, $password);
}
}
else {
$smtp_port = $default_smtp_port unless $smtp_port;
$smtp = Net::SMTP->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>0);
if( $smtp && $username ) {
$smtp->auth($username, $password);
}
}
};
if( $@ ) {
$@ =~ s/\n/ /g; # the error message can be multiline but we want our output to be just one line
print "SMTP SEND CRITICAL - $@\n";
exit $status{CRITICAL};
}
unless( $smtp ) {
print "SMTP SEND CRITICAL - Could not connect to $smtp_server port $smtp_port\n";
exit $status{CRITICAL};
}
my $time_connected = time;
# add the monitored server's banner to the report
if( $tls ) {
$report->{banner} = "";
}
elsif( $ssl ) {
$report->{banner} = $smtp->banner || "";
chomp $report->{banner};
}
else {
$report->{banner} = $smtp->banner || "";
chomp $report->{banner};
}
# send email
if( $stdin ) {
$body = "";
while(<STDIN>) {
$body .= $_;
}
}
$smtp->mail($mailfrom);
foreach( @mailto ) {
# the two SMTP modules have different error reporting mechanisms:
if( $tls ) {
# Net::SMTP::TLS croaks when the recipient is rejected
eval {
$smtp->to($_);
};
if( $@ ) {
print "SMTP SEND CRITICAL - Could not send to $_\n";
exit $status{CRITICAL};
}
}
else {
# Net::SMTP returns false when the recipient is rejected
my $to_returned = $smtp->to($_);
if( !$to_returned ) {
print "SMTP SEND CRITICAL - Could not send to $_\n";
exit $status{CRITICAL};
}
}
}
# Net::SMTP::TLS doesn't implement code() so we need to wrap calls in eval to get our error messages
# start data transfer (expect response 354)
$smtp->data();
# send data
$smtp->datasend("To: ".join(", ",@mailto)."\n");
$smtp->datasend("From: $mailfrom\n");
foreach( @header ) {
$smtp->datasend("$_\n");
}
$smtp->datasend("\n");
$smtp->datasend($body);
$smtp->datasend("\n");
eval {
# end data transfer (expect response 250)
$smtp->dataend();
};
if( $@ ) {
$actual_response = $tls ? get_tls_error($@) : $smtp->code();
}
else {
$actual_response = $tls ? "250" : $smtp->code(); # no error means we got 250
}
eval {
# disconnect from SMTP server (expect response 221)
$smtp->quit();
};
if( $@ ) {
push @warning, "Error while disconnecting from $smtp_server";
}
# calculate elapsed time and issue warnings
my $time_end = time;
my $elapsedtime = $time_end - $time_start;
$report->{seconds} = $elapsedtime;
push @warning, "connection time more than $warntime" if( $time_connected - $time_start > $warntime );
push @critical, "connection time more than $criticaltime" if( $time_connected - $time_start > $criticaltime );
push @critical, "response was $actual_response but expected $expect_response" if ( $actual_response ne $expect_response );
# print report and exit with known status
my $short_report = $report->text(qw/seconds/);
my $long_report = join("", map { "$_: $report->{$_}\n" } qw/banner/ );
if( scalar @critical ) {
my $crit_alerts = join(", ", @critical);
print "SMTP SEND CRITICAL - $crit_alerts; $short_report\n";
print $long_report if $verbose;
exit $status{CRITICAL};
}
if( scalar @warning ) {
my $warn_alerts = join(", ", @warning);
print "SMTP SEND WARNING - $warn_alerts; $short_report\n";
print $long_report if $verbose;
exit $status{WARNING};
}
print "SMTP SEND OK - $short_report\n";
print $long_report if $verbose;
exit $status{OK};
# utility to load required modules. exits if unable to load one or more of the modules.
sub load_modules {
my @missing_modules = ();
foreach( @_ ) {
eval "require $_";
push @missing_modules, $_ if $@;
}
if( @missing_modules ) {
print "Missing perl modules: @missing_modules\n";
return 0;
}
return 1;
}
# utility to extract error codes out of Net::SMTP::TLS croak messages
sub get_tls_error {
my ($errormsg) = @_;
$errormsg =~ m/: (\d+) (.+)/;
my $code = $1;
return $code;
}
# NAME
# PluginReport
# SYNOPSIS
# $report = new PluginReport;
# $report->{label1} = "value1";
# $report->{label2} = "value2";
# print $report->text(qw/label1 label2/);
package PluginReport;
sub new {
my ($proto,%p) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{$_} = $p{$_} foreach keys %p;
return $self;
}
sub text {
my ($self,@labels) = @_;
my @report = map { "$self->{$_} $_" } grep { defined $self->{$_} } @labels;
my $text = join(", ", @report);
return $text;
}
package main;
1;

View file

@ -1,48 +0,0 @@
#!/usr/bin/env bash
# Description : script to check the status of systemd units
# if they failed, try to restart the service once !!
# Author : Seddik Alaoui Ismaili
# Version : 1.0
# Exits code
warning_exit="1"
ok_exit="0"
# Unit list
unit_list=(pagure_ci
pagure_ev
pagure_fast_worker
pagure_loadjson
pagure_logcom
pagure_medium_worker
pagure_milter
pagure_mirror
pagure_slow_worker
pagure_webhook
pagure_worker
pagure_mirror_project_in.timer)
#Element's arrays
failed_array=()
active_array=()
# Check units's status
echo -e "here the lenght of array : ${#active_array[@]}"
for element in ${unit_list[@]}; do
status=$(systemctl status ${element} |grep -E "Active:" | awk '{ print $2 }')
if [ $status == failed ]; then
systemctl restart ${element} && active_array+=($element) || failed_array+=($element)
fi
done
# check the lenght of array and print result/exit code for nagios
if [ ${#failed_array[@]} -ne "0" ]; then
echo -e "WARNING - Failed systemd units after restart : ${failed_array[@]}"
exit ${warning_exit}
elif [ ${#failed_array[@]} -eq "0" ]; then
echo -e "OK - Systemd units are active"
exit ${ok_exit}
fi

View file

@ -1,19 +0,0 @@
#!/bin/bash
RUNNING_VMS=`testcloud instance list | grep -i 'running' | wc -l`
CRITICAL=30
WARNING=25
if [ $RUNNING_VMS -gt $CRITICAL ]
then
echo "Testcloud: CRITICAL Number of VMs running: $RUNNING_VMS"
exit 2
elif [ $RUNNING_VMS -gt $WARNING ]
then
echo "Testcloud: WARNING Number of VMs running: $RUNNING_VMS"
exit 1
else
echo "Testcloud: OK Number of VMs running: $RUNNING_VMS"
exit 0
fi

View file

@ -1,73 +0,0 @@
#!/bin/sh
#
# Event handler script for restarting the web server on the local machine
#
# Note: This script will only restart the web server if the service is
# retried 3 times (in a "soft" state) or if the web service somehow
# manages to fall into a "hard" error state.
#
servicestate=$1
servicestatetype=$2
serviceattempt=$3
remotehost=$4
hostalias=$5
servicedesc=$6
servicestate=$7
# What state is the HTTP service in?
case "$servicestate" in
OK)
# The service just came back up, so don't do anything...
;;
WARNING)
# We don't really care about warning states, since the service is probably still running...
;;
UNKNOWN)
# We don't know what might be causing an unknown error, so don't do anything...
;;
CRITICAL)
# Aha! The HTTP service appears to have a problem - perhaps we should restart the server...
# Is this a "soft" or a "hard" state?
case "$servicestatetype" in
# We're in a "soft" state, meaning that Nagios is in the middle of retrying the
# check before it turns into a "hard" state and contacts get notified...
SOFT)
# What check attempt are we on? We don't want to restart the web server on the first
# check, because it may just be a fluke!
case "$serviceattempt" in
# Wait until the check has been tried 2 times before reloading the web server.
# If the check fails on the 4th time (after we restart the web server), the state
# type will turn to "hard" and contacts will be notified of the problem.
# Hopefully this will restart the web server successfully, so the 4th check will
# result in a "soft" recovery. If that happens no one gets notified because we
# fixed the problem!
2)
echo -n "Restarting HTTP service (3rd soft critical state)..."
# Call the init script to restart the HTTPD server
echo "#fedora-noc $hostalias - Attempting to reload httpd. $servicedesc is $servicestate (2nd check)" | /usr/bin/nc -w 1 value01 5050
/usr/lib64/nagios/plugins/check_nrpe -H $remotehost -c service_httpd_reload
;;
esac
;;
# The HTTP service somehow managed to turn into a hard error without getting fixed.
# It should have been restarted by the code above, but for some reason it didn't.
# Let's give it one last try, shall we?
# Note: Contacts have already been notified of a problem with the service at this
# point (unless you disabled notifications for this service)
HARD)
echo -n "Restarting HTTP service..."
echo "#fedora-noc $hostalias - Attempting to reload httpd. $servicedesc is $servicestate" | /usr/bin/nc -w 1 value01 5050
# Call the init script to restart the HTTPD server
/usr/lib64/nagios/plugins/check_nrpe -H $remotehost -c service_httpd_restart
;;
esac
;;
esac
exit 0

View file

@ -1,73 +0,0 @@
#!/bin/sh
#
# Event handler script for restarting the rsyslog server on the local machine
#
# Note: This script will only restart the web server if the service is
# retried 3 times (in a "soft" state) or if the web service somehow
# manages to fall into a "hard" error state.
#
servicestate=$1
servicestatetype=$2
serviceattempt=$3
remotehost=$4
hostalias=$5
servicedesc=$6
servicestate=$7
# What state is the HTTP service in?
case "$servicestate" in
OK)
# The service just came back up, so don't do anything...
;;
WARNING)
# We don't really care about warning states, since the service is probably still running...
;;
UNKNOWN)
# We don't know what might be causing an unknown error, so don't do anything...
;;
CRITICAL)
# Aha! The rsyslog service appears to have a problem - perhaps we should restart the server...
# Is this a "soft" or a "hard" state?
case "$servicestatetype" in
# We're in a "soft" state, meaning that Nagios is in the middle of retrying the
# check before it turns into a "hard" state and contacts get notified...
SOFT)
# What check attempt are we on? We don't want to restart the web server on the first
# check, because it may just be a fluke!
case "$serviceattempt" in
# Wait until the check has been tried 2 times before reloading the web server.
# If the check fails on the 4th time (after we restart the web server), the state
# type will turn to "hard" and contacts will be notified of the problem.
# Hopefully this will restart the web server successfully, so the 4th check will
# result in a "soft" recovery. If that happens no one gets notified because we
# fixed the problem!
2)
echo -n "Restarting rsyslog service (3rd soft critical state)..."
# Call the init script to restart the rsyslog server
echo "#fedora-noc $hostalias - Attempting to reload rsyslog. $servicedesc is $servicestate (2nd check)" | /usr/bin/nc -w 1 value01 5050
/usr/lib64/nagios/plugins/check_nrpe -H $remotehost -c service_rsyslog_reload
;;
esac
;;
# The HTTP service somehow managed to turn into a hard error without getting fixed.
# It should have been restarted by the code above, but for some reason it didn't.
# Let's give it one last try, shall we?
# Note: Contacts have already been notified of a problem with the service at this
# point (unless you disabled notifications for this service)
HARD)
echo -n "Restarting rsyslog service..."
echo "#fedora-noc $hostalias - Attempting to restart rsyslog. $servicedesc is $servicestate" | /usr/bin/nc -w 1 value01 5050
# Call the init script to restart the HTTPD server
/usr/lib64/nagios/plugins/check_nrpe -H $remotehost -c service_rsyslog_restart
;;
esac
;;
esac
exit 0

View file

@ -1,133 +0,0 @@
#!/usr/bin/python3
#
# A script to read the Nagios status file and send email for notifications
# off, but have recovered.
#
# Written by Athmane Madjoudj <athmane@fedoraproject.org>, 2011-11-15
# based on tummy.com's work <jafo@tummy.com>, 2010-11-16
# Minimally ported to Python 3 by Adam Williamson <adamwill@fedoraproject.org>, 2023-08-14
# Released under the GPLv2.
import re
from smtplib import SMTP
from email.mime.text import MIMEText
from socket import gethostname
# Settings
debug = 0
EMAIL_FROM = "nagios@fedoraproject.org"
EMAIL_TO = "sysadmin-noc-members@fedoraproject.org"
# EMAIL_TO="athmane@fedoraproject.org"
nagios_status_file = "/var/spool/nagios/status.dat"
class NagiosStatus:
def __init__(self, filename):
self.filename = filename
self.hosts = {}
self.load_status_file()
def load_status_file(self):
fp = open(self.filename, "r")
while True:
line = fp.readline()
if not line:
break
m = re.match(r"^hoststatus\s+{\s*$", line)
if m:
if debug >= 2:
print("START OF HOST")
data = {"services": []}
while True:
line = fp.readline()
if not line:
break
if debug >= 2:
print("host: %s" % line.rstrip())
m2 = re.match(r"^\s+([^=]+)=(\S.*)*$", line.rstrip())
if not m2:
break
data[m2.group(1)] = m2.group(2)
self.hosts[data["host_name"]] = data
if debug >= 2:
print("END OF HOST")
m = re.match(r"^servicestatus\s+{\s*$", line)
if m:
if debug >= 2:
print("START OF SERVICE")
data = {}
while True:
line = fp.readline()
if not line:
break
if debug >= 2:
print("service: %s" % line.rstrip())
m2 = re.match(r"^\s+([^=]+)=(.*)$", line.rstrip())
if not m2:
break
data[m2.group(1)] = m2.group(2)
self.hosts[data["host_name"]]["services"].append(data)
if debug >= 2:
print("END OF SERVICE")
def main():
status = NagiosStatus(nagios_status_file)
output = ""
for host in sorted(status.hosts.keys()):
host = status.hosts[host]
if host.get("notifications_enabled", None) == None:
output += "Host %s has no notifications_enabled line \n" % host["host_name"]
continue
# are there any hard states that aren't 0 or 1?
hard_states = [
x
for x in [int(x["last_hard_state"]) for x in host["services"]]
if x not in [0, 1]
]
need_newline = False
if host["notifications_enabled"] == "0" and not hard_states:
output += (
"Host %s has notifications disabled and all services ok \n"
% host["host_name"]
)
need_newline = True
for service in host["services"]:
if debug:
print("%s@%s" % (service["check_command"], host["host_name"]))
print(
" notifications_enabled: %(notifications_enabled)s last_hard_state: %(last_hard_state)s"
% service
)
if int(service["notifications_enabled"]) == 0 and int(
service["last_hard_state"]
) in [0, 1]:
output += (
"Service %(check_command)s@%(host_name)s\n"
" has notifications disabled, but is ok\n"
) % service
need_newline = True
if need_newline:
output += "\n\n"
if output.strip() != "":
msg_body = (
"List of notifications off for recovered hosts/services: \n\n" + output
)
msg = MIMEText(msg_body)
msg["Subject"] = "Notifications status on %s" % gethostname()
msg["From"] = EMAIL_FROM
msg["To"] = EMAIL_TO
smtp_conn = SMTP()
smtp_conn.connect("localhost")
smtp_conn.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
smtp_conn.quit()
if __name__ == "__main__":
main()

View file

@ -1,59 +0,0 @@
#!/usr/bin/python3
""" Reads a string from stdin and prints it to stdout with irc colors
:license: LGPLv2+
:author: Ralph Bean <rbean@redhat.com>
"""
import sys
mirc_colors = {
"white": 0,
"black": 1,
"blue": 2,
"green": 3,
"red": 4,
"brown": 5,
"purple": 6,
"orange": 7,
"yellow": 8,
"light green": 9,
"teal": 10,
"light cyan": 11,
"light blue": 12,
"pink": 13,
"grey": 14,
"light grey": 15,
}
mapping = {
'RECOVERY': 'green',
'OK': 'green',
'ACKNOWLEDGEMENT': 'yellow',
'UNKNOWN': 'purple',
'WARNING': 'teal',
# 'red' probably makes the most sense here, but it behaved oddly
'PROBLEM': 'brown',
'CRITICAL': 'brown',
}
def markup(string, color):
return "\x02\x03%i%s\x03\x02" % (mirc_colors[color], string)
def colorize(word):
suffix = ''
if word.endswith(':'):
word, suffix = word[:-1], word[-1]
if word in mapping:
word = markup(word, mapping[word])
return word + suffix
if __name__ == '__main__':
lines = sys.stdin.readlines()
for line in lines:
print(" ".join([colorize(word) for word in line.strip().split()]))

View file

@ -1,143 +0,0 @@
#define servicedependency {
# host_name hosted03
# service_description nrpe
# dependent_host_name hosted03
# dependent_service_description Disk Space /srv, Disk Space /, Total Processes, Zombie Processes, Cron Daemon, Check Raid, Swap
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#define servicedependency {
# host_name hosted04
# service_description nrpe
# dependent_host_name hosted04
# dependent_service_description Disk Space /srv, Disk Space /, Total Processes, Zombie Processes, Cron Daemon, Check Raid, Swap
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#
#define servicedependency {
# host_name pkgdb01
# service_description nrpe
# dependent_host_name pkgdb01
# dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#
#define servicedependency {
# host_name pkgdb02
# service_description nrpe
# dependent_host_name pkgdb02
# dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#
#define servicedependency {
# host_name pkgdb01.stg
# service_description nrpe
# dependent_host_name pkgdb01.stg
# dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#define servicedependency {
# host_name bapp02
# service_description nrpe
# dependent_host_name bapp02
# dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
define servicedependency {
host_name bastion02
service_description nrpe
dependent_host_name bastion02
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name bastion-vpn
service_description nrpe
dependent_host_name bastion-vpn
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name sundries01
service_description nrpe
dependent_host_name sundries01
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
# define servicedependency {
# host_name sundries01.stg
# service_description nrpe
# dependent_host_name sundries01.stg
# dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
# notification_failure_criteria w,c
# execution_failure_criteria w,c
# }
define servicedependency {
host_name sundries02
service_description nrpe
dependent_host_name sundries02
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name wiki01
service_description nrpe
dependent_host_name wiki01
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name wiki01.stg
service_description nrpe
dependent_host_name wiki01.stg
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name wiki02
service_description nrpe
dependent_host_name wiki02
dependent_service_description Check Raid, Cron Daemon, Disk Space /, Swap, Total Processes, Zombie Processes
notification_failure_criteria w,c
execution_failure_criteria w,c
}
#define servicedependency {
# host_name packages03
# service_description packages-internal
# dependent_host_name packages03
# dependent_service_description packages-internal-bugstab
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}
#
#define servicedependency {
# host_name packages04
# service_description packages-internal
# dependent_host_name packages04
# dependent_service_description packages-internal-bugstab
# notification_failure_criteria w,c
# execution_failure_criteria w,c
#}

View file

@ -1,72 +0,0 @@
define servicedependency {
host_name proxy03.rdu3.fedoraproject.org
service_description https
dependent_host_name proxy03.rdu3.fedoraproject.org
dependent_service_description bodhi, elections, accounts, mirrors.fedoraproject.org - mirrorlist, mirrors.fedoraproject.org - publiclist, docs.fedoraproject.org
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 38.145.32.20-rdu3
service_description https
dependent_host_name 38.145.32.20-rdu3
dependent_service_description bodhi, elections, docs.fedoraproject.org, mirrors.fedoraproject.org - mirrorlist, mirrors.fedoraproject.org - publiclist, fedoraproject.org, fedoraproject.org - wiki
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 152.19.134.142-ibiblio
service_description https
dependent_host_name 152.19.134.142-ibiblio
dependent_service_description bodhi, elections, accounts, mirrors.fedoraproject.org - mirrorlist, mirrors.fedoraproject.org - publiclist, docs.fedoraproject.org
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 152.19.134.198-ibiblio
service_description https
dependent_host_name 152.19.134.198-ibiblio
dependent_service_description bodhi, elections, accounts, mirrors.fedoraproject.org - mirrorlist, mirrors.fedoraproject.org - publiclist, docs.fedoraproject.org
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 85.236.55.6-internetx
service_description https
dependent_host_name 85.236.55.6-internetx
dependent_service_description bodhi, elections, accounts, mirrors.fedoraproject.org - mirrorlist, mirrors.fedoraproject.org - publiclist, docs.fedoraproject.org
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 152.19.134.142-ibiblio
service_description http
dependent_host_name 152.19.134.142-ibiblio
dependent_service_description fedoraproject.org, fedoraproject.org - wiki
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 152.19.134.198-ibiblio
service_description http
dependent_host_name 152.19.134.198-ibiblio
dependent_service_description fedoraproject.org, fedoraproject.org - wiki
notification_failure_criteria w,c
execution_failure_criteria w,c
}
define servicedependency {
host_name 85.236.55.6-internetx
service_description http
dependent_host_name 85.236.55.6-internetx
dependent_service_description fedoraproject.org, fedoraproject.org - wiki
notification_failure_criteria w,c
execution_failure_criteria w,c
}

View file

@ -1,4 +0,0 @@
define servicegroup {
servicegroup_name bodhi
alias Bodhi
}

View file

@ -1,5 +0,0 @@
define servicegroup {
servicegroup_name fas
alias Fedora Account System
}

View file

@ -1,11 +0,0 @@
define servicegroup {
servicegroup_name fp-wiki
alias Fedora Project Wiki
}
define servicegroup {
servicegroup_name fp-wiki-non-cached
alias Fedora Project Wiki
}

View file

@ -1,5 +0,0 @@
define servicegroup {
servicegroup_name freemedia
alias FreeMedia
}

View file

@ -1,4 +0,0 @@
define servicegroup {
servicegroup_name ipa
alias IPA Servers
}

View file

@ -1,6 +0,0 @@
define servicegroup {
servicegroup_name mirrorlist
alias Mirrorlist
}

View file

@ -1,9 +0,0 @@
define servicegroup {
servicegroup_name mgmt-http
alias mgmt interfaces on http
}
define servicegroup {
servicegroup_name mgmt-https
alias mgmt interfaces on https
}

View file

@ -1 +0,0 @@
# TODO: define Koschei backend services here

View file

@ -1,7 +0,0 @@
define service {
host_name noc02.fedoraproject.org
service_description Check Nagios
check_command check_by_nrpe!check_nagios
use criticaltemplate
}

View file

@ -1,6 +0,0 @@
define service {
host_name ipv6-noc02.fedoraproject.org
service_description ICMP-Ping6-check
check_command check-host-alive6!fedorapeople.org!1500.0,20%!2500.0,80%
use criticaltemplate
}

View file

@ -1,8 +0,0 @@
define service {
host_name bastion01.rdu3.fedoraproject.org, sundries01.rdu3.fedoraproject.org, wiki01.rdu3.fedoraproject.org
service_description nrpe
check_command test_nrpe
max_check_attempts 2
check_interval 2
use defaulttemplate
}

View file

@ -1,187 +0,0 @@
###############################################################################
###############################################################################
#
# SERVICE TEMPLATES
#
###############################################################################
###############################################################################
# Generic service definition template - This is NOT a real service, just a template!
define service{
name generic-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
# Local service definition template - This is NOT a real service, just a template!
define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_interval 1 ; Re-check the service every minute until a hard state can be determined
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
define service {
name criticaltemplate
max_check_attempts 4
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name defaulttemplate
max_check_attempts 3
check_interval 10
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name disktemplate
max_check_attempts 3
check_interval 30
retry_interval 1
check_period 24x7
notification_interval 40
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name builderdisktemplate
max_check_attempts 12
check_interval 30
retry_interval 1
check_period 24x7
notification_interval 40
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name lighttemplate
max_check_attempts 3
check_interval 480
retry_interval 5
check_period 12x7-USET
notification_interval 490
notification_period 12x7-USET
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name websitetemplate
max_check_attempts 3
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name internalwebsitetemplate
max_check_attempts 3
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
use defaulttemplate
name passivetemplate
active_checks_enabled 0
passive_checks_enabled 1
check_command check_dummy!0
check_period 24x7
check_freshness 0
register 0
}
define service {
name ppc-secondarytemplate
max_check_attempts 3
check_interval 10
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}
define service {
name retracetemplate
max_check_attempts 3
check_interval 10
retry_interval 1
check_period 24x7
notification_interval 15
notification_period 24x7
notification_options w,u,c,r
contact_groups fedora-sysadmin-ircbot
register 0
}

View file

@ -1,4 +0,0 @@
module:
checkmodule -Mmo nagios_hostname.mod nagios_hostname.te
semodule_package -o nagios_hostname.pp -m nagios_hostname.mod
rm nagios_hostname.mod

View file

@ -1,11 +0,0 @@
module nagios_hostname 1.0;
require {
type nagios_t;
type hostname_exec_t;
class file { read getattr open execute execute_no_trans };
}
#============= nagios_t ==============
allow nagios_t hostname_exec_t:file { read getattr open execute execute_no_trans };

View file

@ -1,32 +0,0 @@
module nagios_nrpe 1.0;
require {
type nagios_t;
type nagios_checkdisk_plugin_t;
type nagios_unconfined_plugin_t;
type nrpe_t;
type system_mail_t;
class process { noatsecure rlimitinh siginh };
class tcp_socket { read write };
}
#============= nagios_checkdisk_plugin_t ==============
# src="nagios_checkdisk_plugin_t" tgt="nrpe_t" class="tcp_socket", perms="{ read write }"
# comm="check_disk" exe="" path="socket:[270138836]"
allow nagios_checkdisk_plugin_t nrpe_t:tcp_socket { read write };
#============= nagios_t ==============
# src="nagios_t" tgt="nagios_unconfined_plugin_t" class="process", perms="{ noatsecure rlimitinh siginh }"
# comm="check_ping" exe="" path=""
allow nagios_t nagios_unconfined_plugin_t:process { noatsecure rlimitinh siginh };
# src="nagios_t" tgt="system_mail_t" class="process", perms="{ noatsecure rlimitinh siginh }"
# comm="sendmail" exe="" path=""
allow nagios_t system_mail_t:process { noatsecure rlimitinh siginh };
#============= nrpe_t ==============
# src="nrpe_t" tgt="nagios_checkdisk_plugin_t" class="process", perms="{ noatsecure rlimitinh siginh }"
# comm="check_disk" exe="" path=""
allow nrpe_t nagios_checkdisk_plugin_t:process { noatsecure rlimitinh siginh };
# src="nrpe_t" tgt="nagios_unconfined_plugin_t" class="process", perms="{ noatsecure rlimitinh siginh }"
# comm="check_swap" exe="" path=""
allow nrpe_t nagios_unconfined_plugin_t:process { noatsecure rlimitinh siginh };

View file

@ -1,3 +0,0 @@
---
- name: Restart nrpe
service: name=nrpe state=restarted

View file

@ -1,78 +0,0 @@
##
## A playbook to set up a Nagios 4 server
##
## Setup the initial user and groups.
---
- name: Stop and disable the nagios service
service: name=nagios.service state=stopped enabled=no
check_mode: no
failed_when: false
tags:
- nagios_server
- name: Remove nagios user
user: name=nagios state=absent
tags:
- nagios_server
- name: Remove nagios group
group: name=nagios state=absent
tags:
- nagios_server
## Remove the initial packages for the group. Leave some more generic ones like php
- name: Remove nagios packages
ansible.builtin.package:
state: absent
name:
#- php
- nagios.x86_64
- nagios-selinux
- nrpe-selinux
- nagios-plugins
- nagios-plugins-dig
- nagios-plugins-disk
- nagios-plugins-dns
- nagios-plugins-dummy
- nagios-plugins-file_age
- nagios-plugins-http
- nagios-plugins-load
- nagios-plugins-nagios
- nagios-plugins-nrpe
- nagios-plugins-perl
- nagios-plugins-pgsql
- nagios-plugins-ping
- nagios-plugins-procs
- nagios-plugins-smtp
- nagios-plugins-ssh
- nagios-plugins-swap
- nagios-plugins-tcp
- nagios-plugins-users
#- stunnel
#- mod_auth_gssapi
#- ipmitool
tags:
- nagios_server
## Remove Nagios directories & files
- name: Remove directories for Nagios
ansible.builtin.file: dest={{item}} state=absent
with_items:
# homedir
- /var/spool/nagios
# the rest
- /etc/nagios
- /usr/lib64/nagios
- /usr/local/share/nagios-policy
# leftovers
- /usr/local/bin/irc-colorize.py
- /usr/local/bin/check_nagios_notifications.py
- /etc/httpd/conf.d/nagios.conf
- /etc/httpd/conf.d/0_nagios-external.conf
- /usr/share/nagios/html/config.inc.php
- /usr/local/bin/matrix-notify.sh
tags:
- nagios_server

View file

@ -1,20 +0,0 @@
<VirtualHost *:80>
ServerName nagios-external.fedoraproject.org
ProxyPass "/.well-known/acme-challenge" "http://certgetter01/.well-known/acme-challenge"
Redirect permanent / https://nagios-external.fedoraproject.org/
</VirtualHost>
<VirtualHost *:443>
ServerName nagios-external.fedoraproject.org:443
SSLEngine on
SSLProtocol {{ ssl_protocols }}
SSLCipherSuite {{ ssl_ciphers }}
Header always add Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
SSLCertificateFile /etc/pki/tls/certs/nagios-external.fedoraproject.org.cert
SSLCertificateChainFile /etc/pki/tls/certs/nagios-external.fedoraproject.org.intermediate.cert
SSLCertificateKeyFile /etc/pki/tls/private/nagios-external.fedoraproject.org.key
ProxyPass "/.well-known/acme-challenge" "http://certgetter01/.well-known/acme-challenge"
</VirtualHost>

View file

@ -1,63 +0,0 @@
# Set up the script aliases
ScriptAlias /nagios/cgi-bin/ /usr/lib64/nagios/cgi-bin/
ScriptAlias /tac.cgi /usr/lib64/nagios/cgi-bin/tac.cgi
Alias /robots.txt /var/www/robots.txt
# Set up the authorization
<Location /nagios>
AuthName "Nagios GSSAPI Login"
{% if datacenter != 'ibiblio' %}
GssapiCredStore keytab:/etc/krb5.HTTP_nagios{{env_suffix}}.fedoraproject.org.keytab
# This is off because Apache (and thus mod_auth_gssapi) doesn't know this is proxied over TLS
GssapiSSLonly Off
{% else %}
GssapiCredStore keytab:/etc/krb5.HTTP_nagios-external{{env_suffix}}.fedoraproject.org.keytab
GssapiSSLonly On
{% endif %}
GssapiLocalName on
AuthType GSSAPI
<Limit GET HEAD>
Require all granted
</Limit>
<LimitExcept GET HEAD>
Require valid-user
</LimitExcept>
</Location>
<Location ~ "/nagios/cgi-bin/">
Options ExecCGI
</Location>
<Location /nagios/cgi-bin/cmd.cgi>
Require valid-user
</Location>
<Location /nagios/cgi-bin/config.cgi>
Require valid-user
</Location>
<Location /apache-status>
SetHandler server-status
{% if vars['nagios_location'] == 'external' %}
Require ip 2600:2701:4000:5211:dead:beef:00fe:fed9
{% else %}
Require ip 10.16.163.10
{% endif %}
Require ip 127.0.0.1
Require ip ::1
</Location>
RewriteEngine on
RewriteRule ^/$ /nagios/ [R]
# Spiders-gone-wild
# These spiders may not follow robots.txt and will
# hit admin sections which consume large amounts of CPU
RewriteCond %{HTTP_USER_AGENT} "(Bytespider|ClaudeBot|Amazonbot|YandexBot|ChatGLM-Spider|GPTBot|Barkrowler|YisouSpider|MJ12bot)" [NC]
RewriteRule .* - [F,L]
Alias /nagios /usr/share/nagios/html/
<Directory "/usr/share/nagios/html">
Options None
</Directory>

View file

@ -1,5 +0,0 @@
# 'pgsql'
define command{
command_name check_pgsql
command_line $USER1$/check_pgsql -H $HOSTADDRESS$ -d $ARG1$ -p '{{nagios_db_user_password}}' --logname 'nagiosuser'
}

View file

@ -1,13 +0,0 @@
<?php
$cfg['cgi_config_file']='/etc/nagios/cgi.cfg'; // location of the CGI config file
$cfg['cgi_base_url']='/{{nagios_srcdir}}/cgi-bin/';
// FILE LOCATION DEFAULTS
$cfg['main_config_file']='/etc/nagios/nagios.cfg'; // default location of the main Nagios config file
$cfg['status_file']='/var/lib/nagios/status.dat'; // default location of Nagios status file
$cfg['state_retention_file']='/var/lib/nagios/retention.dat'; // default location of Nagios retention file
// utilities
require_once(dirname(__FILE__).'/includes/utils.inc.php');

Some files were not shown because too many files have changed in this diff Show more