public static synchronized String getGoogleChartURL ( int minutes , int width , int height , String timeLabel ) { ArrayDeque < Datum > history = historyS ; if ( minutes > 2 ) history = historyM ; if ( minutes > 30 ) history = historyL ; HTMLChartHelper chart = new HTMLChartHelper ( ) ; chart . width = width ; chart . height = height ; chart . timeLabel = timeLabel ; HTMLChartHelper . DataSet Jds = new HTMLChartHelper . DataSet ( ) ; chart . data . add ( Jds ) ; Jds . title = "UsedJava" ; Jds . belowcolor = "ff9999" ; HTMLChartHelper . DataSet Rds = new HTMLChartHelper . DataSet ( ) ; chart . data . add ( Rds ) ; Rds . title = "RSS" ; Rds . belowcolor = "ff0000" ; HTMLChartHelper . DataSet RUds = new HTMLChartHelper . DataSet ( ) ; chart . data . add ( RUds ) ; RUds . title = "RSS+UnusedJava" ; RUds . dashlength = 6 ; RUds . spacelength = 3 ; RUds . thickness = 2 ; RUds . belowcolor = "ffffff" ; long cropts = System . currentTimeMillis ( ) ; cropts -= ( 60 * 1000 * minutes ) ; long modulo = ( 60 * 1000 * minutes ) / 30 ; double maxmemdatum = 0 ; for ( Datum d : history ) { if ( d . timestamp < cropts ) continue ; double javaused = d . javausedheapmem + d . javausedsysmem ; double javaunused = SystemStatsCollector . javamaxheapmem - d . javausedheapmem ; javaused /= 1204 * 1024 ; javaunused /= 1204 * 1024 ; double rss = d . rss / 1024 / 1024 ; long ts = ( d . timestamp / modulo ) * modulo ; if ( ( rss + javaunused ) > maxmemdatum ) maxmemdatum = rss + javaunused ; RUds . append ( ts , rss + javaunused ) ; Rds . append ( ts , rss ) ; Jds . append ( ts , javaused ) ; } chart . megsMax = 2 ; while ( chart . megsMax < maxmemdatum ) chart . megsMax *= 2 ; return chart . getURL ( minutes ) ; }
Get a URL that uses the Google Charts API to show a chart of memory usage history .