116116 < div class ="label " style ="font-size: 0.7rem; color: var(--text-dim); "> TOTAL LOSS</ div >
117117 < div class ="value " style ="font-size: 1.5rem; color: var(--danger); "> < span id ="debug-loss "> 0.0</ span > MB</ div >
118118 </ div >
119+ < div class ="card " style ="padding: 1rem; text-align: center; border-color: var(--primary); ">
120+ < div class ="label " style ="font-size: 0.7rem; color: var(--text-dim); "> SERVER UPTIME</ div >
121+ < div class ="value " style ="font-size: 1.5rem; color: var(--primary); " id ="debug-uptime "> 0s</ div >
122+ </ div >
119123 </ div >
120124 </ section >
121125 < div id ="tab-overview " class ="tab-content active ">
@@ -222,9 +226,19 @@ <h2>Playback History</h2>
222226 var debugRam = document . getElementById ( 'debug-ram' ) ; var debugGoroutines = document . getElementById ( 'debug-goroutines' ) ;
223227 var debugHeap = document . getElementById ( 'debug-heap' ) ; var debugStack = document . getElementById ( 'debug-stack' ) ;
224228 var debugGC = document . getElementById ( 'debug-gc' ) ; var debugLoss = document . getElementById ( 'debug-loss' ) ;
229+ var debugUptime = document . getElementById ( 'debug-uptime' ) ;
225230 var isDebug = window . location . search . indexOf ( 'debug' ) !== - 1 ;
226231 if ( isDebug ) document . getElementById ( 'debug-stats' ) . style . display = 'block' ;
227232
233+ function formatBytes ( bytes , decimals = 2 ) {
234+ if ( ! + bytes ) return '0 Bytes' ;
235+ const k = 1024 ;
236+ const dm = decimals < 0 ? 0 : decimals ;
237+ const sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' ] ;
238+ const i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ;
239+ return `${ parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) } ${ sizes [ i ] } ` ;
240+ }
241+
228242 function resize ( ) { var rect = canvas . getBoundingClientRect ( ) ; canvas . width = rect . width * 2 ; canvas . height = rect . height * 2 ; ctx . scale ( 2 , 2 ) ; }
229243 window . addEventListener ( 'resize' , resize ) ; resize ( ) ;
230244 var historyLen = 60 ; var dataIn = new Array ( historyLen ) . fill ( 0 ) ; var dataOut = new Array ( historyLen ) . fill ( 0 ) ;
@@ -250,17 +264,17 @@ <h2>Playback History</h2>
250264 inRateEl . innerText = rIn . toFixed ( 1 ) ; outRateEl . innerText = rOut . toFixed ( 1 ) ; dataIn . shift ( ) ; dataIn . push ( rIn ) ; dataOut . shift ( ) ; dataOut . push ( rOut ) ; drawChart ( ) ;
251265 gListeners . innerText = data . total_listeners ; gSources . innerText = data . total_sources ;
252266 gStreamers . innerText = data . total_streamers ; gRelays . innerText = data . total_relays ;
253- gMbIn . innerText = ( data . bytes_in / ( 1024 * 1024 ) ) . toFixed ( 1 ) ; gMbOut . innerText = ( data . bytes_out / ( 1024 * 1024 ) ) . toFixed ( 1 ) ;
254- if ( debugRam ) {
255- debugRam . innerText = data . sys_ram ;
256- debugHeap . innerText = data . heap_alloc ;
257- debugStack . innerText = data . stack_sys ;
258- debugGC . innerText = data . num_gc ;
259- debugGoroutines . innerText = data . goroutines ;
260- debugLoss . innerText = ( data . total_dropped / ( 1024 * 1024 ) ) . toFixed ( 2 ) ;
261- }
262-
263- streamsBody . innerHTML = '' ; if ( data . streams . length > 0 ) {
267+ gMbIn . innerText = ( data . bytes_in / ( 1024 * 1024 ) ) . toFixed ( 2 ) ; gMbOut . innerText = ( data . bytes_out / ( 1024 * 1024 ) ) . toFixed ( 2 ) ;
268+ if ( debugRam ) {
269+ debugRam . innerText = formatBytes ( data . sys_ram ) ;
270+ debugHeap . innerText = formatBytes ( data . heap_alloc ) ;
271+ debugStack . innerText = formatBytes ( data . stack_sys ) ;
272+ debugGC . innerText = data . num_gc ;
273+ debugGoroutines . innerText = data . goroutines ;
274+ debugLoss . innerText = formatBytes ( data . total_dropped ) ;
275+ debugUptime . innerText = data . server_uptime ;
276+ }
277+ streamsBody . innerHTML = '' ; if ( data . streams . length > 0 ) {
264278
265279 data . streams . forEach ( function ( s ) {
266280 var prev = streamHistory [ s . mount ] || { in : s . bytes_in , out : s . bytes_out } ; var curIn = ( s . bytes_in - prev . in ) / 1024 , curOut = ( s . bytes_out - prev . out ) / 1024 ; streamHistory [ s . mount ] = { in : s . bytes_in , out : s . bytes_out } ;
0 commit comments