svg.c revision 1c6330456c5ae76085c63d2a7cf3d722596e545a
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick This file is part of systemd.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick Copyright (C) 2009-2013 Intel Coproration
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick Auke Kok <auke-jan.h.kok@intel.com>
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick systemd is free software; you can redistribute it and/or modify it
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick under the terms of the GNU Lesser General Public License as published by
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick the Free Software Foundation; either version 2.1 of the License, or
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick (at your option) any later version.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick systemd is distributed in the hope that it will be useful, but
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick WITHOUT ANY WARRANTY; without even the implied warranty of
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick Lesser General Public License for more details.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick You should have received a copy of the GNU Lesser General Public License
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick along with systemd; If not, see <http://www.gnu.org/licenses/>.
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick#define time_to_graph(t) ((t) * arg_scale_x)
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick#define kb_to_graph(m) ((m) * arg_scale_y * 0.0001)
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick#define to_color(n) (192.0 - ((n) * 192.0))
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiick#define svg(a...) do { snprintf(str, 8092, ## a); fputs(str, of); fflush(of); } while (0)
e2c5185af3c50d9510e5df68aa37abdc6c0d3aacChristopher Kiickstatic const char * const colorwheel[12] = {
static int pfiltered = 0;
static int pcount = 0;
static int kcount = 0;
static float psize = 0;
static float ksize = 0;
static float esize = 0;
static void svg_header(void) {
FILE *f;
time_t t;
int fd;
fclose(f);
fclose(f);
fclose(f);
cpu);
model);
cmdline);
build);
svg("<text class=\"sec\" x=\"20\" y=\"155\">Graph data: %.03f samples/sec, recorded %i total, dropped %i samples, %i processes, %i filtered</text>\n",
d - graph_start);
char *enc_name, *p;
if (!enc_name)
return NULL;
for (p = enc_name; *p; p++)
return enc_name;
static void svg_pss_graph(void) {
time_to_graph(.0),
kb_to_graph(i),
kb_to_graph(i));
int bottom;
int top;
bottom = 0;
top = 0;
if (!ps)
svg(" <rect class=\"clrw\" style=\"fill: %s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
if (!ps)
svg(" <rect class=\"clrw\" style=\"fill: %s\" x=\"%.03f\" y=\"%.03f\" width=\"%.03f\" height=\"%.03f\" />\n",
int bottom;
int top;
bottom = 0;
top = 0;
if (!ps)
if (!ps)
if (!ps)
if(!enc_name)
for (i = 0; i < samples ; i++) {
static void svg_io_bi_bar(void) {
double range;
int max_here = 0;
int start;
int stop;
double tot;
max_here = i;
int start;
int stop;
double tot;
double pbi;
if (i == max_here) {
static void svg_io_bo_bar(void) {
double range;
int max_here = 0;
int start;
int stop;
double tot;
max_here = i;
int start;
int stop;
double tot;
double pbo;
if (i == max_here) {
static void svg_cpu_bar(void) {
double trt;
double ptrt;
for (c = 0; c < cpus; c++)
static void svg_wait_bar(void) {
double twt;
double ptwt;
for (c = 0; c < cpus; c++)
static void svg_entropy_bar(void) {
if (!ps)
return ps;
return NULL;
if (!arg_filter)
int ret;
int usecs;
kcount = 0;
if (!count_only) {
kcount = 0;
while (!feof(f)) {
func[z] = 0;
if (count_only) {
kcount++;
func,
kcount++;
static void svg_ps_bars(void) {
int pid;
double starttime;
if(!enc_name)
ps_to_graph(j),
ps_to_graph(j),
svg(" <text x=\"%.03f\" y=\"%.03f\"><![CDATA[%s]]> [%i]<tspan class=\"run\">%.03fs</tspan></text>\n",
double crt;
double brt;
for (c = 0; c < cpus; c++)
idletime);
idletime);
static void svg_top_ten_cpu(void) {
static void svg_top_ten_pss(void) {
pcount++;
pfiltered++;
svg_header();
svg_cpu_bar();
svg_wait_bar();
if (kcount) {
svg_do_initcall(0);
svg_ps_bars();
if (arg_entropy) {
if (arg_pss) {
svg("<g transform=\"translate(10,%.03f)\">\n", 400.0 + (arg_scale_y * 28.0) + ksize + psize + esize);