-static void svg_io_bi_bar(void)
-{
- double max = 0.0;
- double range;
- int max_here = 0;
- int i;
-
- svg("<!-- IO utilization graph - In -->\n");
-
- svg("<text class=\"t2\" x=\"5\" y=\"-15\">IO utilization - read</text>\n");
-
- /*
- * calculate rounding range
- *
- * We need to round IO data since IO block data is not updated on
- * each poll. Applying a smoothing function loses some burst data,
- * so keep the smoothing range short.
- */
- range = 0.25 / (1.0 / hz);
- if (range < 2.0)
- range = 2.0; /* no smoothing */
-
- /* surrounding box */
- svg_graph_box(5);
-
- /* find the max IO first */
- for (i = 1; i < samples; i++) {
- int start;
- int stop;
- double tot;
-
- start = max(i - ((range / 2) - 1), 0);
- stop = min(i + (range / 2), samples - 1);
-
- tot = (double)(blockstat[stop].bi - blockstat[start].bi)
- / (stop - start);
- if (tot > max) {
- max = tot;
- max_here = i;
- }
- tot = (double)(blockstat[stop].bo - blockstat[start].bo)
- / (stop - start);
- if (tot > max)
- max = tot;
- }
-
- /* plot bi */
- for (i = 1; i < samples; i++) {
- int start;
- int stop;
- double tot;
- double pbi;
-
- start = max(i - ((range / 2) - 1), 0);
- stop = min(i + (range / 2), samples);
-
- tot = (double)(blockstat[stop].bi - blockstat[start].bi)
- / (stop - start);
- pbi = tot / max;
-
- if (pbi > 0.001)
- svg("<rect class=\"bi\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
- time_to_graph(sampletime[i - 1] - graph_start),
- (scale_y * 5) - (pbi * (scale_y * 5)),
- time_to_graph(sampletime[i] - sampletime[i - 1]),
- pbi * (scale_y * 5));
-
- /* labels around highest value */
- if (i == max_here) {
- svg(" <text class=\"sec\" x=\"%.03f\" y=\"%.03f\">%0.2fmb/sec</text>\n",
- time_to_graph(sampletime[i] - graph_start) + 5,
- ((scale_y * 5) - (pbi * (scale_y * 5))) + 15,
- max / 1024.0 / (interval / 1000000000.0));
- }
- }
+static void svg_pss_graph(void) {
+ struct ps_struct *ps;
+ int i;
+ struct list_sample_data *sampledata_last;
+
+ sampledata_last = head;
+ LIST_FOREACH_BEFORE(link, sampledata, head) {
+ sampledata_last = sampledata;
+ }
+
+
+ svg("\n\n<!-- Pss memory size graph -->\n");
+
+ svg("\n <text class=\"t2\" x=\"5\" y=\"-15\">Memory allocation - Pss</text>\n");
+
+ /* vsize 1000 == 1000mb */
+ svg_graph_box(100);
+ /* draw some hlines for usable memory sizes */
+ for (i = 100000; i < 1000000; i += 100000) {
+ svg(" <line class=\"sec01\" x1=\"%.03f\" y1=\"%.0f\" x2=\"%.03f\" y2=\"%.0f\"/>\n",
+ time_to_graph(.0),
+ kb_to_graph(i),
+ time_to_graph(sampledata_last->sampletime - graph_start),
+ kb_to_graph(i));
+ svg(" <text class=\"sec\" x=\"%.03f\" y=\"%.0f\">%dM</text>\n",
+ time_to_graph(sampledata_last->sampletime - graph_start) + 5,
+ kb_to_graph(i), (1000000 - i) / 1000);
+ }
+ svg("\n");
+
+ /* now plot the graph itself */
+ i = 1;
+ prev_sampledata = head;
+ LIST_FOREACH_BEFORE(link, sampledata, head) {
+ int bottom;
+ int top;
+ struct ps_sched_struct *cross_place;
+
+ bottom = 0;
+ top = 0;
+
+ /* put all the small pss blocks into the bottom */
+ ps = ps_first;
+ while (ps->next_ps) {
+ ps = ps->next_ps;
+ if (!ps)
+ continue;
+ ps->sample = ps->first;
+ while (ps->sample->next) {
+ ps->sample = ps->sample->next;
+ if (ps->sample->sampledata == sampledata)
+ break;
+ }
+ if (ps->sample->sampledata == sampledata) {
+ if (ps->sample->pss <= (100 * arg_scale_y))
+ top += ps->sample->pss;
+ break;
+ }
+ }
+ while (ps->sample->cross) {
+ cross_place = ps->sample->cross;
+ ps = ps->sample->cross->ps_new;
+ ps->sample = cross_place;
+ if (ps->sample->pss <= (100 * arg_scale_y))
+ top += ps->sample->pss;
+ }
+
+ svg(" <rect class=\"clrw\" style=\"fill: %s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
+ "rgb(64,64,64)",
+ time_to_graph(prev_sampledata->sampletime - graph_start),
+ kb_to_graph(1000000.0 - top),
+ time_to_graph(sampledata->sampletime - prev_sampledata->sampletime),
+ kb_to_graph(top - bottom));
+ bottom = top;
+
+ /* now plot the ones that are of significant size */
+ ps = ps_first;
+ while (ps->next_ps) {
+ ps = ps->next_ps;
+ if (!ps)
+ continue;
+ ps->sample = ps->first;
+ while (ps->sample->next) {
+ ps->sample = ps->sample->next;
+ if (ps->sample->sampledata == sampledata)
+ break;
+ }
+ /* don't draw anything smaller than 2mb */
+ if (ps->sample->sampledata == sampledata) {
+ if (ps->sample->pss > (100 * arg_scale_y)) {
+ top = bottom + ps->sample->pss;
+ svg(" <rect class=\"clrw\" style=\"fill: %s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
+ colorwheel[ps->pid % 12],
+ time_to_graph(prev_sampledata->sampletime - graph_start),
+ kb_to_graph(1000000.0 - top),
+ time_to_graph(sampledata->sampletime - prev_sampledata->sampletime),
+ kb_to_graph(top - bottom));
+ bottom = top;
+ }
+ break;
+ }
+ }
+ while ((cross_place = ps->sample->cross)) {
+ ps = ps->sample->cross->ps_new;
+ ps->sample = cross_place;
+ if (ps->sample->pss > (100 * arg_scale_y)) {
+ top = bottom + ps->sample->pss;
+ svg(" <rect class=\"clrw\" style=\"fill: %s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
+ colorwheel[ps->pid % 12],
+ time_to_graph(prev_sampledata->sampletime - graph_start),
+ kb_to_graph(1000000.0 - top),
+ time_to_graph(sampledata->sampletime - prev_sampledata->sampletime),
+ kb_to_graph(top - bottom));
+ bottom = top;
+ }
+ }
+ prev_sampledata = sampledata;
+ i++;
+ }
+
+ /* overlay all the text labels */
+ i = 1;
+ LIST_FOREACH_BEFORE(link, sampledata, head) {
+ int bottom;
+ int top = 0;
+ struct ps_sched_struct *prev_sample;
+ struct ps_sched_struct *cross_place;
+
+ /* put all the small pss blocks into the bottom */
+ ps = ps_first->next_ps;
+ while (ps->next_ps) {
+ ps = ps->next_ps;
+ if (!ps)
+ continue;
+ ps->sample = ps->first;
+ while (ps->sample->next) {
+ ps->sample = ps->sample->next;
+ if (ps->sample->sampledata == sampledata)
+ break;
+ }
+ if (ps->sample->sampledata == sampledata) {
+ if (ps->sample->pss <= (100 * arg_scale_y))
+ top += ps->sample->pss;
+ break;
+ }
+ }
+ while ((cross_place = ps->sample->cross)) {
+ ps = ps->sample->cross->ps_new;
+ ps->sample = cross_place;
+ if (ps->sample->pss <= (100 * arg_scale_y))
+ top += ps->sample->pss;
+ }
+ bottom = top;
+
+ /* now plot the ones that are of significant size */
+ ps = ps_first;
+ while (ps->next_ps) {
+ prev_sample = ps->sample;
+ ps = ps->next_ps;
+ if (!ps)
+ continue;
+ ps->sample = ps->first;
+ while (ps->sample->next) {
+ prev_sample = ps->sample;
+ ps->sample = ps->sample->next;
+ if (ps->sample->sampledata == sampledata)
+ break;
+ }
+ /* don't draw anything smaller than 2mb */
+ if (ps->sample->sampledata == sampledata) {
+ if (ps->sample->pss > (100 * arg_scale_y)) {
+ top = bottom + ps->sample->pss;
+ /* draw a label with the process / PID */
+ if ((i == 1) || (prev_sample->pss <= (100 * arg_scale_y)))
+ svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]</text>\n",
+ time_to_graph(sampledata->sampletime - graph_start),
+ kb_to_graph(1000000.0 - bottom - ((top - bottom) / 2)),
+ ps->name,
+ ps->pid);
+ bottom = top;
+ }
+ break;
+ }
+ }
+ while ((cross_place = ps->sample->cross)) {
+ ps = ps->sample->cross->ps_new;
+ ps->sample = cross_place;
+ prev_sample = ps->sample->prev;
+ if (ps->sample->pss > (100 * arg_scale_y)) {
+ top = bottom + ps->sample->pss;
+ /* draw a label with the process / PID */
+ if ((i == 1) || (prev_sample->pss <= (100 * arg_scale_y)))
+ svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]</text>\n",
+ time_to_graph(sampledata->sampletime - graph_start),
+ kb_to_graph(1000000.0 - bottom - ((top - bottom) / 2)),
+ ps->name,
+ ps->pid);
+ bottom = top;
+ }
+ }
+ i++;
+ }
+
+ /* debug output - full data dump */
+ svg("\n\n<!-- PSS map - csv format -->\n");
+ ps = ps_first;
+ while (ps->next_ps) {
+ _cleanup_free_ char *enc_name = NULL;
+ ps = ps->next_ps;
+ if (!ps)
+ continue;
+
+ enc_name = xml_comment_encode(ps->name);
+ if (!enc_name)
+ continue;
+
+ svg("<!-- %s [%d] pss=", enc_name, ps->pid);
+
+ ps->sample = ps->first;
+ while (ps->sample->next) {
+ ps->sample = ps->sample->next;
+ svg("%d," , ps->sample->pss);
+ }
+ svg(" -->\n");
+ }
+