From 9b2009c2c8209ad5902a14f2a59acabd4f660e28 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Thu, 17 Mar 2011 10:10:05 +0100 Subject: [PATCH] *: Add GPL header, check_*: catch import error Signed-off-by: Sven Velt --- check_apaches.py | 42 +++++++++++++++++++++++++++++++++++++++-- check_naf.py | 19 +++++++++++++++++-- check_nagiostats.py | 41 ++++++++++++++++++++++++++++++++++++++-- check_netconnections.py | 42 +++++++++++++++++++++++++++++++++++++++-- check_sensors.py | 40 +++++++++++++++++++++++++++++++++++++-- monitoringplugin.py | 22 +++++++++++++++++++++ 6 files changed, 196 insertions(+), 10 deletions(-) diff --git a/check_apaches.py b/check_apaches.py index 39bbc13..8878f91 100755 --- a/check_apaches.py +++ b/check_apaches.py @@ -1,10 +1,48 @@ -#!/usr/bin/python +#!/usr/bin/env python +# -*- encoding: utf-8 -*- -from monitoringplugin import MonitoringPlugin +##################################################################### +# (c) 2007-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# sv@teamix.net # +# # +# This file is part of "team(ix) Monitoring Plugins" # +# URL: http://oss.teamix.org/projects/monitoringplugins/ # +# # +# This file is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 2 of the License, # +# or (at your option) any later version. # +# # +# This file is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this file. If not, see . # +##################################################################### +import os import re +import sys import urllib2 +try: + from monitoringplugin import MonitoringPlugin +except ImportError: + print '==========================' + print 'AIKS! Python import error!' + print '==========================\n' + print 'Could not find "monitoringplugin.py"!\n' + print 'Did you download "%s"' % os.path.basename(sys.argv[0]) + print 'without "monitoringplugin.py"?\n' + print 'Please go back to' + print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' + print 'or even better:' + print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' + sys.exit(127) + + plugin = MonitoringPlugin(pluginname='check_apaches', tagforstatusline='APACHE', description='Check Apache workers', version='0.1') plugin.add_cmdlineoption('-H', '', 'host', 'Hostname/IP to check', default='localhost') diff --git a/check_naf.py b/check_naf.py index 8afd3de..56f0213 100755 --- a/check_naf.py +++ b/check_naf.py @@ -2,7 +2,7 @@ # -*- encoding: utf-8 -*- ##################################################################### -# (c) 2006-2010 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# (c) 2006-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # # sv@teamix.net # # # # This file is part of check_naf (FKA check_netappfiler) # @@ -21,9 +21,24 @@ # along with check_naf. If not, see . # ##################################################################### +import os import sys -from monitoringplugin import SNMPMonitoringPlugin +try: + from monitoringplugin import SNMPMonitoringPlugin +except ImportError: + print '==========================' + print 'AIKS! Python import error!' + print '==========================\n' + print 'Could not find "monitoringplugin.py"!\n' + print 'Did you download "%s"' % os.path.basename(sys.argv[0]) + print 'without "monitoringplugin.py"?\n' + print 'Please go back to' + print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' + print 'or even better:' + print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' + sys.exit(127) + class CheckNAF(SNMPMonitoringPlugin): OID = { diff --git a/check_nagiostats.py b/check_nagiostats.py index 7d78163..a57579e 100755 --- a/check_nagiostats.py +++ b/check_nagiostats.py @@ -1,10 +1,47 @@ -#!/usr/bin/python +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +##################################################################### +# (c) 2005-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# sv@teamix.net # +# # +# This file is part of "team(ix) Monitoring Plugins" # +# URL: http://oss.teamix.org/projects/monitoringplugins/ # +# # +# This file is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 2 of the License, # +# or (at your option) any later version. # +# # +# This file is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this file. If not, see . # +##################################################################### import os import shlex import subprocess +import sys + +try: + from monitoringplugin import MonitoringPlugin +except ImportError: + print '==========================' + print 'AIKS! Python import error!' + print '==========================\n' + print 'Could not find "monitoringplugin.py"!\n' + print 'Did you download "%s"' % os.path.basename(sys.argv[0]) + print 'without "monitoringplugin.py"?\n' + print 'Please go back to' + print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' + print 'or even better:' + print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' + sys.exit(127) -from monitoringplugin import MonitoringPlugin plugin = MonitoringPlugin(pluginname='check_nagiostats', tagforstatusline='NAGIOSTATS', description='Check Nagios statistics', version='0.1') diff --git a/check_netconnections.py b/check_netconnections.py index a5b00ad..8de5d5d 100755 --- a/check_netconnections.py +++ b/check_netconnections.py @@ -1,8 +1,46 @@ -#!/usr/bin/python +#!/usr/bin/env python +# -*- encoding: utf-8 -*- -from monitoringplugin import MonitoringPlugin +##################################################################### +# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# sv@teamix.net # +# # +# This file is part of "team(ix) Monitoring Plugins" # +# URL: http://oss.teamix.org/projects/monitoringplugins/ # +# # +# This file is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 2 of the License, # +# or (at your option) any later version. # +# # +# This file is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this file. If not, see . # +##################################################################### +import os import re +import sys + +try: + from monitoringplugin import MonitoringPlugin +except ImportError: + print '==========================' + print 'AIKS! Python import error!' + print '==========================\n' + print 'Could not find "monitoringplugin.py"!\n' + print 'Did you download "%s"' % os.path.basename(sys.argv[0]) + print 'without "monitoringplugin.py"?\n' + print 'Please go back to' + print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' + print 'or even better:' + print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' + sys.exit(127) + plugin = MonitoringPlugin(pluginname='check_netconnections', tagforstatusline='NETCONNS', description='Count network connections', version='0.1') diff --git a/check_sensors.py b/check_sensors.py index a75317e..e7e4283 100755 --- a/check_sensors.py +++ b/check_sensors.py @@ -1,12 +1,48 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- encoding: utf-8 -*- -from monitoringplugin import MonitoringPlugin +##################################################################### +# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# sv@teamix.net # +# # +# This file is part of "team(ix) Monitoring Plugins" # +# URL: http://oss.teamix.org/projects/monitoringplugins/ # +# # +# This file is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 2 of the License, # +# or (at your option) any later version. # +# # +# This file is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this file. If not, see . # +##################################################################### import datetime import time import os import re +import sys + +try: + from monitoringplugin import MonitoringPlugin +except ImportError: + print '==========================' + print 'AIKS! Python import error!' + print '==========================\n' + print 'Could not find "monitoringplugin.py"!\n' + print 'Did you download "%s"' % os.path.basename(sys.argv[0]) + print 'without "monitoringplugin.py"?\n' + print 'Please go back to' + print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' + print 'or even better:' + print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' + sys.exit(127) + plugin = MonitoringPlugin(pluginname='check_sensors', tagforstatusline='Sensors', description='Check environment sensors', version='0.2') diff --git a/monitoringplugin.py b/monitoringplugin.py index c56fc5e..f37b1f3 100644 --- a/monitoringplugin.py +++ b/monitoringplugin.py @@ -1,5 +1,27 @@ +#!/usr/bin/env python # -*- encoding: utf-8 -*- +##################################################################### +# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany # +# sv@teamix.net # +# # +# This file is part of "team(ix) Monitoring Plugins" # +# URL: http://oss.teamix.org/projects/monitoringplugins/ # +# # +# This file is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published # +# by the Free Software Foundation, either version 2 of the License, # +# or (at your option) any later version. # +# # +# This file is distributed in the hope that it will be useful, but # +# WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this file. If not, see . # +##################################################################### + __version__ = '0.0.100802' __all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']