11#
2- # Copyright 2012-2021 Ghent University
2+ # Copyright 2012-2022 Ghent University
33#
44# This file is part of vsc-utils,
55# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
@@ -80,7 +80,7 @@ def _script_name(full_name):
8080 os .path .join (NAGIOS_CACHE_DIR ,
8181 NAGIOS_CACHE_FILENAME_TEMPLATE % (_script_name (sys .argv [0 ]),))),
8282 'nagios-check-interval-threshold' : ('threshold of nagios checks timing out' , 'int' , 'store' , 0 ),
83- 'nagios-user' : ('user nagios runs as' , 'string' , 'store' , 'nrpe' ),
83+ 'nagios-user' : ('user nagios runs as' , 'string' , 'store' , None ),
8484 'nagios-world-readable-check' : ('make the nagios check data file world readable' , None , 'store_true' , False ),
8585}
8686
@@ -114,6 +114,7 @@ class ExtendedSimpleOption(SimpleOption):
114114
115115 The prologue should be called at the start of the script; the epilogue at the end.
116116 """
117+ MONITORCLASS = SimpleNagios
117118
118119 def __init__ (self , options , run_prologue = True , excepthook = None , ** kwargs ):
119120 """Initialise.
@@ -127,6 +128,9 @@ def __init__(self, options, run_prologue=True, excepthook=None, **kwargs):
127128 options_ = _merge_options (options )
128129 super (ExtendedSimpleOption , self ).__init__ (options_ , ** kwargs )
129130
131+ if not self .options .nagios_user :
132+ self .options .nagios_user = self .MONITORCLASS .DEFAULT_CACHE_USER
133+
130134 self .nagios_reporter = None
131135 self .lockfile = None
132136
@@ -151,12 +155,12 @@ def prologue(self):
151155 """
152156
153157 # 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- )
158+ self .nagios_reporter = self . MONITORCLASS (_cache = self .options .nagios_check_filename ,
159+ _report_and_exit = self .options .nagios_report ,
160+ _threshold = self .options .nagios_check_interval_threshold ,
161+ _cache_user = self .options .nagios_user ,
162+ _world_readable = self .options .nagios_world_readable_check ,
163+ )
160164
161165 # check for HA host
162166 if self .options .ha and not proceed_on_ha_service (self .options .ha ):
0 commit comments