Skip to content

Commit 2dbf7fa

Browse files
committed
Add Percona MySQL plugins
1 parent 98f162f commit 2dbf7fa

14 files changed

+2955
-9
lines changed

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,66 @@ An example Vagrant project has been included to get you started right away.
8686
<td>Michael Chapman</td>
8787
<td><a href="https://github.com/anchor/nagios-plugin-drbd">upstream</a></td>
8888
</tr>
89+
<tr>
90+
<td>pmp-check-lvm-snapshots</td>
91+
<td><a href="http://www.percona.com/">Percona</a></td>
92+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
93+
</tr>
94+
<tr>
95+
<td>pmp-check-mysql-deadlocks</td>
96+
<td><a href="http://www.percona.com/">Percona</a></td>
97+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
98+
</tr>
99+
<tr>
100+
<td>pmp-check-mysql-deleted-files</td>
101+
<td><a href="http://www.percona.com/">Percona</a></td>
102+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
103+
</tr>
104+
<tr>
105+
<td>pmp-check-mysql-file-privs</td>
106+
<td><a href="http://www.percona.com/">Percona</a></td>
107+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
108+
</tr>
109+
<tr>
110+
<td>pmp-check-mysql-innodb</td>
111+
<td><a href="http://www.percona.com/">Percona</a></td>
112+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
113+
</tr>
114+
<tr>
115+
<td>pmp-check-mysql-pidfile</td>
116+
<td><a href="http://www.percona.com/">Percona</a></td>
117+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
118+
</tr>
119+
<tr>
120+
<td>pmp-check-mysql-processlist</td>
121+
<td><a href="http://www.percona.com/">Percona</a></td>
122+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
123+
</tr>
124+
<tr>
125+
<td>pmp-check-mysql-replication-delay</td>
126+
<td><a href="http://www.percona.com/">Percona</a></td>
127+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
128+
</tr>
129+
<tr>
130+
<td>pmp-check-mysql-replication-running</td>
131+
<td><a href="http://www.percona.com/">Percona</a></td>
132+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
133+
</tr>
134+
<tr>
135+
<td>pmp-check-mysql-status</td>
136+
<td><a href="http://www.percona.com/">Percona</a></td>
137+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
138+
</tr>
139+
<tr>
140+
<td>pmp-check-pt-table-checksum</td>
141+
<td><a href="http://www.percona.com/">Percona</a></td>
142+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
143+
</tr>
144+
<tr>
145+
<td>pmp-check-unix-memory</td>
146+
<td><a href="http://www.percona.com/">Percona</a></td>
147+
<td><a href="http://www.percona.com/software/percona-monitoring-plugins/">upstream</a></td>
148+
</tr>
89149
</table>
90150

91151
### Contributions

build.txt

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
# Nagios plugin version iteration
2-
check_apache-auto.pl 1.0 1
3-
check_bacula 0.0.4 1
4-
check_drbd 3e0b548f55 1
5-
check_linux-procstat.pl 0.4 1
6-
check_linux-stats.pl 1.1 1
7-
check_mem.pl 1.8 1
8-
check_mysqld.pl 0.93 1
9-
check_puppet.rb 70ba5a5155 1
1+
# Nagios plugin version iteration
2+
check_apache-auto.pl 1.0 1
3+
check_bacula 0.0.4 1
4+
check_drbd 3e0b548f55 1
5+
check_linux-procstat.pl 0.4 1
6+
check_linux-stats.pl 1.1 1
7+
check_mem.pl 1.8 1
8+
check_mysqld.pl 0.93 1
9+
check_puppet.rb 70ba5a5155 1
10+
pmp-check-lvm-snapshots 0.9.0 1
11+
pmp-check-mysql-deadlocks 0.9.0 1
12+
pmp-check-mysql-deleted-files 0.9.0 1
13+
pmp-check-mysql-file-privs 0.9.0 1
14+
pmp-check-mysql-innodb 0.9.0 1
15+
pmp-check-mysql-pidfile 0.9.0 1
16+
pmp-check-mysql-processlist 0.9.0 1
17+
pmp-check-mysql-replication-delay 0.9.0 1
18+
pmp-check-mysql-replication-running 0.9.0 1
19+
pmp-check-mysql-status 0.9.0 1
20+
pmp-check-pt-table-checksum 0.9.0 1
21+
pmp-check-unix-memory 0.9.0 1

