diff options
Diffstat (limited to 'src/statistics/gnunet-statistics-gtk.c')
-rw-r--r-- | src/statistics/gnunet-statistics-gtk.c | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/src/statistics/gnunet-statistics-gtk.c b/src/statistics/gnunet-statistics-gtk.c index e73cd5e1..558e7baa 100644 --- a/src/statistics/gnunet-statistics-gtk.c +++ b/src/statistics/gnunet-statistics-gtk.c | |||
@@ -49,6 +49,11 @@ struct PlotInfo | |||
49 | const char *name; | 49 | const char *name; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Label to use in legend. | ||
53 | */ | ||
54 | const char *label; | ||
55 | |||
56 | /** | ||
52 | * Name of color to use when plotting. | 57 | * Name of color to use when plotting. |
53 | */ | 58 | */ |
54 | const char *color_name; | 59 | const char *color_name; |
@@ -58,7 +63,33 @@ struct PlotInfo | |||
58 | 63 | ||
59 | static const struct PlotInfo connection_data[] = | 64 | static const struct PlotInfo connection_data[] = |
60 | { | 65 | { |
61 | { "core", "entries in session map", "white" }, | 66 | { "fs", "# peers connected", "file-sharing connections", "blue" }, |
67 | { "core", "# entries in session map", "encrypted connections (core)", "green" }, | ||
68 | { "core", "# neighbour entries allocated", "transport connections (core)", "yellow" }, | ||
69 | { "transport", "# peers connected", "total connections (transport)", "orange" }, | ||
70 | { "transport", "# TCP sessions active", "tcp connections", "red" }, | ||
71 | { "peerinfo", "# peers known", "peers known", "brown" }, | ||
72 | { "nse", "# nodes in the network (estimate)", "network size (estimate)", "purple" }, | ||
73 | { NULL, NULL, NULL} | ||
74 | }; | ||
75 | |||
76 | |||
77 | static const struct PlotInfo traffic_data[] = | ||
78 | { | ||
79 | { "core", "# bytes encrypted", "bytes encrypted", "blue" }, | ||
80 | { "core", "# bytes decrypted", "bytes decrypted", "green" }, | ||
81 | { "transport", "# bytes received via TCP", "received via tcp", "yellow" }, | ||
82 | { "transport", "# bytes transmitted via TCP", "sent via tcp", "brown" }, | ||
83 | { NULL, NULL, NULL} | ||
84 | }; | ||
85 | |||
86 | |||
87 | static const struct PlotInfo storage_data[] = | ||
88 | { | ||
89 | { "datastore", "# quota", "datastore capacity", "blue" }, | ||
90 | { "datastore", "# bytes stored", "datastore utilization", "yellow" }, | ||
91 | { "datastore", "# cache size", "reservation for datastore cache", "green" }, | ||
92 | { "datastore", "# bytes purged (low-priority)", "discarded due to limited space", "red" }, | ||
62 | { NULL, NULL, NULL} | 93 | { NULL, NULL, NULL} |
63 | }; | 94 | }; |
64 | 95 | ||
@@ -83,6 +114,11 @@ static struct GNUNET_STATISTICS_Handle *statistics; | |||
83 | */ | 114 | */ |
84 | static GNUNET_SCHEDULER_TaskIdentifier connection_task; | 115 | static GNUNET_SCHEDULER_TaskIdentifier connection_task; |
85 | 116 | ||
117 | /** | ||
118 | * When did this process start? | ||
119 | */ | ||
120 | static struct GNUNET_TIME_Absolute start_time; | ||
121 | |||
86 | 122 | ||
87 | /** | 123 | /** |
88 | * Callback function to process statistic values. | 124 | * Callback function to process statistic values. |
@@ -103,8 +139,8 @@ process_value_update (void *cls, const char *subsystem, | |||
103 | 139 | ||
104 | gtk_statistics_update_value (stats, | 140 | gtk_statistics_update_value (stats, |
105 | name, | 141 | name, |
106 | value, | 142 | GNUNET_TIME_absolute_get_duration (start_time).rel_value / 1000LL, |
107 | GNUNET_TIME_absolute_get().abs_value); | 143 | value); |
108 | return GNUNET_OK; | 144 | return GNUNET_OK; |
109 | } | 145 | } |
110 | 146 | ||
@@ -128,17 +164,22 @@ get_object (const char *name) | |||
128 | * @param widget size and style information for the plot | 164 | * @param widget size and style information for the plot |
129 | * @param info what to draw | 165 | * @param info what to draw |
130 | */ | 166 | */ |
131 | /* static */ GtkStatistics * | 167 | static void |
132 | create_plot (const struct PlotInfo *info) | 168 | create_plot (const char *box_name, |
169 | const struct PlotInfo *info) | ||
133 | { | 170 | { |
171 | GtkBox *box; | ||
134 | GtkStatistics *ret; | 172 | GtkStatistics *ret; |
135 | unsigned int i; | 173 | unsigned int i; |
136 | 174 | ||
137 | ret = GTK_STATISTICS (gtk_statistics_new ()); | 175 | ret = GTK_STATISTICS (gtk_statistics_new ()); |
176 | box = GTK_BOX (get_object (box_name)); | ||
177 | |||
138 | for (i=0; NULL != info[i].subsystem; i++) | 178 | for (i=0; NULL != info[i].subsystem; i++) |
139 | { | 179 | { |
140 | gtk_statistics_add_line (ret, | 180 | gtk_statistics_add_line (ret, |
141 | info[i].name, | 181 | info[i].name, |
182 | info[i].label, | ||
142 | info[i].color_name); | 183 | info[i].color_name); |
143 | GNUNET_STATISTICS_watch (statistics, | 184 | GNUNET_STATISTICS_watch (statistics, |
144 | info[i].subsystem, | 185 | info[i].subsystem, |
@@ -146,7 +187,12 @@ create_plot (const struct PlotInfo *info) | |||
146 | &process_value_update, | 187 | &process_value_update, |
147 | ret); | 188 | ret); |
148 | } | 189 | } |
149 | return ret; | 190 | gtk_widget_show (GTK_WIDGET (ret)); |
191 | gtk_box_pack_start (box, | ||
192 | GTK_WIDGET (ret), | ||
193 | TRUE, | ||
194 | TRUE, | ||
195 | 0); | ||
150 | } | 196 | } |
151 | 197 | ||
152 | 198 | ||
@@ -209,6 +255,14 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
209 | GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), | 255 | GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), |
210 | "gnunet-gtk" /* FIXME: different icon? */ , | 256 | "gnunet-gtk" /* FIXME: different icon? */ , |
211 | "gnunet-statistics-gtk"); | 257 | "gnunet-statistics-gtk"); |
258 | |||
259 | create_plot ("GNUNET_STATISTICS_GTK_connectivity_box", | ||
260 | connection_data); | ||
261 | create_plot ("GNUNET_STATISTICS_GTK_traffic_box", | ||
262 | traffic_data); | ||
263 | create_plot ("GNUNET_STATISTICS_GTK_storage_box", | ||
264 | storage_data); | ||
265 | |||
212 | /* make GUI visible */ | 266 | /* make GUI visible */ |
213 | if (!tray_only) | 267 | if (!tray_only) |
214 | { | 268 | { |
@@ -228,6 +282,7 @@ main (int argc, char *const *argv) | |||
228 | GNUNET_GETOPT_OPTION_END | 282 | GNUNET_GETOPT_OPTION_END |
229 | }; | 283 | }; |
230 | 284 | ||
285 | start_time = GNUNET_TIME_absolute_get (); | ||
231 | if (GNUNET_OK != | 286 | if (GNUNET_OK != |
232 | GNUNET_GTK_main_loop_start ("gnunet-statistics-gtk", | 287 | GNUNET_GTK_main_loop_start ("gnunet-statistics-gtk", |
233 | "GTK GUI for viewing GNUnet statistics", argc, | 288 | "GTK GUI for viewing GNUnet statistics", argc, |