Commit | Line | Data |
---|---|---|
9e066e23 CM |
1 | /* |
2 | * Copyright (C) 2012 Fusion-io | |
3 | * | |
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. | |
7 | * | |
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. | |
12 | * | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | * | |
17 | */ | |
18 | #ifndef __IOWATCH_PLOT__ | |
19 | #define __IOWATCH_PLOT__ | |
20 | #define MAX_TICKS 10 | |
21 | ||
ba758825 CM |
22 | #include "list.h" |
23 | ||
9e066e23 CM |
24 | typedef __u64 u64; |
25 | typedef __u32 u32; | |
26 | typedef __u16 u16; | |
27 | ||
ba758825 | 28 | |
9e066e23 CM |
29 | struct plot { |
30 | int fd; | |
31 | ||
32 | /* svg style y = 0 is the top of the graph */ | |
33 | int start_y_offset; | |
34 | ||
35 | /* abs coords of the start of X start of the plot */ | |
36 | int start_x_offset; | |
37 | ||
38 | int add_xlabel; | |
39 | ||
40 | /* | |
41 | * these two are for anyone that wants | |
42 | * to add a plot after this one, it tells | |
43 | * them how much space we took up | |
44 | */ | |
45 | int total_height; | |
46 | int total_width; | |
47 | char **legend_lines; | |
48 | int legend_index; | |
49 | int num_legend_lines; | |
50 | }; | |
51 | ||
52 | struct graph_line_pair { | |
53 | u64 count; | |
54 | u64 sum; | |
55 | }; | |
56 | ||
57 | struct graph_line_data { | |
58 | /* total number of seconds in this graph */ | |
59 | int seconds; | |
60 | ||
61 | int stop_seconds; | |
62 | ||
63 | /* Y max */ | |
64 | u64 max; | |
65 | ||
66 | /* label for this graph */ | |
67 | char *label; | |
68 | struct graph_line_pair data[]; | |
69 | }; | |
70 | ||
71 | struct graph_dot_data { | |
72 | u64 max_offset; | |
bfb0e441 CM |
73 | u64 max_bank; |
74 | u64 max_bank_offset; | |
9e066e23 | 75 | u64 total_ios; |
bfb0e441 CM |
76 | u64 total_bank_ios; |
77 | ||
78 | int add_bank_ios; | |
9e066e23 CM |
79 | |
80 | /* in pixels, number of rows in our bitmap */ | |
81 | int rows; | |
82 | /* in pixels, number of cols in our bitmap */ | |
83 | int cols; | |
84 | ||
85 | /* total number of seconds in this graph */ | |
86 | int seconds; | |
87 | int stop_seconds; | |
88 | ||
89 | /* label for the legend */ | |
90 | char *label; | |
91 | ||
92 | /* bitmap, one bit for each cell to light up */ | |
93 | unsigned char data[]; | |
94 | }; | |
95 | ||
ba758825 CM |
96 | struct plot_history { |
97 | struct list_head list; | |
abf08f96 | 98 | double history_max; |
ba758825 CM |
99 | int history_len; |
100 | int num_used; | |
101 | int col; | |
102 | char *color; | |
103 | double *history; | |
104 | }; | |
105 | ||
9e066e23 | 106 | int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd, char *color); |
bfb0e441 | 107 | int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2); |
9e066e23 CM |
108 | struct graph_line_data *alloc_line_data(int seconds, int stop_seconds); |
109 | void free_line_data(struct graph_line_data *gld); | |
110 | struct graph_dot_data *alloc_dot_data(int seconds, u64 max_offset, int stop_seconds); | |
111 | void free_dot_data(struct graph_dot_data *gdd); | |
ba758825 | 112 | void set_gdd_bit(struct graph_dot_data *gdd, u64 offset, double bytes, double time); |
9e066e23 CM |
113 | void print_gdd(struct graph_dot_data *gdd); |
114 | void write_svg_header(int fd); | |
ba758825 | 115 | struct plot *alloc_plot(void); |
9e066e23 CM |
116 | int close_plot(struct plot *plot); |
117 | void setup_axis(struct plot *plot); | |
118 | void set_xticks(struct plot *plot, int num_ticks, int first, int last); | |
119 | void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *units); | |
120 | void set_plot_title(struct plot *plot, char *title); | |
121 | void set_plot_label(struct plot *plot, char *label); | |
122 | void set_xlabel(struct plot *plot, char *label); | |
123 | void set_ylabel(struct plot *plot, char *label); | |
124 | void scale_line_graph_bytes(u64 *max, char **units, u64 factor); | |
125 | void scale_line_graph_time(u64 *max, char **units); | |
126 | void write_drop_shadow(struct plot *plot); | |
127 | void write_drop_shadow_line(struct plot *plot); | |
128 | void svg_write_legend(struct plot *plot); | |
129 | void svg_add_legend(struct plot *plot, char *text, char *extra, char *color); | |
130 | void svg_alloc_legend(struct plot *plot, int num_lines); | |
131 | void set_legend_width(int longest_str); | |
132 | void set_rolling_avg(int rolling); | |
e199d546 | 133 | void svg_free_legend(struct plot *plot); |
ba758825 CM |
134 | void set_io_graph_scale(int scale); |
135 | void set_plot_output(struct plot *plot, char *filename); | |
136 | void set_graph_size(int width, int height); | |
137 | void get_graph_size(int *width, int *height); | |
138 | int svg_io_graph_movie(struct graph_dot_data *gdd, struct plot_history *ph, int col); | |
abf08f96 | 139 | int svg_io_graph_movie_array(struct plot *plot, struct plot_history *ph); |
ba758825 CM |
140 | void svg_write_time_line(struct plot *plot, int col); |
141 | void set_graph_height(int h); | |
142 | void set_graph_width(int w); | |
abf08f96 CM |
143 | int close_plot_file(struct plot *plot); |
144 | int svg_io_graph_movie_array_spindle(struct plot *plot, struct plot_history *ph); | |
145 | void rewind_spindle_steps(int num); | |
146 | void setup_axis_spindle(struct plot *plot); | |
9e066e23 | 147 | #endif |