pmp-check-lvm-snapshots

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#!/bin/sh
2+
3+
# ########################################################################
4+
# This program is part of Percona Monitoring Plugins
5+
# License: GPL License (see COPYING)
6+
# Authors:
7+
# Baron Schwartz
8+
# ########################################################################
9+
10+
# ########################################################################
11+
# Redirect STDERR to STDOUT; Nagios doesn't handle STDERR.
12+
# ########################################################################
13+
exec 2>&1
14+
15+
# ########################################################################
16+
# Set up constants, etc.
17+
# ########################################################################
18+
STATE_OK=0
19+
STATE_WARNING=1
20+
STATE_CRITICAL=2
21+
STATE_UNKNOWN=3
22+
STATE_DEPENDENT=4
23+
EXITSTATUS=$STATE_UNKNOWN
24+
25+
# ########################################################################
26+
# Print the name and fullness of every LVM snapshot that is open and
27+
# nearly full. The input is the file with 'lvs', and the allowable fullness.
28+
# In many cases lvs will report "File descriptor %d (...) leaked" and we ignore
29+
# this, as it's only a warning that usually happens from a shell.
30+
# ########################################################################
31+
check_lvm_snapshot_fullness() {
32+
local FILE="$1"
33+
local FULL="$2"
34+
awk -v full="$FULL" '
35+
$1 != "LV" && $1 != "File" && $6 !~ /[^0-9.]/ && $6 > full {
36+
print $2 "/" $1 "[" $5 "]=" $6 "%"
37+
}' "${FILE}"
38+
}
39+
40+
# ########################################################################
41+
# Run the program.
42+
# ########################################################################
43+
main() {
44+
45+
# Get options
46+
for o; do
47+
case "${o}" in
48+
-w) shift; OPT_WARN="${1}"; shift; ;;
49+
-c) shift; OPT_CRIT="${1}"; shift; ;;
50+
--version) grep -A2 '^=head1 VERSION' "$0" | tail -n1; exit 0 ;;
51+
--help) perl -00 -ne 'm/^ Usage:/ && print' "$0"; exit 0 ;;
52+
-*) echo "Unknown option ${o}. Try --help."; exit 1; ;;
53+
esac
54+
done
55+
OPT_WARN=${OPT_WARN:-90}
56+
OPT_CRIT=${OPT_CRIT:-95}
57+
58+
local NOTE="OK no full LVM snapshot volumes"
59+
local TEMP=$(mktemp "/tmp/${0##*/}.XXXX") || exit $?
60+
trap 'rm -rf "${TEMP}" >/dev/null 2>&1' EXIT
61+
62+
# The lvs command is usually in /usr/sbin. But if it's run as a non-root
63+
# user, it will print out "WARNING: Running as a non-root user. Functionality
64+
# may be unavailable." and exit with success anyway. So we have to detect
65+
# this and make the plugin exit UNKNOWN in that case.
66+
PATH="$PATH:/usr/sbin:/sbin"
67+
lvs > "${TEMP}" 2>&1 || exit $?
68+
69+
if grep 'WARNING: Running as a non-root user' "${TEMP}" >/dev/null 2>&1; then
70+
NOTE="UNK You must execute lvs with root privileges"
71+
EXITSTATUS=$STATE_UNKNOWN
72+
else
73+
local VOLS=$(check_lvm_snapshot_fullness "${TEMP}" "${OPT_CRIT}")
74+
if [ "${VOLS}" ]; then
75+
NOTE="CRIT LVM snapshot volumes over ${FULL}% full: ${VOLS}"
76+
EXITSTATUS=$STATE_CRITICAL
77+
else
78+
VOLS=$(check_lvm_snapshot_fullness "${TEMP}" "${OPT_WARN}")
79+
if [ "${VOLS}" ]; then
80+
NOTE="WARN LVM snapshot volumes over ${FULL}% full: ${VOLS}"
81+
EXITSTATUS=$STATE_WARNING
82+
fi
83+
fi
84+
fi
85+
86+
echo $NOTE
87+
exit $EXITSTATUS
88+
}
89+
90+
# ########################################################################
91+
# Execute the program if it was not included from another file.
92+
# This makes it possible to include without executing, and thus test.
93+
# ########################################################################
94+
if [ "${0##*/}" = "pmp-check-lvm-snapshots" ] \
95+
|| [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then
96+
main "$@"
97+
fi
98+
99+
# ############################################################################
100+
# Documentation
101+
# ############################################################################
102+
: <<'DOCUMENTATION'
103+
=pod
104+
105+
=head1 NAME
106+
107+
pmp-check-lvm-snapshots - Alert when LVM snapshots are running out of copy-on-write space.
108+
109+
=head1 SYNOPSIS
110+
111+
Usage: pmp-check-lvm-snapshots [OPTIONS]
112+
Options:
113+
-c CRIT Critical threshold; default 95%.
114+
-w WARN Warning threshold; default 90%.
115+
--help Print help and exit.
116+
--version Print version and exit.
117+
Options must be given as --option value, not --option=value or -Ovalue.
118+
Use perldoc to read embedded documentation with more details.
119+
120+
=head1 DESCRIPTION
121+
122+
This Nagios plugin looks at the output of the 'lvs' command to find LVM snapshot volumes
123+
that are beginning to run out of copy-on-write space. If a snapshot fills up its
124+
copy-on-write space, it will fail. This is also a useful way to detect whether
125+
some process, such as a backup, failed to release a snapshot volume after
126+
finishing with it.
127+
128+
=head1 PRIVILEGES
129+
130+
This plugin does not access MySQL.
131+
132+
This plugin executes the following UNIX commands that may need special privileges:
133+
134+
=over
135+
136+
=item *
137+
138+
lvs
139+
140+
=back
141+
142+
=head1 COPYRIGHT, LICENSE, AND WARRANTY
143+
144+
This program is copyright 2012 Baron Schwartz, 2012 Percona Inc.
145+
Feedback and improvements are welcome.
146+
147+
THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
148+
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
149+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
150+
151+
This program is free software; you can redistribute it and/or modify it under
152+
the terms of the GNU General Public License as published by the Free Software
153+
Foundation, version 2. You should have received a copy of the GNU General
154+
Public License along with this program; if not, write to the Free Software
155+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
156+
157+
=head1 VERSION
158+
159+
Percona Monitoring Plugins pmp-check-lvm-snapshots 0.9.0
160+
161+
=cut
162+
163+
DOCUMENTATION

0 commit comments

Comments
 (0)