aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/gnunet-statistics-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/gnunet-statistics-gtk.c')
-rw-r--r--src/statistics/gnunet-statistics-gtk.c112
1 files changed, 49 insertions, 63 deletions
diff --git a/src/statistics/gnunet-statistics-gtk.c b/src/statistics/gnunet-statistics-gtk.c
index e2115615..3055c4aa 100644
--- a/src/statistics/gnunet-statistics-gtk.c
+++ b/src/statistics/gnunet-statistics-gtk.c
@@ -57,41 +57,42 @@ struct PlotInfo
57 * Name of color to use when plotting. 57 * Name of color to use when plotting.
58 */ 58 */
59 const char *color_name; 59 const char *color_name;
60 60
61}; 61};
62 62
63 63
64static const struct PlotInfo connection_data[] = 64static const struct PlotInfo connection_data[] = {
65 { 65 {"fs", "# peers connected", "file-sharing connections", "blue"},
66 { "fs", "# peers connected", "file-sharing connections", "blue" }, 66 {"core", "# entries in session map", "encrypted connections (core)", "green"},
67 { "core", "# entries in session map", "encrypted connections (core)", "green" }, 67 {"core", "# neighbour entries allocated", "transport connections (core)",
68 { "core", "# neighbour entries allocated", "transport connections (core)", "yellow" }, 68 "yellow"},
69 { "transport", "# peers connected", "total connections (transport)", "orange" }, 69 {"transport", "# peers connected", "total connections (transport)", "orange"},
70 { "transport", "# TCP sessions active", "tcp connections", "red" }, 70 {"transport", "# TCP sessions active", "tcp connections", "red"},
71 { "peerinfo", "# peers known", "peers known", "brown" }, 71 {"peerinfo", "# peers known", "peers known", "brown"},
72 { "nse", "# nodes in the network (estimate)", "network size (estimate)", "purple" }, 72 {"nse", "# nodes in the network (estimate)", "network size (estimate)",
73 { NULL, NULL, NULL} 73 "purple"},
74 }; 74 {NULL, NULL, NULL}
75};
75 76
76 77
77static const struct PlotInfo traffic_data[] = 78static const struct PlotInfo traffic_data[] = {
78 { 79 {"core", "# bytes encrypted", "bytes encrypted", "blue"},
79 { "core", "# bytes encrypted", "bytes encrypted", "blue" }, 80 {"core", "# bytes decrypted", "bytes decrypted", "green"},
80 { "core", "# bytes decrypted", "bytes decrypted", "green" }, 81 {"transport", "# bytes received via TCP", "received via tcp", "yellow"},
81 { "transport", "# bytes received via TCP", "received via tcp", "yellow" }, 82 {"transport", "# bytes transmitted via TCP", "sent via tcp", "brown"},
82 { "transport", "# bytes transmitted via TCP", "sent via tcp", "brown" }, 83 {NULL, NULL, NULL}
83 { NULL, NULL, NULL} 84};
84 };
85 85
86 86
87static const struct PlotInfo storage_data[] = 87static const struct PlotInfo storage_data[] = {
88 { 88 {"datastore", "# quota", "datastore capacity", "blue"},
89 { "datastore", "# quota", "datastore capacity", "blue" }, 89 {"datastore", "# utilization by current datastore", "datastore utilization",
90 { "datastore", "# utilization by current datastore", "datastore utilization", "yellow" }, 90 "yellow"},
91 { "datastore", "# cache size", "reservation for datastore cache", "green" }, 91 {"datastore", "# cache size", "reservation for datastore cache", "green"},
92 { "datastore", "# bytes purged (low-priority)", "discarded due to limited space", "red" }, 92 {"datastore", "# bytes purged (low-priority)",
93 { NULL, NULL, NULL} 93 "discarded due to limited space", "red"},
94 }; 94 {NULL, NULL, NULL}
95};
95 96
96 97
97/** 98/**
@@ -130,19 +131,17 @@ static struct GNUNET_TIME_Absolute start_time;
130 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not 131 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
131 * @return GNUNET_OK to continue 132 * @return GNUNET_OK to continue
132 */ 133 */
133static int 134static int
134process_value_update (void *cls, const char *subsystem, 135process_value_update (void *cls, const char *subsystem, const char *name,
135 const char *name, uint64_t value, 136 uint64_t value, int is_persistent)
136 int is_persistent)
137{ 137{
138 GtkStatistics *stats = cls; 138 GtkStatistics *stats = cls;
139 char *id; 139 char *id;
140 140
141 GNUNET_asprintf (&id, "%s: %s", subsystem, name); 141 GNUNET_asprintf (&id, "%s: %s", subsystem, name);
142 gtk_statistics_update_value (stats, 142 gtk_statistics_update_value (stats, id,
143 id, 143 GNUNET_TIME_absolute_get_duration
144 GNUNET_TIME_absolute_get_duration (start_time).rel_value / 1000LL, 144 (start_time).rel_value / 1000LL, value);
145 value);
146 GNUNET_free (id); 145 GNUNET_free (id);
147 return GNUNET_OK; 146 return GNUNET_OK;
148} 147}
@@ -168,8 +167,7 @@ get_object (const char *name)
168 * @param info what to draw 167 * @param info what to draw
169 */ 168 */
170static void 169static void
171create_plot (const char *box_name, 170create_plot (const char *box_name, const struct PlotInfo *info)
172 const struct PlotInfo *info)
173{ 171{
174 GtkBox *box; 172 GtkBox *box;
175 GtkStatistics *ret; 173 GtkStatistics *ret;
@@ -178,27 +176,17 @@ create_plot (const char *box_name,
178 176
179 ret = GTK_STATISTICS (gtk_statistics_new ()); 177 ret = GTK_STATISTICS (gtk_statistics_new ());
180 box = GTK_BOX (get_object (box_name)); 178 box = GTK_BOX (get_object (box_name));
181 179
182 for (i=0; NULL != info[i].subsystem; i++) 180 for (i = 0; NULL != info[i].subsystem; i++)
183 { 181 {
184 GNUNET_asprintf (&id, "%s: %s", info[i].subsystem, info[i].name); 182 GNUNET_asprintf (&id, "%s: %s", info[i].subsystem, info[i].name);
185 gtk_statistics_add_line (ret, 183 gtk_statistics_add_line (ret, id, info[i].label, info[i].color_name);
186 id,
187 info[i].label,
188 info[i].color_name);
189 GNUNET_free (id); 184 GNUNET_free (id);
190 GNUNET_STATISTICS_watch (statistics, 185 GNUNET_STATISTICS_watch (statistics, info[i].subsystem, info[i].name,
191 info[i].subsystem, 186 &process_value_update, ret);
192 info[i].name,
193 &process_value_update,
194 ret);
195 } 187 }
196 gtk_widget_show (GTK_WIDGET (ret)); 188 gtk_widget_show (GTK_WIDGET (ret));
197 gtk_box_pack_start (box, 189 gtk_box_pack_start (box, GTK_WIDGET (ret), TRUE, TRUE, 0);
198 GTK_WIDGET (ret),
199 TRUE,
200 TRUE,
201 0);
202} 190}
203 191
204 192
@@ -253,12 +241,13 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
253 GtkWidget *main_window; 241 GtkWidget *main_window;
254 242
255 ml = cls; 243 ml = cls;
256 statistics = GNUNET_STATISTICS_create ("gnunet-statistics-gtk", 244 statistics =
257 GNUNET_GTK_main_loop_get_configuration (ml)); 245 GNUNET_STATISTICS_create ("gnunet-statistics-gtk",
246 GNUNET_GTK_main_loop_get_configuration (ml));
258 if (NULL == statistics) 247 if (NULL == statistics)
259 { 248 {
260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
261 _("Failed to initiate connection with statistics service\n")); 250 _("Failed to initiate connection with statistics service\n"));
262 return; 251 return;
263 } 252 }
264 GNUNET_GTK_set_icon_search_path (); 253 GNUNET_GTK_set_icon_search_path ();
@@ -271,12 +260,9 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
271 "gnunet-gtk" /* FIXME: different icon? */ , 260 "gnunet-gtk" /* FIXME: different icon? */ ,
272 "gnunet-statistics-gtk"); 261 "gnunet-statistics-gtk");
273 262
274 create_plot ("GNUNET_STATISTICS_GTK_connectivity_box", 263 create_plot ("GNUNET_STATISTICS_GTK_connectivity_box", connection_data);
275 connection_data); 264 create_plot ("GNUNET_STATISTICS_GTK_traffic_box", traffic_data);
276 create_plot ("GNUNET_STATISTICS_GTK_traffic_box", 265 create_plot ("GNUNET_STATISTICS_GTK_storage_box", storage_data);
277 traffic_data);
278 create_plot ("GNUNET_STATISTICS_GTK_storage_box",
279 storage_data);
280 266
281 /* make GUI visible */ 267 /* make GUI visible */
282 if (!tray_only) 268 if (!tray_only)