Hej,

Dawno to powinno tu trafić :)
Przydatne do monitorowania macierzy mdadm'owych przez Nagios. 
Proste i skuteczne.

-- 
Pozdrawiam, Best regards, Mit freundlichen Grüßen,

Wojciech Błaszkowski
www.blaszkowski.com
GSM: +48 600 197 207
JID: [email protected]
#!/usr/bin/python
# (C) 2008 Arkadiusz Miskiewicz <[email protected]>
# Linux Software Raid monitoring for nagios

import re
import sys

NAGIOS_OK = 0
NAGIOS_WARNING = 1
NAGIOS_CRITICAL = 2
NAGIOS_UNKNOWN = 3

nagios_state = NAGIOS_UNKNOWN

try:
    f = open('/proc/mdstat' , 'r')
    d = f.read()
    f.close()
except IOError, e:
    print "Can't read RAID data: %s" % e
    sys.exit(NAGIOS_UNKNOWN)

re_md = re.compile(r'^(md\d+)\s+:\s+(\w+) (\w+) (.*?)$.*?\[(\w+)\]$', re.MULTILINE|re.IGNORECASE|re.DOTALL)
d_md = re_md.findall(d)

d_md.sort()

mdarr = []
for (md, lv_state, raid, disks, d_state)  in d_md:
    if lv_state != "active":
        nagios_state = NAGIOS_CRITICAL
    if d_state.find('_') >= 0:
        if nagios_state < NAGIOS_WARNING or nagios_state == NAGIOS_UNKNOWN:
            nagios_state = NAGIOS_WARNING
        disks = " (%s)" % disks
    else:
        disks = ""
    mdarr.append("%s [%s, %s, %s%s] " % (md, raid, lv_state, d_state, disks))

msg = "MD: " + " . ".join(mdarr)
print msg

# no failures were found
if nagios_state == NAGIOS_UNKNOWN:
    nagios_state = NAGIOS_OK

sys.exit(nagios_state)
# $Revision: 1.1 $, $Date: 2011/03/10 12:31:08 $
%define		plugin	check_md
Summary:	Nagios plugin for monitoring mdadm software RAID
Name:		nagios-plugin-%{plugin}
# revision from download page
Version:	1.0
Release:	1
License:	GPL v2
Group:		Networking
# written by Arkadiusz Miśkiewicz, [email protected]
Source0:	check_md
Requires:	nagios-core
Requires:	nagios-plugins-libs
BuildArch:	noarch
BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)

%define		plugindir	%{_prefix}/lib/nagios/plugins
%define		_sysconfdir	/etc/nagios/plugins

%description
Plugin for monitoring mdadm arrays. Simple and efficient.

%prep
%setup -qcT

install %{SOURCE0} %{plugin}

cat > nagios.cfg <<'EOF'
# Usage:
# %{plugin}

define service {
        use                     any-service
        name                    md-raid
        register                0

        max_check_attempts      2
        retry_check_interval    180
        normal_check_interval   720
        notification_interval   720

        service_description     linux md raid
        check_command           check_nrpe!check_md
}

EOF

%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{plugindir}}

install %{plugin} $RPM_BUILD_ROOT%{plugindir}/%{plugin}
cp -a nagios.cfg $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(644,root,root,755)
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg
%attr(755,root,root) %{plugindir}/%{plugin}

%define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
%changelog
* %{date} PLD Team <[email protected]>
All persons listed below can be reached at <cvs_login>@pld-linux.org

$Log: nagios-plugin-check_megaraid_sas.spec,v $


_______________________________________________
pld-devel-pl mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-devel-pl

Odpowiedź listem elektroniczym