Skip to content

Commit 4aa0383

Browse files
author
Carl Chang
committed
remove default config content from script;
update readme
1 parent fb65e04 commit 4aa0383

File tree

2 files changed

+166
-161
lines changed

2 files changed

+166
-161
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ For example `check_snmp.py -r -f 192.168.1.120`
2323
By default SNMP version **v2c** and community string **public** will be used. Different values can be specified with `-v` and `-c` respectively.
2424
The script will decide the manufacturer based on the OID returned on a initial call to snmpgetnext.
2525

26+
The script will load configurations from file `config_default.json` in the same directory by default.
27+
If you won't specify another config file, keep the default one in the same directory as the script.
28+
2629
The mibs folder contains lots of MIB files downloaded from Dell and HPE websites, also the ones downloaded by `snmp-mibs-downloader`.
2730
Only a few are used by the script. The rest are kept for completeness. Also they are no so big.
2831
**Keep the folder at the same directory with the script so the MIB files can be loaded correctly.**

check_snmp.py

Lines changed: 163 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
_parser.add_argument('-r', dest='respect', help='Respect properties marked as important when other results contain errors.', action='store_true')
1515
_parser.add_argument('-f', dest='more_format', help='Include additional format like colors in the output.', action='store_true')
1616
_parser.add_argument('host', help='The host to connect to.')
17-
_parser.add_argument('config', nargs='?', help='The configuration file to load.')
17+
_parser.add_argument('config', nargs='?', help='The configuration file to load.', default='config_default.json')
1818
_parser.add_argument('category', nargs='*', help='One or more of the categories from the configuration separated by spaces.')
1919
_args = _parser.parse_args()
2020
args_Host = _args.host
@@ -29,166 +29,168 @@
2929
os.chdir(os.path.dirname(os.path.realpath(__file__)))
3030

