Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit d727ec79 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent c1062eb8
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2016-08-01
#
# monitor Juniper Networks led state
#
# sample snmpwalk
# .1.3.6.1.4.1.2636.3.1.10.1.7.3.1.1.0.0 = STRING: " chassis alarm LED"
# .1.3.6.1.4.1.2636.3.1.10.1.7.3.2.1.1.0 = STRING: " Power Supply 0 LED"
# .1.3.6.1.4.1.2636.3.1.10.1.7.3.2.1.2.0 = STRING: " Power Supply 1 LED"
# .1.3.6.1.4.1.2636.3.1.10.1.9.3.1.1.0.0 = INTEGER: 6
# .1.3.6.1.4.1.2636.3.1.10.1.9.3.2.1.1.0 = INTEGER: 2
# .1.3.6.1.4.1.2636.3.1.10.1.9.3.2.1.2.0 = INTEGER: 2
#
# sample string_table
# [[' chassis alarm LED', '6'], [' Power Supply 0 LED', '2'], [' Power Supply 1 LED', '2']]
#
# sample section
# {'Chassis alarm': '6', 'Power Supply 0': '2', 'Power Supply 1': '2'}
#
# ToDo: create WATO for monitoring levels for each LED state
#
from typing import Optional, Dict
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
Result,
State,
SNMPTree,
startswith,
)
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
_juniper_led_alarm_ordered = {
'1': (0, 'OK, online as an active primary (blue)'), # blue
'2': (0, 'OK, good, normally working (green)'), # green
'3': (1, 'alarm, offline, not running (minor) (amber)'), # amber
'4': (1, 'alarm, warning, marginally working (minor) (yellow)'), # yellow
'5': (2, 'alert, failed, not working (major) (red)'), # red
'6': (3, 'unknown or unavailable'), # other
'7': (3, 'off'),
'8': (3, 'blinking blue'),
'9': (3, 'blinking green'),
'10': (3, 'blinking amber'),
'11': (3, 'blinking yellow'),
'12': (3, 'blinking red'),
}
def parse_juniper_led(string_table: StringTable) -> Optional[Dict[str, str]]:
juniper_leds = {}
for led_description, led_state in string_table:
# remove "LED" from description
led_description = led_description.replace('LED', '').strip(' ')
# changing the first letter into upper case
led_description = led_description[0].upper() + led_description[1:]
juniper_leds[led_description] = led_state
return juniper_leds
def discovery_juniper_led(section: Dict[str, str]) -> DiscoveryResult:
for led in section.keys():
yield Service(item=led)
def check_juniper_led(item, params, section: Dict[str, str]) -> CheckResult:
led_state = section.get(item)
if led_state:
state, state_readable = _juniper_led_alarm_ordered.get(led_state, (3, f'unhandled alarm type {led_state}'))
yield Result(state=State(state), summary=state_readable)
register.snmp_section(
name='juniper_led',
parse_function=parse_juniper_led,
supersedes=['juniper_alarm'],
fetch=
SNMPTree(
base='.1.3.6.1.4.1.2636.3.1.10.1', # JUNIPER-MIB::jnxLEDEntry
oids=[
'7', # jnxLEDDescr
'9', # jnxLEDStateOrdered
]
),
detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2636.1.1.1'),
)
register.check_plugin(
name='juniper_led',
service_name='Alarm LED %s',
discovery_function=discovery_juniper_led,
check_function=check_juniper_led,
check_ruleset_name='juniper_led',
check_default_parameters={
}
)
File added
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Monitor Juniper Networks Alarm LED state. This is a '
'rewrite/extension for the "juniper_alarm" check plugin.\n'
'\n'
'Extends the check for all LEDs available in the MIB and also '
'for the "blinking" state of the LEDs.\n'
'\n'
'Note: the OIDs used in this check are deprecated by Juniper.\n'
'\n'
'ToDo: WATO to match monitoring states to LED states\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['juniper_led.py']},
'name': 'juniper_led',
'num_files': 1,
'title': 'Juniper Alarm LEDs',
'version': '20220607v.0.0.1',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment