add https option

This commit is contained in:
Rob Wilson 2015-02-09 10:20:22 +00:00
parent a322e17c63
commit c50f0c2e74
2 changed files with 10 additions and 3 deletions

View File

@ -52,7 +52,8 @@ usage: check_http_json.py [-h] -H HOST [-p PATH]
[-q [KEY_VALUE_LIST [KEY_VALUE_LIST ...]]]
[-l [KEY_LTE_LIST [KEY_LTE_LIST ...]]]
[-g [KEY_GTE_LIST [KEY_GTE_LIST ...]]]
[-m [METRIC_LIST [METRIC_LIST ...]]] [-d]
[-m [METRIC_LIST [METRIC_LIST ...]]] [-s] [-d]
Nagios plugin which checks json values from a given endpoint against argument
specified rules and determines the status and performance data for that
@ -84,6 +85,7 @@ optional arguments:
plugins.org/doc/guidelines.html Additional formats for
this parameter are: (key), (key,UnitOfMeasure),
(key,UnitOfMeasure,Min,Max).
-s, --ssl HTTPS mode.
-d, --debug Debug mode.
```

View File

@ -157,6 +157,7 @@ def parseArgs():
help='Gathers the values of these keys (key,UnitOfMeasure,Min,Max,WarnRange,CriticalRange) for Nagios performance data.\
More information about Range format and units of measure for nagios can be found at https://nagios-plugins.org/doc/guidelines.html\
Additional formats for this parameter are: (key), (key,UnitOfMeasure), (key,UnitOfMeasure,Min,Max).')
parser.add_argument('-s', '--ssl', action='store_true', help='HTTPS mode.')
parser.add_argument('-d', '--debug', action='store_true', help='Debug mode.')
return parser.parse_args()
@ -173,7 +174,11 @@ if __name__ == "__main__":
args = parseArgs()
nagios = NagiosHelper()
url = "http://%s" % args.host
if args.ssl:
url = "https://%s" % args.host
else:
url = "http://%s" % args.host
if args.path: url += "/%s" % args.path
debugPrint(args.debug, "url:%s" % url)