]> git.pld-linux.org Git - packages/monitoring-plugin-check_mysql-heartbeat.git/commitdiff
- initial. issue 46714
authorElan Ruusamäe <glen@delfi.ee>
Sun, 9 Oct 2011 22:17:08 +0000 (22:17 +0000)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 9 Oct 2011 22:17:08 +0000 (22:17 +0000)
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 [new file with mode: 0644]
check_mysql-heartbeat.sh [new file with mode: 0755]
nagios-plugin-check_mysql-heartbeat.spec [new file with mode: 0644]

diff --git a/check_mysql-heartbeat.cfg b/check_mysql-heartbeat.cfg
new file mode 100644 (file)
index 0000000..fd9755a
--- /dev/null
@@ -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 (executable)
index 0000000..378f5b0
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+# License: GPL v2
+# Author: Elan Ruusamäe <glen@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"
diff --git a/nagios-plugin-check_mysql-heartbeat.spec b/nagios-plugin-check_mysql-heartbeat.spec
new file mode 100644 (file)
index 0000000..d0116c6
--- /dev/null
@@ -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}
This page took 0.036656 seconds and 4 git commands to generate.