[packages/monitoring-plugin-check_mysql-heartbeat: 1/10] - initial. issue 46714

glen glen at pld-linux.org
Tue Mar 22 12:32:26 CET 2016


commit 64e40e56bdcfcec67ecf6e20084bfd3e90789517
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Oct 9 22:17:08 2011 +0000

    - initial. issue 46714
    
    Changed files:
        check_mysql-heartbeat.cfg -> 1.1
        check_mysql-heartbeat.sh -> 1.1
        nagios-plugin-check_mysql-heartbeat.spec -> 1.1

 check_mysql-heartbeat.cfg                | 13 +++++
 check_mysql-heartbeat.sh                 | 88 ++++++++++++++++++++++++++++++++
 nagios-plugin-check_mysql-heartbeat.spec | 71 ++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
---
diff --git a/nagios-plugin-check_mysql-heartbeat.spec b/nagios-plugin-check_mysql-heartbeat.spec
new file mode 100644
index 0000000..d0116c6
--- /dev/null
+++ b/nagios-plugin-check_mysql-heartbeat.spec
@@ -0,0 +1,71 @@
+%define		plugin	check_mysql-heartbeat
+%define		php_min_version 5.0.0
+%include	/usr/lib/rpm/macros.php
+Summary:	Nagios plugin to check MySQL heartbeat
+Name:		nagios-plugin-%{plugin}
+Version:	1.0
+Release:	0.1
+License:	GPL v2
+Group:		Networking
+BuildRequires:	rpm-php-pearprov >= 4.4.2-11
+Requires:	nagios-common
+Requires:	nagios-plugins-libs
+BuildArch:	noarch
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define		_sysconfdir	/etc/nagios/plugins
+%define		plugindir	%{_prefix}/lib/nagios/plugins
+
+%define		_cvsroot	:ext:cvs.delfi.ee:/usr/local/cvs
+%define		_cvsmodule	nagios/plugins
+
+%description
+Nagios plugin to check MySQL heartbeat with maatkit or percona-toolkit.
+
+%prep
+# check early if build is ok to be performed
+%if %{!?debug:1}%{?debug:0} && %{!?_cvstag:1}%{?_cvstag:0} && %([[ %{release} = *.* ]] && echo 0 || echo 1)
+# break if spec is not commited
+cd %{_specdir}
+if [ "$(cvs status %{name}.spec | awk '/Status:/{print $NF}')" != "Up-to-date" ]; then
+	: "Integer build not allowed: %{name}.spec is not up-to-date with CVS"
+	exit 1
+fi
+cd -
+%endif
+%setup -qTc
+cd ..
+cvs -d %{_cvsroot} co -d %{name}-%{version} %{_cvsmodule}/%{plugin}
+cd -
+cvs up %{plugin}.cfg
+
+%build
+# skip tagging if we checkouted from tag or have debug enabled
+# also make make tag only if we have integer release
+%if %{!?debug:1}%{?debug:0} && %{!?_cvstag:1}%{?_cvstag:0} && %([[ %{release} = *.* ]] && echo 0 || echo 1)
+# do tagging by version
+tag=%{name}-%(echo %{version} | tr . _)-%(echo %{release} | tr . _)
+
+cd %{_specdir}
+if [ $(cvs status -v %{name}.spec | grep -Ec "$tag[[:space:]]") != 0 ]; then
+	: "Tag $tag already exists"
+	exit 1
+fi
+cvs tag $tag %{name}.spec
+cd -
+cvs tag $tag
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}}
+install -p %{plugin} $RPM_BUILD_ROOT%{plugindir}
+cp -p %{plugin}.cfg $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg
+%attr(755,root,root) %{plugindir}/%{plugin}
diff --git a/check_mysql-heartbeat.cfg b/check_mysql-heartbeat.cfg
new file mode 100644
index 0000000..fd9755a
--- /dev/null
+++ b/check_mysql-heartbeat.cfg
@@ -0,0 +1,13 @@
+define command {
+	command_name    check_mysql-heartbeat
+	command_line    /usr/lib/nagios/plugins/check_mysql-heartbeat -H $HOSTADDRESS$ -D nagios --username $USER3$ --password $USER4$ $ARG1$
+}
+
+define service {
+	use                     generic-service
+	name                    check_mysql-heartbeat
+	service_description     check_mysql-heartbeat
+	register                0
+
+	check_command           check_mysql_health
+}
diff --git a/check_mysql-heartbeat.sh b/check_mysql-heartbeat.sh
new file mode 100755
index 0000000..378f5b0
--- /dev/null
+++ b/check_mysql-heartbeat.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# License: GPL v2
+# Author: Elan Ruusamäe <glen at delfi.ee>
+#
+# Usage: check_mysql-heartbeat
+#
+
+PROGRAM=${0##*/}
+REVISION=$(echo '$Revision$' | sed -e 's/[^0-9.]//g')
+PROGPATH=${0%/*}
+. $PROGPATH/utils.sh
+
+heartbeat=mk-heartbeat
+hostname=
+port=
+username=
+password=
+database=
+
+die() {
+	eval local rc=\$STATE_$1
+	[ "$rc" ] || rc=$STATE_UNKNOWN
+	echo "$2"
+	exit $rc
+}
+
+usage() {
+	cat >&2 <<EOF
+Usage: check_mysql-heartbeat
+
+    --mk | --maatkit
+       Uses maatkit: mk-heartbeat
+    --pt | --percona-toolkit
+       Uses percona-toolkit: pt-hearbeat
+EOF
+}
+
+## Start of main program ##
+while [ $# -gt 0 ]; do
+	case "$1" in
+	-h|--help)
+		usage
+		exit 0
+		;;
+	-V|--version)
+		echo $PROGRAM $REVISION
+		exit 0
+		;;
+	--mk|--maatkit)
+		heartbeat=mk-heartbeat
+		;;
+	--pt|--percona-toolkit)
+		heartbeat=mk-heartbeat
+		;;
+	-H|--host)
+		shift
+		hostname=$1
+		;;
+	-P|--port)
+		shift
+		port=$1
+		;;
+	-u|--username)
+		shift
+		username=$1
+		;;
+	-p|--password)
+		shift
+		password=$1
+		;;
+	-D|--database)
+		shift
+		database=$1
+		;;
+	esac
+	shift
+done
+
+if [ -z "$hostname" ]; then
+	die UNKNOWN "No hostname given"
+fi
+
+out=$($heartbeat ${database:+-D $database} --check -h $hostname ${username:+-u $username} ${password:+-p $password} 2>&1)
+rc=$?
+if [ "$rc" != 0 ]; then
+	die UNKNOWN "$out"
+fi
+die OK "OK $heartbeat on $hostname @$out"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/monitoring-plugin-check_mysql-heartbeat.git/commitdiff/c97836d2e3bccf7d77e278a624bc4dd433f544f9



More information about the pld-cvs-commit mailing list