Skip to content

Commit b708ace

Browse files
author
Carl Chang
authored
add brief option
1 parent ce0b65d commit b708ace

File tree

1 file changed

+9
-165
lines changed

1 file changed

+9
-165
lines changed

check_snmp.py

Lines changed: 9 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
from typing import NamedTuple
1010

1111
_parser = argparse.ArgumentParser()
12-
_parser.add_argument('-v', '--version', dest='version', help='The SNMP version to use.', default='2c')
13-
_parser.add_argument('-c', '--community', dest='community', help='The community string to use.', default='public')
14-
_parser.add_argument('-r', '--respect', dest='respect', help='Respect properties marked as important when other results contain errors.', action='store_true')
15-
_parser.add_argument('-f', '--format', dest='more_format', help='Include additional format like colors in the output.', action='store_true')
12+
_parser.add_argument('-v', '--version', help='The SNMP version to use.', default='2c')
13+
_parser.add_argument('-c', '--community', help='The community string to use.', default='public')
14+
_parser.add_argument('-r', '--respect', help='Respect properties marked as important when other results contain errors.', action='store_true')
15+
_parser.add_argument('-f', '--format', help='Include additional format like colors in the output.', action='store_true')
16+
_parser.add_argument('-b', '--brief', help='Output brief information (only combined status etc.).', action='store_true')
1617
_parser.add_argument('host', help='The host to connect to.')
1718
_parser.add_argument('--config', nargs='?', help='The configuration file to load.', default='config_default.json')
1819
_parser.add_argument('category', nargs='*', help='One or more of the categories from the configuration separated by spaces.')
@@ -23,170 +24,12 @@
2324
args_Version = _args.version
2425
args_Community = _args.community
2526
args_RespectImp = _args.respect
26-
args_MoreFormat = _args.more_format
27+
args_MoreFormat = _args.format
28+
args_Brief = _args.brief
2729

2830
# get base folder
2931
os.chdir(os.path.dirname(os.path.realpath(__file__)))
3032

