Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor arguments #3

Merged
merged 3 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ these plugins were developed / tested on the following models:
* [check_cisco_stackmodules.py](docs/check_cisco_stackmodules.md)

### Installing dependencies
* `pip3.6 install -r requirements.txt`
* `pip3 install -r requirements.txt`

## Contributing
* You're welcome to open pull requests
Expand Down
87 changes: 47 additions & 40 deletions check_cisco_cpuload.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,46 +50,53 @@ def get_args():
""" Parse Arguments """
parser = ArgumentParser(
description="Icinga/Nagios plugin which checks cpu \
load on Cisco switches/routers",
epilog=""
)
parser.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
parser.add_argument("-p", "--port", required=False,
help="SNMP port", type=int, dest='port', default=161)
parser.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)
parser.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
parser.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
parser.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
parser.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
parser.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
parser.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])
parser.add_argument("-w", "--warn", required=False,
help="warning thresholds (5sec,1min,5min)",
type=str, dest='warn', default="90,80,70")
parser.add_argument("-c", "--crit", required=False,
help="warning thresholds (5sec,1min,5min)",
type=str, dest='crit', default="95,90,80")
parser.add_argument("--mode", required=False, help="", type=str,
dest='mode',
default="CISCO-PROCESS-MIB_NEW",
choices=['CISCO-PROCESS-MIB_NEW',
'CISCO-PROCESS-MIB_OLD'])
load on Cisco switches/routers")

checkopts = parser.add_argument_group('Check parameters')
checkopts.add_argument("--mode", required=False, help="", type=str,
dest='mode',
default="CISCO-PROCESS-MIB_NEW",
choices=['CISCO-PROCESS-MIB_NEW',
'CISCO-PROCESS-MIB_OLD'])

thresholds = parser.add_argument_group('Thresholds')
thresholds.add_argument("-w", "--warn", required=False,
help="warning thresholds (5sec,1min,5min)",
type=str, dest='warn', default="90,80,70")
thresholds.add_argument("-c", "--crit", required=False,
help="warning thresholds (5sec,1min,5min)",
type=str, dest='crit', default="95,90,80")

connopts = parser.add_argument_group('Connection parameters')
connopts.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
connopts.add_argument("-p", "--port", required=False,
help="SNMP port", type=int, dest='port', default=161)
connopts.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)

snmpopts = parser.add_argument_group('SNMPv3 parameters')
snmpopts.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
snmpopts.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
snmpopts.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
snmpopts.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
snmpopts.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
snmpopts.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])

args = parser.parse_args()
return args

Expand Down
75 changes: 40 additions & 35 deletions check_cisco_envtemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,46 @@ def get_args():
""" Parse Arguments """
parser = ArgumentParser(
description="Icinga/Nagios plugin which checks temperature \
sensors on Cisco switches/routers",
epilog=""
)
parser.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
parser.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
parser.add_argument("-t", "--timeout", required=False, help="SNMP timeout",
type=int, dest='timeout', default=10)
parser.add_argument("-u", "--user", required=True, help="SNMPv3 user name",
type=str, dest='user')
parser.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
parser.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
parser.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
parser.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
parser.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])
parser.add_argument("--os", required=False, help="Switch operating system",
type=str, dest='os',
default='ios', choices=['ios', 'nxos'])
parser.add_argument("--scale", required=False,
help="Scaling factor for thresholds (in percent), \
currently only works wiht --os nxos",
type=float, dest='scale')
sensors on Cisco switches/routers")

checkopts = parser.add_argument_group('Check parameters')
checkopts.add_argument("--os", required=False, help="Switch operating system",
type=str, dest='os',
default='ios', choices=['ios', 'nxos'])
checkopts.add_argument("--scale", required=False,
help="Scaling factor for thresholds (in percent), \
currently only works wiht --os nxos",
type=float, dest='scale')

connopts = parser.add_argument_group('Connection parameters')
connopts.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
connopts.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
connopts.add_argument("-t", "--timeout", required=False, help="SNMP timeout",
type=int, dest='timeout', default=10)

