Example #1
0
#
#

import logging as log
import re

from shared import __version__
from monitoring.nagios.plugin import NagiosPluginSNMP

logger = log.getLogger('plugin')


# The main procedure
progdesc = 'Check all PSU of Cisco and alert if one is not on.'

plugin = NagiosPluginSNMP(version=__version__, description=progdesc)

oids = {
    'psu_status': '1.3.6.1.4.1.9.9.117.1.1.2.1.2', # From CISCO-ENTITY-FRU-CONTROL-MIB
    'psu_descs': '1.3.6.1.2.1.47.1.1.1.1.2', # From ENTITY-MIB
}

desc = {
    1: 'offEnvOther',
    2: 'on',
    3: 'offAdmin',
    4: 'offDenied',
    5: 'offEnvPower',
    6: 'offEnvTemp',
    7: 'offEnvFan',
    8: 'failed',
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
#

import os, sys
from time import strftime, localtime, time

from shared import __version__
from monitoring.nagios.plugin import NagiosPluginSNMP

# The main procedure
progname = os.path.basename(sys.argv[0])
progdesc = 'Check config last change and last saved date time.'

plugin = NagiosPluginSNMP(version=__version__, description=progdesc)

oids = {
    'uptime': '1.3.6.1.2.1.1.3.0',
    'config_last_changed': '1.3.6.1.4.1.9.9.43.1.1.1.0',
    'config_last_saved': '1.3.6.1.4.1.9.9.43.1.1.2.0',
}

query = plugin.snmp.get(oids)

# Date calculations
delta_time_changed = abs(long(query['uptime'].value) - long(query['config_last_changed'].value)) / 100
delta_time_saved = abs(long(query['uptime'].value) - long(query['config_last_saved'].value)) / 100

config_last_changed_date = localtime(time() - delta_time_changed)
config_last_changed_date_str = strftime('%d/%m/%Y %H:%M', config_last_changed_date)
# Object:
#
################################################################################

import logging as log
import re
import datetime


from monitoring.nagios.plugin import NagiosPluginSNMP

logger = log.getLogger('plugin')

# The main procedure
desc_plug = "This plugin returns the isdnCallHistory table."
plugin = NagiosPluginSNMP(version=0.1, description=desc_plug)

oid = {
    'isdnCallHistoryType': '1.3.6.1.4.1.272.4.2.8.1.2',
    'isdnCallHistoryTime': '1.3.6.1.4.1.272.4.2.8.1.3',
    'isdnCallHistoryDuration': '1.3.6.1.4.1.272.4.2.8.1.4',
    'isdnCallHistoryRemoteNumber': '1.3.6.1.4.1.272.4.2.8.1.8',
}

call_type = {
    1: 'Incoming',
    2: 'Outgoing',
}
query = plugin.snmp.getnext(oid)

# Store temp data
Example #4
0
# Author:
# Object:
#
################################################################################

import logging as log
import re
import datetime

from monitoring.nagios.plugin import NagiosPluginSNMP

logger = log.getLogger('plugin')

# The main procedure
desc_plug = "This plugin returns the isdnCallHistory table."
plugin = NagiosPluginSNMP(version=0.1, description=desc_plug)

oid = {
    'isdnCallHistoryType': '1.3.6.1.4.1.272.4.2.8.1.2',
    'isdnCallHistoryTime': '1.3.6.1.4.1.272.4.2.8.1.3',
    'isdnCallHistoryDuration': '1.3.6.1.4.1.272.4.2.8.1.4',
    'isdnCallHistoryRemoteNumber': '1.3.6.1.4.1.272.4.2.8.1.8',
}

call_type = {
    1: 'Incoming',
    2: 'Outgoing',
}
query = plugin.snmp.getnext(oid)

# Store temp data
Example #5
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
#

import os, sys
from time import strftime, localtime, time

from shared import __version__
from monitoring.nagios.plugin import NagiosPluginSNMP

# The main procedure
progname = os.path.basename(sys.argv[0])
progdesc = 'Check config last change and last saved date time.'

plugin = NagiosPluginSNMP(version=__version__, description=progdesc)

oids = {
    'uptime': '1.3.6.1.2.1.1.3.0',
    'config_last_changed': '1.3.6.1.4.1.9.9.43.1.1.1.0',
    'config_last_saved': '1.3.6.1.4.1.9.9.43.1.1.2.0',
}

query = plugin.snmp.get(oids)

# Date calculations
delta_time_changed = abs(
    long(query['uptime'].value) -
    long(query['config_last_changed'].value)) / 100
delta_time_saved = abs(
    long(query['uptime'].value) - long(query['config_last_saved'].value)) / 100
Example #6
0
#
#

import logging as log
import os, sys

from shared import __version__
from monitoring.nagios.plugin import NagiosPluginSNMP

logger = log.getLogger("plugin")

# The main procedure
progname = os.path.basename(sys.argv[0])
progdesc = "Check hardware (sensors, fans, power) of Cisco devices."

plugin = NagiosPluginSNMP(version=__version__, description=progdesc)

oids = {
    # For devices supporting CISCO-ENTITY-SENSOR-MIB
    "sensor_names": "1.3.6.1.2.1.47.1.1.1.1.7",  # from ENTITY-MIB
    "sensors_status": "1.3.6.1.4.1.9.9.91.1.1.1.1.5",  # from CISCO-ENTITY-SENSOR-MIB
    # For devices supporting CISCO-ENVMON-MIB
    "envmon_fan_status": "1.3.6.1.4.1.9.9.13.1.4.1.3",  # from CISCO-ENVMON-MIB
    "envmon_power_status": "1.3.6.1.4.1.9.9.13.1.5.1.3",  # from CISCO-ENVMON-MIB
}

# Store all sensors data
sensor_data = []

# Query using CISCO-ENTITY-SENSOR-MIB be default, fallback to CISCO-ENVMON-MIB
query = plugin.snmp.getnext(oids)
Example #7
0
#
#

import logging as log
import os, sys

from shared import __version__
from monitoring.nagios.plugin import NagiosPluginSNMP

logger = log.getLogger('plugin')

# The main procedure
progname = os.path.basename(sys.argv[0])
progdesc = 'Check hardware (sensors, fans, power) of Cisco devices.'

plugin = NagiosPluginSNMP(version=__version__, description=progdesc)

oids = {
    # For devices supporting CISCO-ENTITY-SENSOR-MIB
    'sensor_names': '1.3.6.1.2.1.47.1.1.1.1.7',  # from ENTITY-MIB
    'sensors_status':
    '1.3.6.1.4.1.9.9.91.1.1.1.1.5',  # from CISCO-ENTITY-SENSOR-MIB
    # For devices supporting CISCO-ENVMON-MIB
    'envmon_fan_status': '1.3.6.1.4.1.9.9.13.1.4.1.3',  # from CISCO-ENVMON-MIB
    'envmon_power_status':
    '1.3.6.1.4.1.9.9.13.1.5.1.3',  # from CISCO-ENVMON-MIB
}

# Store all sensors data
sensor_data = []
Example #8
0
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# TODO: Convert to unittest.

import sys

sys.path.insert(0, '..')

from monitoring.nagios.plugin import NagiosPluginSNMP

plugin = NagiosPluginSNMP(version='1.0', description='Test SNMPQuery class')

results = plugin.snmp.get({
    'name': '1.3.6.1.2.1.1.5.0',
})
print results