31-
# definitions
32-
# config content moved to config_default.json
33-
# Config = {
34-
# 'dell': {
35-
# 'mib_dir': 'mibs/default:mibs/iana:mibs/ietf:mibs/dell',
36-
# 'mib': 'IDRAC-MIB-SMIv2',
37-
# 'categories': OrderedDict([
38-
# ('global', {
39-
# 'description': 'Overall System Status',
40-
# 'oids': [
41-
# {'oid': 'systemModelName', 'type': 'text'},
42-
# {'oid': 'systemServiceTag', 'type': 'text'},
43-
# {'oid': 'globalSystemStatus', 'type': 'status'},
44-
# ],
45-
# 'important': True
46-
# }),
47-
# ('processor', {
48-
# 'description': 'Processor Status',
49-
# 'oids': [
50-
# {'oid': 'processorDeviceBrandName', 'type': 'text'},
51-
# {'oid': 'processorDeviceStatus', 'type': 'status'},
52-
# ],
53-
# }),
54-
# ('memory', {
55-
# 'description': 'Memory Status',
56-
# 'oids': [
57-
# {'oid': 'memoryDeviceLocationName', 'type': 'text'},
58-
# {'oid': 'memoryDeviceStatus', 'type': 'status'},
59-
# ],
60-
# }),
61-
# ('physicalDisk', {
62-
# 'description': 'Physical Disk Status',
63-
# 'oids': [
64-
# {'oid': 'physicalDiskDisplayName', 'type': 'text'},
65-
# {'oid': 'physicalDiskState', 'type': 'status'},
66-
# ],
67-
# }),
68-
# ('virtualDisk', {
69-
# 'description': 'Virtual Disk Status',
70-
# 'oids': [
71-
# {'oid': 'virtualDiskDisplayName', 'type': 'text'},
72-
# {'oid': 'virtualDiskState', 'type': 'status'},
73-
# ],
74-
# }),
75-
# ('storageController', {
76-
# 'description': 'Storage Controller Status',
77-
# 'oids': [
78-
# {'oid': 'controllerName', 'type': 'text'},
79-
# {'oid': 'controllerComponentStatus', 'type': 'status'},
80-
# ],
81-
# }),
82-
# ('cooling', {
83-
# 'description': 'Cooling Status',
84-
# 'oids': [
85-
# {'oid': 'coolingUnitName', 'type': 'text'},
86-
# {'oid': 'coolingUnitStatus', 'type': 'status'},
87-
# ],
88-
# }),
89-
# ('temperature', {
90-
# 'description': 'Temperature Status',
91-
# 'oids': [
92-
# {'oid': 'temperatureProbeLocationName', 'type': 'text'},
93-
# {'oid': 'temperatureProbeStatus', 'type': 'status'},
94-
# ],
95-
# }),
96-
# ('powerSupply', {
97-
# 'description': 'Power Supply Status',
98-
# 'oids': [
99-
# {'oid': 'powerSupplyLocationName', 'type': 'text'},
100-
# {'oid': 'powerSupplyStatus', 'type': 'status'},
101-
# ],
102-
# }),
103-
# ('battery', {
104-
# 'description': 'Battery Status',
105-
# 'oids': [
106-
# {'oid': 'systemBatteryLocationName', 'type': 'text'},
107-
# {'oid': 'systemBatteryStatus', 'type': 'status'},
108-
# ],
109-
# }),
110-
# ])
111-
# },
112-
# 'hpe': {
113-
# 'mib_dir': 'mibs/default:mibs/iana:mibs/ietf:mibs/hpe',
114-
# 'mib': 'CPQSINFO-MIB:CPQHLTH-MIB:CPQIDA-MIB:CPQSTDEQ-MIB',
115-
# 'categories': OrderedDict([
116-
# ('global', {
117-
# 'description': 'Overall System Status',
118-
# 'oids': [
119-
# {'oid': 'cpqSiProductName', 'type': 'text'},
120-
# {'oid': 'cpqSiSysSerialNum', 'type': 'text'},
121-
# {'oid': 'cpqHeMibCondition', 'type': 'status'},
122-
# ],
123-
# 'important': True
124-
# }),
125-
# ('processor', {
126-
# 'description': 'Processor Status',
127-
# 'oids': [
128-
# {'oid': 'cpqSeCpuName', 'type': 'text'},
129-
# {'oid': 'cpqSeCpuStatus', 'type': 'status'},
130-
# ],
131-
# }),
132-
# ('memory', {
133-
# 'description': 'Memory Status',
134-
# 'oids': [
135-
# {'oid': 'cpqHeResMem2ModuleHwLocation', 'type': 'text'},
136-
# {'oid': 'cpqHeResMem2ModuleCondition', 'type': 'status'},
137-
# ],
138-
# }),
139-
# ('physicalDisk', {
140-
# 'description': 'Physical Disk Status',
141-
# 'oids': [
142-
# {'oid': 'cpqDaPhyDrvLocationString', 'type': 'text'},
143-
# {'oid': 'cpqDaPhyDrvCondition', 'type': 'status'},
144-
# ],
145-
# }),
146-
# ('virtualDisk', {
147-
# 'description': 'Virtual Disk Status',
148-
# 'oids': [
149-
# {'oid': 'cpqDaLogDrvCondition', 'type': 'status'},
150-
# ],
151-
# }),
152-
# ('storageController', {
153-
# 'description': 'Storage Controller Status',
154-
# 'oids': [
155-
# {'oid': 'cpqDaCntlrModel', 'type': 'text'},
156-
# {'oid': 'cpqDaCntlrCondition', 'type': 'status'},
157-
# ],
158-
# }),
159-
# ('cooling', {
160-
# 'description': 'Cooling Status',
161-
# 'oids': [
162-
# {'oid': 'cpqHeFltTolFanLocale', 'type': 'text'},
163-
# {'oid': 'cpqHeFltTolFanCondition', 'type': 'status'},
164-
# ],
165-
# }),
166-
# ('temperature', {
167-
# 'description': 'Temperature Status',
168-
# 'oids': [
169-
# {'oid': 'cpqHeTemperatureLocale', 'type': 'text'},
170-
# {'oid': 'cpqHeTemperatureCondition', 'type': 'status'},
171-
# ],
172-
# }),
173-
# ('powerSupply', {
174-
# 'description': 'Power Supply Status',
175-
# 'oids': [
176-
# {'oid': 'cpqHeFltTolPowerSupplyModel', 'type': 'text'},
177-
# {'oid': 'cpqHeFltTolPowerSupplyCondition', 'type': 'status'},
178-
# ],
179-
# }),
180-
# ('eventLog', {
181-
# 'description': 'Integrated Management Log Status',
182-
# 'oids': [
183-
# {'oid': 'cpqHeEventLogCondition', 'type': 'status'},
184-
# ],
185-
# }),
186-
# ]),
187-
# }
188-
# }
189-
19033
# load config file
19134
with open(args_Config, 'r') as config_file:
19235
Config = json.load(config_file, object_pairs_hook=OrderedDict)
@@ -358,7 +201,8 @@ def get_row_output(col_val_raw: str, col_type: str, col_prefix: str = None, col_
358201
col[2],
359202
col[3]))
360203

361-
category_output += list_bullet + oid_separator.join(cols) + '\n'
204+
if not args_Brief:
205+
category_output += list_bullet + oid_separator.join(cols) + '\n'
362206
category_output = category_output.format(combined_status=status_formatter(category_code, with_color=args_MoreFormat))
363207

364208
print(category_output)

0 commit comments

Comments
 (0)