snmpopts = parser.add_argument_group('SNMPv3 parameters')
snmpopts.add_argument("-u", "--user", required=True, help="SNMPv3 user name",
type=str, dest='user')
snmpopts.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
snmpopts.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
snmpopts.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
snmpopts.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
snmpopts.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])

args = parser.parse_args()
return args

Expand Down
85 changes: 46 additions & 39 deletions check_cisco_memusage.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,52 @@ def get_args():
""" Parse Arguments """
parser = ArgumentParser(
description="Icinga/Nagios plugin which checks system memory \
usage on Cisco switches/routers",
epilog=""
)
parser.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
parser.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
parser.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)
parser.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
parser.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
parser.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
parser.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
parser.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
parser.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])
parser.add_argument("-w", "--warn", required=False,
help="warning threshold (in percent)",
type=float, dest='warn', default="70")
parser.add_argument("-c", "--crit", required=False,
help="warning thresholds (in percent)",
type=float, dest='crit', default="80")
parser.add_argument("--mib", required=False, help="use OIDs from this MIB",
type=str, dest='mib',
default="CISCO-PROCESS-MIB",
choices=["CISCO-PROCESS-MIB", "CISCO-MEMORY-POOL-MIB"])
usage on Cisco switches/routers")

checkopts = parser.add_argument_group('Check parameters')
checkopts.add_argument("--mib", required=False, help="use OIDs from this MIB",
type=str, dest='mib',
default="CISCO-PROCESS-MIB",
choices=["CISCO-PROCESS-MIB", "CISCO-MEMORY-POOL-MIB"])

connopts = parser.add_argument_group('Connection parameters')
connopts.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
connopts.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
connopts.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)

thresholds = parser.add_argument_group('Thresholds')
thresholds.add_argument("-w", "--warn", required=False,
help="warning threshold (in percent)",
type=float, dest='warn', default="70")
thresholds.add_argument("-c", "--crit", required=False,
help="warning thresholds (in percent)",
type=float, dest='crit', default="80")

snmpopts = parser.add_argument_group('SNMPv3 parameters')
snmpopts.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
snmpopts.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
snmpopts.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
snmpopts.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
snmpopts.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
snmpopts.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])

args = parser.parse_args()
return args

Expand Down
61 changes: 32 additions & 29 deletions check_cisco_stackmodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,38 @@
def get_args():
""" Parse Arguments """
parser = ArgumentParser(
description="Cisco stack module check plugin",
epilog=""
)
parser.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
parser.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
parser.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)
parser.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
parser.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
parser.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
parser.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
parser.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
parser.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])
description="Cisco stack module check plugin")

connopts = parser.add_argument_group('Connection parameters')
connopts.add_argument("-H", "--host", required=True,
help="hostname or IP address", type=str, dest='host')
connopts.add_argument("-p", "--port", required=False, help="SNMP port",
type=int, dest='port', default=161)
connopts.add_argument("-t", "--timeout", required=False,
help="SNMP timeout", type=int, dest='timeout',
default=10)

snmpopts = parser.add_argument_group('SNMPv3 parameters')
snmpopts.add_argument("-u", "--user", required=True,
help="SNMPv3 user name", type=str, dest='user')
snmpopts.add_argument("-l", "--seclevel", required=False,
help="SNMPv3 security level", type=str,
dest="v3mode",
choices=["authPriv", "authNoPriv"], default="authPriv")
snmpopts.add_argument("-A", "--authkey", required=True,
help="SNMPv3 auth key", type=str, dest='authkey')
snmpopts.add_argument("-X", "--privkey", required=True,
help="SNMPv3 priv key", type=str, dest='privkey')
snmpopts.add_argument("-a", "--authmode", required=False,
help="SNMPv3 auth mode", type=str, dest='authmode',
default='SHA',
choices=['MD5', 'SHA', 'SHA224', 'SHA256', 'SHA384',
'SHA512'])
snmpopts.add_argument("-x", "--privmode", required=False,
help="SNMPv3 privacy mode", type=str, dest='privmode',
default='AES',
choices=['DES', '3DES', 'AES', 'AES192', 'AES256'])

args = parser.parse_args()
return args

Expand Down
Loading