Skip to content

Commit 069adcc

Browse files
author
Carl Chang
committed
change config parameter to named from positional;
update readme; remove .idea files;
1 parent 2a19679 commit 069adcc

File tree

9 files changed

+20
-76
lines changed

9 files changed

+20
-76
lines changed

.idea/check_snmp.iml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.idea/deployment.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.idea/dictionaries/carl.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
#### Python script that checks components status against Dell or HPE servers with snmpwalk command
33

44
```
5-
usage: check_snmp.py [-h] [-v VERSION] [-c COMMUNITY] [-r] [-f]
6-
host [config] [category [category ...]]
5+
usage: check_snmp.py [-h] [-v VERSION] [-c COMMUNITY] [-r] [-f] [--config [CONFIG]]
6+
host [category [category ...]]
77
88
positional arguments:
9-
host The host to connect to.
10-
config The configuration file to load.
11-
category One or more of the categories from the configuration separated by spaces.
9+
host The host to connect to.
10+
category One or more of the categories from the configuration separated by spaces.
1211
1312
optional arguments:
14-
-h, --help show this help message and exit
15-
-v VERSION The SNMP version to use.
16-
-c COMMUNITY The community string to use.
17-
-r Respect properties marked as important when other results contain errors.
18-
-f Include additional format like colors in the output.
13+
-h, --help show this help message and exit
14+
-v VERSION, --version VERSION
15+
The SNMP version to use.
16+
-c COMMUNITY, --community COMMUNITY
17+
The community string to use.
18+
-r, --respect Respect properties marked as important when other results contain errors.
19+
-f, --format Include additional format like colors in the output.
20+
--config [CONFIG] The configuration file to load.
1921
```
2022

2123
For example `check_snmp.py -r -f 192.168.1.120`
@@ -31,6 +33,9 @@ Only a few are used by the script. The rest are kept for completeness. Also they
3133
**Keep the folder at the same directory with the script so the MIB files can be loaded correctly.**
3234

3335
The script is developed and tested on Python 3.5 against a few Dell PowerEdge servers (iDRAC 9) and HPE ProLiant DL380 Gen9 (iLO 4).
36+
37+
And of course you need to have snmp installed with `sudo apt install snmp`.
38+
3439
As one of my earliest Python projects, feel free to fork and make your own improvements.
3540

3641
--------------

check_snmp.py

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

1111
_parser = argparse.ArgumentParser()
12-
_parser.add_argument('-v', dest='version', help='The SNMP version to use.', default='2c')
13-
_parser.add_argument('-c', dest='community', help='The community string to use.', default='public')
14-
_parser.add_argument('-r', dest='respect', help='Respect properties marked as important when other results contain errors.', action='store_true')
15-
_parser.add_argument('-f', dest='more_format', help='Include additional format like colors in the output.', action='store_true')
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')
1616
_parser.add_argument('host', help='The host to connect to.')
17-
_parser.add_argument('config', nargs='?', help='The configuration file to load.', default='config_default.json')
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

0 commit comments

Comments
 (0)