@@ -897,7 +897,7 @@ int showalert(const char *interface, const AlertOutput output, const AlertExit e
897
897
char tablename [6 ], typeoutput [8 ], conditionname [16 ];
898
898
char datebuff [DATEBUFFLEN ];
899
899
ListType listtype = LT_None ;
900
- uint64_t bytes = 0 , e_rx = 0 , e_tx = 0 , e_bytes = 0 ;
900
+ uint64_t bytes = 0 , e_rx = 0 , e_tx = 0 , e_bytes = 0 , periodseconds = 0 ;
901
901
dbdatalist * datalist = NULL ;
902
902
dbdatalistinfo datainfo ;
903
903
@@ -1079,10 +1079,14 @@ int showalert(const char *interface, const AlertOutput output, const AlertExit e
1079
1079
printf (" percentage | avg. rate\n" );
1080
1080
printf (" ----------+------------------+----------------+--------------\n" );
1081
1081
printf (" used | %16s |" , getvalue (bytes , 16 , RT_Normal ));
1082
+ periodseconds = getperiodseconds (listtype , datalist -> timestamp , ifaceinfo .updated , ongoing );
1083
+ if (ongoing && periodseconds == 0 ) {
1084
+ periodseconds = getperiodseconds (listtype , datalist -> timestamp , ifaceinfo .updated , 0 );
1085
+ }
1082
1086
if (percentage <= 100000.0 ) {
1083
- printf (" %13.1f%% | %13s\n" , percentage , gettrafficrate (bytes , (time_t )getperiodseconds ( listtype , datalist -> timestamp , ifaceinfo . updated , ongoing ) , 13 ));
1087
+ printf (" %13.1f%% | %13s\n" , percentage , gettrafficrate (bytes , (time_t )periodseconds , 13 ));
1084
1088
} else {
1085
- printf (" %14s | %13s\n" , ">100000%" , gettrafficrate (bytes , (time_t )getperiodseconds ( listtype , datalist -> timestamp , ifaceinfo . updated , ongoing ) , 13 ));
1089
+ printf (" %14s | %13s\n" , ">100000%" , gettrafficrate (bytes , (time_t )periodseconds , 13 ));
1086
1090
}
1087
1091
printf (" limit | %16s |" , getvalue (limit , 16 , RT_Normal ));
1088
1092
printf (" | %13s\n" , gettrafficrate (limit , (time_t )getperiodseconds (listtype , datalist -> timestamp , ifaceinfo .updated , 0 ), 13 ));
@@ -1105,7 +1109,8 @@ int showalert(const char *interface, const AlertOutput output, const AlertExit e
1105
1109
if (e_bytes > limit ) {
1106
1110
printf (", +%s\n" , getvalue (e_bytes - limit , 0 , RT_Normal ));
1107
1111
} else {
1108
- printf (" | %13s\n" , gettrafficrate (bytes , (time_t )getperiodseconds (listtype , datalist -> timestamp , ifaceinfo .updated , ongoing ), 13 ));
1112
+ /* rate for estimated is always to same as for used so "bytes" intentionally used here instead of "e_bytes" */
1113
+ printf (" | %13s\n" , gettrafficrate (bytes , (time_t )periodseconds , 13 ));
1109
1114
}
1110
1115
}
1111
1116
}
0 commit comments