4545 SimpleNagios , NAGIOS_CACHE_DIR , NAGIOS_CACHE_FILENAME_TEMPLATE , exit_from_errorcode ,
4646 NAGIOS_EXIT_OK , NAGIOS_EXIT_WARNING , NAGIOS_EXIT_CRITICAL , NAGIOS_EXIT_UNKNOWN ,
4747)
48- from vsc .utils .timestamp import (
49- convert_timestamp , write_timestamp , retrieve_timestamp_with_default
50- )
48+ from vsc .utils .timestamp import convert_timestamp , write_timestamp , retrieve_timestamp_with_default
5149from vsc .utils .timestamp_pid_lockfile import TimestampedPidLockfile
5250
5351DEFAULT_TIMESTAMP = "20140101000000Z"
54- TIMESTAMP_FILE_OPTION = ' timestamp_file'
52+ TIMESTAMP_FILE_OPTION = " timestamp_file"
5553DEFAULT_CLI_OPTIONS = {
56- ' start_timestamp' : ("The timestamp form which to start, otherwise use the cached value" , None , "store" , None ),
54+ " start_timestamp" : ("The timestamp form which to start, otherwise use the cached value" , None , "store" , None ),
5755 TIMESTAMP_FILE_OPTION : ("Location to cache the start timestamp" , None , "store" , None ),
5856}
5957MAX_DELTA = 3
@@ -151,12 +149,13 @@ def prologue(self):
151149 """
152150
153151 # bail if nagios report is requested
154- self .nagios_reporter = SimpleNagios (_cache = self .options .nagios_check_filename ,
155- _report_and_exit = self .options .nagios_report ,
156- _threshold = self .options .nagios_check_interval_threshold ,
157- _cache_user = self .options .nagios_user ,
158- _world_readable = self .options .nagios_world_readable_check ,
159- )
152+ self .nagios_reporter = SimpleNagios (
153+ _cache = self .options .nagios_check_filename ,
154+ _report_and_exit = self .options .nagios_report ,
155+ _threshold = self .options .nagios_check_interval_threshold ,
156+ _cache_user = self .options .nagios_user ,
157+ _world_readable = self .options .nagios_world_readable_check ,
158+ )
160159
161160 # check for HA host
162161 if self .options .ha and not proceed_on_ha_service (self .options .ha ):
@@ -165,8 +164,9 @@ def prologue(self):
165164 sys .exit (NAGIOS_EXIT_OK )
166165
167166 if not self .options .disable_locking and not self .options .dry_run :
168- self .lockfile = TimestampedPidLockfile (self .options .locking_filename ,
169- threshold = self .options .nagios_check_interval_threshold * 2 )
167+ self .lockfile = TimestampedPidLockfile (
168+ self .options .locking_filename , threshold = self .options .nagios_check_interval_threshold * 2
169+ )
170170 lock_or_bork (self .lockfile , self .nagios_reporter )
171171
172172 self .log .info ("%s has started" , _script_name (sys .argv [0 ]))
@@ -182,7 +182,7 @@ def epilogue(self, nagios_message, nagios_thresholds=None):
182182
183183 self ._epilogue ()
184184
185- nagios_thresholds [' message' ] = nagios_message
185+ nagios_thresholds [" message" ] = nagios_message
186186 self .nagios_reporter ._eval_and_exit (** nagios_thresholds )
187187 self .log .info ("%s has finished" , _script_name (sys .argv [0 ])) # may not be reached
188188
@@ -231,6 +231,7 @@ class CLI:
231231 """
232232 Base class to implement cli tools that require timestamps, nagios checks, etc.
233233 """
234+
234235 TIMESTAMP_MANDATORY = True
235236
236237 CLI_OPTIONS = {}
@@ -255,7 +256,6 @@ def __init__(self, name=None, default_options=None):
255256 self .start_timestamp = None
256257 self .current_time = None
257258
258-
259259 def make_options (self , defaults = None ):
260260 """
261261 Take the default sync options, set the default timestamp file and merge
@@ -320,7 +320,7 @@ def critical_exception(self, msg, exception):
320320 logging .exception ("%s: %s" , msg , exception )
321321 exit_from_errorcode (2 , msg )
322322
323- def do (self , dry_run ): #pylint: disable=unused-argument
323+ def do (self , dry_run ): # pylint: disable=unused-argument
324324 """
325325 Method to add actual work to do.
326326 The method is executed in main method in a generic try/except/finally block
@@ -408,9 +408,7 @@ def main(self):
408408 self .fulloptions .epilogue (f"{ msg } complete" , self .thresholds )
409409
410410
411-
412411class NrpeCLI (CLI ):
413-
414412 def __init__ (self , name = None , default_options = None ):
415413 super ().__init__ (name = name , default_options = default_options )
416414
0 commit comments