Skip to content

Commit

Permalink
Add an option to treat missing data as critical state
Browse files Browse the repository at this point in the history
  • Loading branch information
gollux committed Jun 5, 2020
1 parent f32c6c1 commit 8d6a127
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions check_influxdb_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def serialize_influx_series_key(key):
help="warning thresholds, Nagios format")
parser.add_argument("--critical", type=str, required=False,
help="critical thresholds, Nagios format")
parser.add_argument("--missing-as-critical", action='store_const', const=True, required=False,
help="treat missing data as critical state instead of unknown")

parser.add_argument("--output-template", type=str, required=False, default="Values: %s",
help="Template for outputing message")
Expand Down Expand Up @@ -201,8 +203,12 @@ def serialize_influx_series_key(key):
# EDGE CASE: NO DATA

if is_resultset_empty:
nagios_status = 3
nagios_status_desc = 'UNKNOWN'
if args.missing_as_critical:
nagios_status = 2
nagios_status_desc = 'CRITICAL'
else:
nagios_status = 3
nagios_status_desc = 'UNKNOWN'
message = 'No data returned from query'
message = nagios_status_desc + " - " + message
print(message)
Expand Down

0 comments on commit 8d6a127

Please sign in to comment.