mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-24 11:23:47 +01:00
Merge branch 'master' of github.com:opinkerfi/nagios-plugins
This commit is contained in:
commit
4a4794ea0e
49
check_hpasm/nagios-okplugin-check_hpasm.spec
Normal file
49
check_hpasm/nagios-okplugin-check_hpasm.spec
Normal file
@ -0,0 +1,49 @@
|
||||
%define debug_package %{nil}
|
||||
|
||||
Summary: A Nagios plugin to check HP Hardware Status
|
||||
Name: nagios-okplugin-check_hpasm
|
||||
Version: 4.1.2
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
URL: http://opensource.is/trac/wiki/check_hpasm
|
||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_hpasm/releases/nagios-okplugin-check_hpasm-%{version}.tar.gz
|
||||
Requires: nagios-okconfig-nrpe
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Packager: Pall Sigurdsson <palli@opensource.is>
|
||||
BuildArch: noarch
|
||||
|
||||
|
||||
|
||||
%description
|
||||
A Nagios plugin to check HP Hardware Status
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" sudoers.d/check_hpasm
|
||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_hpasm.cfg
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
install -D -p -m 0755 check_hpasm %{buildroot}%{_libdir}/nagios/plugins/check_hpasm
|
||||
install -D -p -m 0440 sudoers.d/check_hpasm %{buildroot}/etc/sudoers.d/check_hpasm
|
||||
install -D -p -m 0644 nrpe.d/check_hpasm.cfg %{buildroot}/etc/nrpe.d/check_hpasm.cfg
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
#%doc README LICENSE
|
||||
#%{_libdir}/nagios/plugins/*
|
||||
%{_libdir}/nagios/plugins/check_hpasm
|
||||
/etc/sudoers.d/check_hpasm
|
||||
/etc/nrpe.d/check_hpasm.cfg
|
||||
|
||||
%changelog
|
||||
* Tue Jun 4 2013 Pall Sigurdsson <palli@opensource.is> 4.1.2-1
|
||||
- Initial packaging
|
3
check_hpasm/nrpe.d/check_hpasm.cfg
Normal file
3
check_hpasm/nrpe.d/check_hpasm.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
command[check_updates]=sudo /usr/lib/nagios/plugins/check_hpasm
|
2
check_hpasm/sudoers.d/check_hpasm
Normal file
2
check_hpasm/sudoers.d/check_hpasm
Normal file
@ -0,0 +1,2 @@
|
||||
Defaults:nrpe !requiretty
|
||||
nrpe ALL = (root) NOPASSWD: /usr/lib/nagios/plugins/check_hpasm
|
@ -18,7 +18,7 @@ helper.parse_arguments()
|
||||
|
||||
username = helper.options.username
|
||||
password = helper.options.password
|
||||
tns = helper.options.database
|
||||
tns = helper.options.tns
|
||||
query = helper.options.query
|
||||
|
||||
enable_debugging = helper.options.verbose
|
||||
@ -34,21 +34,25 @@ if not password:
|
||||
helper.parser.error('--password is required')
|
||||
if not tns:
|
||||
helper.parser.error('--tns is required')
|
||||
if not oracle_home is None:
|
||||
#if not oracle_home is None:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Actual coding logic starts
|
||||
|
||||
conn = cx_Oracle.connect(username, password, database)
|
||||
conn = cx_Oracle.connect(username, password, tns)
|
||||
debug("connecting to host")
|
||||
cur = conn.cursor()
|
||||
debug("Executing sql query: %s" % query)
|
||||
cur.execute(query)
|
||||
|
||||
status,text = None,None
|
||||
problem_items = 0
|
||||
total_items = 0
|
||||
for row in cur:
|
||||
total_items += 1
|
||||
debug(row)
|
||||
if len(row) > 0:
|
||||
status = row[0]
|
||||
@ -61,16 +65,18 @@ for row in cur:
|
||||
if status not in pynag.Plugins.state_text:
|
||||
helper.add_summary("Invalid status: %s" % status)
|
||||
status = pynag.Plugins.unknown
|
||||
if status > 0:
|
||||
problem_items += 1
|
||||
helper.add_summary(text)
|
||||
|
||||
helper.status(status)
|
||||
helper.add_long_output("%s: %s" % (pynag.Plugins.state_text.get(status,'unknown'), text) )
|
||||
|
||||
|
||||
if total_items == 0:
|
||||
helper.add_summary("SQL Query returned 0 rows")
|
||||
helper.status(pynag.Plugins.unknown)
|
||||
if not helper.get_summary():
|
||||
if not text:
|
||||
helper.add_summary("Hey! Af hverju er enginn texti?")
|
||||
else:
|
||||
helper.add_summary(text)
|
||||
helper.add_summary("%s items checked. %s problems" % (total_items, problem_items))
|
||||
|
||||
helper.check_all_metrics()
|
||||
helper.exit()
|
||||
|
Loading…
Reference in New Issue
Block a user