2 * Copyright (C) 2012 Fusion-io
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef __IOWATCH_PLOT__
19 #define __IOWATCH_PLOT__
29 /* values for the plot direction field */
36 /* svg style y = 0 is the top of the graph */
39 /* abs coords of the start of X start of the plot */
46 * these two are for anyone that wants
47 * to add a plot after this one, it tells
48 * them how much space we took up
58 * timeline is a vertical line through line graphs that
59 * is used by the movie mode to show where in the graph
60 * our current frame lives
65 struct graph_line_pair {
70 struct graph_line_data {
71 /* beginning of an interval displayed by this graph */
72 unsigned int min_seconds;
74 /* end of an interval displayed by this graph */
75 unsigned int max_seconds;
77 unsigned int stop_seconds;
82 /* label for this graph */
84 struct graph_line_pair data[];
87 struct graph_dot_data {
97 /* in pixels, number of rows in our bitmap */
99 /* in pixels, number of cols in our bitmap */
102 /* beginning of an interval displayed by this graph */
105 /* end of an interval displayed by this graph */
106 unsigned int max_seconds;
107 unsigned int stop_seconds;
109 /* label for the legend */
112 /* color for plotting data */
115 /* bitmap, one bit for each cell to light up */
116 unsigned char data[];
119 struct pid_plot_history {
127 struct plot_history {
128 struct list_head list;
129 int pid_history_count;
131 struct pid_plot_history **read_pid_history;
132 struct pid_plot_history **write_pid_history;
135 char *pick_color(void);
136 char *pick_fio_color(void);
137 char *pick_cpu_color(void);
138 void reset_cpu_color(void);
139 int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd);
140 double line_graph_roll_avg_max(struct graph_line_data *gld);
141 int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2);
142 struct graph_line_data *alloc_line_data(unsigned int min_seconds, unsigned int max_seconds, unsigned int stop_seconds);
143 struct graph_dot_data *alloc_dot_data(unsigned int min_seconds, unsigned int max_seconds, u64 min_offset, u64 max_offset, unsigned int stop_seconds, char *color, char *label);
144 void set_gdd_bit(struct graph_dot_data *gdd, u64 offset, double bytes, double time);
145 void write_svg_header(int fd);
146 struct plot *alloc_plot(void);
147 int close_plot(struct plot *plot);
148 int close_plot_no_height(struct plot *plot);
149 void setup_axis(struct plot *plot);
150 void set_xticks(struct plot *plot, int num_ticks, int first, int last);
151 void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *units);
152 void set_plot_title(struct plot *plot, char *title);
153 void set_plot_label(struct plot *plot, char *label);
154 void set_xlabel(struct plot *plot, char *label);
155 void set_ylabel(struct plot *plot, char *label);
156 void scale_line_graph_bytes(u64 *max, char **units, u64 factor);
157 void scale_line_graph_time(u64 *max, char **units);
158 void write_drop_shadow_line(struct plot *plot);
159 void svg_write_legend(struct plot *plot);
160 void svg_add_legend(struct plot *plot, char *text, char *extra, char *color);
161 void svg_alloc_legend(struct plot *plot, int num_lines);
162 void set_legend_width(int longest_str);
163 void set_rolling_avg(int rolling);
164 void svg_free_legend(struct plot *plot);
165 void set_io_graph_scale(int scale);
166 void set_plot_output(struct plot *plot, char *filename);
167 void set_graph_size(int width, int height);
168 void get_graph_size(int *width, int *height);
169 int svg_io_graph_movie(struct graph_dot_data *gdd, struct pid_plot_history *ph, int col);
170 int svg_io_graph_movie_array(struct plot *plot, struct pid_plot_history *ph);
171 void svg_write_time_line(struct plot *plot, int col);
172 void set_graph_height(int h);
173 void set_graph_width(int w);
174 int close_plot_file(struct plot *plot);
175 int svg_io_graph_movie_array_spindle(struct plot *plot, struct pid_plot_history *ph);
176 void rewind_spindle_steps(int num);
177 void setup_axis_spindle(struct plot *plot);
178 int close_plot_col(struct plot *plot);