3131
# definitions
32-
if args_Config:
33-
with open(args_Config, 'r') as config_file:
34-
Config = json.load(config_file, object_pairs_hook=OrderedDict)
35-
else:
36-
Config = {
37-
'dell': {
38-
'mib_dir': 'mibs/default:mibs/iana:mibs/ietf:mibs/dell',
39-
'mib': 'IDRAC-MIB-SMIv2',
40-
'categories': OrderedDict([
41-
('global', {
42-
'description': 'Overall System Status',
43-
'oids': [
44-
{'oid': 'systemModelName', 'type': 'text'},
45-
{'oid': 'systemServiceTag', 'type': 'text'},
46-
{'oid': 'globalSystemStatus', 'type': 'status'},
47-
],
48-
'important': True
49-
}),
50-
('processor', {
51-
'description': 'Processor Status',
52-
'oids': [
53-
{'oid': 'processorDeviceBrandName', 'type': 'text'},
54-
{'oid': 'processorDeviceStatus', 'type': 'status'},
55-
],
56-
}),
57-
('memory', {
58-
'description': 'Memory Status',
59-
'oids': [
60-
{'oid': 'memoryDeviceLocationName', 'type': 'text'},
61-
{'oid': 'memoryDeviceStatus', 'type': 'status'},
62-
],
63-
}),
64-
('physicalDisk', {
65-
'description': 'Physical Disk Status',
66-
'oids': [
67-
{'oid': 'physicalDiskDisplayName', 'type': 'text'},
68-
{'oid': 'physicalDiskState', 'type': 'status'},
69-
],
70-
}),
71-
('virtualDisk', {
72-
'description': 'Virtual Disk Status',
73-
'oids': [
74-
{'oid': 'virtualDiskDisplayName', 'type': 'text'},
75-
{'oid': 'virtualDiskState', 'type': 'status'},
76-
],
77-
}),
78-
('storageController', {
79-
'description': 'Storage Controller Status',
80-
'oids': [
81-
{'oid': 'controllerName', 'type': 'text'},
82-
{'oid': 'controllerComponentStatus', 'type': 'status'},
83-
],
84-
}),
85-
('cooling', {
86-
'description': 'Cooling Status',
87-
'oids': [
88-
{'oid': 'coolingUnitName', 'type': 'text'},
89-
{'oid': 'coolingUnitStatus', 'type': 'status'},
90-
],
91-
}),
92-
('temperature', {
93-
'description': 'Temperature Status',
94-
'oids': [
95-
{'oid': 'temperatureProbeLocationName', 'type': 'text'},
96-
{'oid': 'temperatureProbeStatus', 'type': 'status'},
97-
],
98-
}),
99-
('powerSupply', {
100-
'description': 'Power Supply Status',
101-
'oids': [
102-
{'oid': 'powerSupplyLocationName', 'type': 'text'},
103-
{'oid': 'powerSupplyStatus', 'type': 'status'},
104-
],
105-
}),
106-
('battery', {
107-
'description': 'Battery Status',
108-
'oids': [
109-
{'oid': 'systemBatteryLocationName', 'type': 'text'},
110-
{'oid': 'systemBatteryStatus', 'type': 'status'},
111-
],
112-
}),
113-
])
114-
},
115-
'hpe': {
116-
'mib_dir': 'mibs/default:mibs/iana:mibs/ietf:mibs/hpe',
117-
'mib': 'CPQSINFO-MIB:CPQHLTH-MIB:CPQIDA-MIB:CPQSTDEQ-MIB',
118-
'categories': OrderedDict([
119-
('global', {
120-
'description': 'Overall System Status',
121-
'oids': [
122-
{'oid': 'cpqSiProductName', 'type': 'text'},
123-
{'oid': 'cpqSiSysSerialNum', 'type': 'text'},
124-
{'oid': 'cpqHeMibCondition', 'type': 'status'},
125-
],
126-
'important': True
127-
}),
128-
('processor', {
129-
'description': 'Processor Status',
130-
'oids': [
131-
{'oid': 'cpqSeCpuName', 'type': 'text'},
132-
{'oid': 'cpqSeCpuStatus', 'type': 'status'},
133-
],
134-
}),
135-
('memory', {
136-
'description': 'Memory Status',
137-
'oids': [
138-
{'oid': 'cpqHeResMem2ModuleHwLocation', 'type': 'text'},
139-
{'oid': 'cpqHeResMem2ModuleCondition', 'type': 'status'},
140-
],
141-
}),
142-
('physicalDisk', {
143-
'description': 'Physical Disk Status',
144-
'oids': [
145-
{'oid': 'cpqDaPhyDrvLocationString', 'type': 'text'},
146-
{'oid': 'cpqDaPhyDrvCondition', 'type': 'status'},
147-
],
148-
}),
149-
('virtualDisk', {
150-
'description': 'Virtual Disk Status',
151-
'oids': [
152-
{'oid': 'cpqDaLogDrvCondition', 'type': 'status'},
153-
],
154-
}),
155-
('storageController', {
156-
'description': 'Storage Controller Status',
157-
'oids': [
158-
{'oid': 'cpqDaCntlrModel', 'type': 'text'},
159-
{'oid': 'cpqDaCntlrCondition', 'type': 'status'},
160-
],
161-
}),
162-
('cooling', {
163-
'description': 'Cooling Status',
164-
'oids': [
165-
{'oid': 'cpqHeFltTolFanLocale', 'type': 'text'},
166-
{'oid': 'cpqHeFltTolFanCondition', 'type': 'status'},
167-
],
168-
}),
169-
('temperature', {
170-
'description': 'Temperature Status',
171-
'oids': [
172-
{'oid': 'cpqHeTemperatureLocale', 'type': 'text'},
173-
{'oid': 'cpqHeTemperatureCondition', 'type': 'status'},
174-
],
175-
}),
176-
('powerSupply', {
177-
'description': 'Power Supply Status',
178-
'oids': [
179-
{'oid': 'cpqHeFltTolPowerSupplyModel', 'type': 'text'},
180-
{'oid': 'cpqHeFltTolPowerSupplyCondition', 'type': 'status'},
181-
],
182-
}),
183-
('eventLog', {
184-
'description': 'Integrated Management Log Status',
185-
'oids': [
186-
{'oid': 'cpqHeEventLogCondition', 'type': 'status'},
187-
],
188-
}),
189-
]),
190-
}
191-
}
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+
190+
# load config file
191+
with open(args_Config, 'r') as config_file:
192+
Config = json.load(config_file, object_pairs_hook=OrderedDict)
193+
192194
StatusOK = ('ok', 'true', 'yes', 'on', 'online', 'spunup', 'full', 'ready', 'enabled', 'presence', 'non-raid', 'nonraid', '0')
193195
StatusWarning = ('noncritical', 'removed', 'foreign', 'offline')
194196
StatusCritical = ('fail', 'failed', 'critical', 'nonrecoverable', 'notredundant', 'lost', 'degraded', 'redundancyoffline')

0 commit comments

Comments
 (0)