@@ -102,7 +102,7 @@ vartab_t *vartab_h = NULL;
102102time_t poll_interval = 2 ;
103103static char * chroot_path = NULL , * user = NULL , * group = NULL ;
104104static int user_from_cmdline = 0 , group_from_cmdline = 0 ,
105- reconnect_max_tries = -1 , reconnect_count = 0 ;
105+ reconnect_max_tries = -1 , reconnect_count = 0 , reconnect_report_freq = -1 ;
106106
107107/* signal handling */
108108int exit_flag = 0 ;
@@ -1410,6 +1410,15 @@ static int main_arg(char *var, char *val)
14101410 }
14111411 }
14121412
1413+ if (!strcmp (var , "reconnect_report_freq" )) {
1414+ int intval = -1 ;
1415+ if ( str_to_int (val , & intval , 10 ) ) {
1416+ reconnect_report_freq = intval ;
1417+ } else {
1418+ upslogx (LOG_INFO , "WARNING : Invalid reconnect_report_freq value found in ups.conf global settings" );
1419+ }
1420+ }
1421+
14131422 /* only for upsdrvctl - ignored here */
14141423 if (!strcmp (var , "sdorder" ))
14151424 return 1 ; /* handled */
@@ -1596,6 +1605,17 @@ static void do_global_args(const char *var, const char *val)
15961605 return ;
15971606 }
15981607
1608+ if (!strcmp (var , "reconnect_report_freq" )) {
1609+ int intval = -1 ;
1610+ if ( str_to_int (val , & intval , 10 ) ) {
1611+ reconnect_report_freq = intval ;
1612+ } else {
1613+ upslogx (LOG_INFO , "WARNING : Invalid reconnect_report_freq value found in ups.conf global settings" );
1614+ }
1615+
1616+ return ;
1617+ }
1618+
15991619 /* Allow to specify its minimal debugging level for all drivers -
16001620 * admins can set more with command-line args, but can't set
16011621 * less without changing config. Should help debug of services.
@@ -2260,6 +2280,10 @@ int reconnect_trying(reconnect_state_t trying) {
22602280 "max %d attempts, then will exit" ,
22612281 upsname , reconnect_max_tries );
22622282 }
2283+ } else if (reconnect_report_freq > 0 && (reconnect_count % reconnect_report_freq ) == 0 ) {
2284+ upslogx (LOG_WARNING , "Driver still reconnecting "
2285+ "to the device [%s] for %d attempts" ,
2286+ upsname , reconnect_count );
22632287 }
22642288
22652289 if (reconnect_count < INT_MAX ) {
0 commit comments