return __td_string_set(vlabel, length, _("Bits Per Second"));
}
+int td_graph_vlabel_bytes(td_ctx* ctx, td_graph* graph,
+ const td_graph_render_options* options, const char* object, char* vlabel, size_t length) {
+ return __td_string_set(vlabel, length, _("Bytes"));
+}
+
int td_graph_vlabel_days(td_ctx* ctx, td_graph* graph,
const td_graph_render_options* options, const char* object, char* vlabel, size_t length) {
return __td_string_set(vlabel, length, _("Days"));
int td_graph_vlabel_bps(td_ctx* ctx, td_graph* graph,
const td_graph_render_options* options, const char* object, char* vlabel, size_t length);
+int td_graph_vlabel_bytes(td_ctx* ctx, td_graph* graph,
+ const td_graph_render_options* options, const char* object, char* vlabel, size_t length);
+
int td_graph_vlabel_days(td_ctx* ctx, td_graph* graph,
const td_graph_render_options* options, const char* object, char* vlabel, size_t length);
&conntrack_graph,
&contextswitches_graph,
&cpufreq_graph,
- &disk_temp_graph,
&hostapd_station_bandwidth_graph,
&hostapd_station_rate_info_graph,
&hostapd_station_signal_graph,
&processor_graph,
&uptime_graph,
+ // Disk
+ &disk_io_graph,
+ &disk_temp_graph,
+
// Pressure (PSI)
&pressure_cpu_graph,
&pressure_io_graph,
#include "graph.h"
#include "disk.h"
+static int disk_io_title(td_ctx* ctx, td_graph* graph,
+ const char* object, char* title, size_t length) {
+ return __td_string_set(title, length, _("Disk Input/Output"));
+}
+
+static int disk_io_render(td_ctx* ctx, td_graph* graph,
+ const td_graph_render_options* options, td_args* args, const char* object) {
+ int r;
+
+ // Load all sources
+ r = td_graph_require_source(graph, args, "disk", object);
+ if (r < 0)
+ return r;
+
+ // Header
+ PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+ // Draw the temperature
+ DRAW_IO_SECTORS(args, object, "read_sectors", "write_sectors");
+
+ // XXX TODO Add discarded bytes
+
+ return 0;
+}
+
+const td_graph_impl disk_io_graph = {
+ .name = "DiskIO",
+ .render = disk_io_render,
+ .title = disk_io_title,
+ .vlabel = td_graph_vlabel_bytes,
+
+ // Limits
+ .lower_limit = 0,
+ .upper_limit = LONG_MAX,
+};
+
+
static int disk_temp_title(td_ctx* ctx, td_graph* graph,
const char* object, char* title, size_t length) {
return __td_string_set(title, length, _("Disk Temperature"));
#include "../graph.h"
+extern const td_graph_impl disk_io_graph;
extern const td_graph_impl disk_temp_graph;
#endif /* TELEMETRY_GRAPH_DISK_H */
#define SECONDS_HIGHRES "%%12.2lf%%ss"
#define SECONDS "%%13.2lfs"
+#define BYTES "%%12.2lf%%s%s", _("B")
+
// Temperatures
#define KELVIN "%%12.2lf K"
#define CELSIUS "%%11.2lf °C"
#define FIELD_INF(field) field "_inf"
#define FIELD_NEGINF(field) field "_neginf"
#define FIELD_BITS(field) field "_bits"
+#define FIELD_BYTES(field) field "_bytes"
#define FIELD_CELSIUS(field) field "_c"
#define FIELD_FAHRENHEIT(field) field "_f"
); \
} while (0)
+#define COMPUTE_BYTES_FROM_SECTORS(args, field, object) \
+ do { \
+ COMPUTE_CDEF(args, FIELD "=" FIELD ",512,*", \
+ FIELD_AND_OBJECT(FIELD_BYTES(field), object), \
+ FIELD_AND_OBJECT(field, object) \
+ ); \
+ VALUE_ALL(args, FIELD_BYTES(field), object); \
+ } while (0)
+
+/*
+ This draws an I/O graph
+*/
+#define DRAW_IO_SECTORS(args, object, read_sectors, write_sectors) \
+ do { \
+ COMPUTE_BYTES_FROM_SECTORS(args, read_sectors, object); \
+ COMPUTE_BYTES_FROM_SECTORS(args, write_sectors, object); \
+ DRAW_IO_BYTES(args, object, \
+ FIELD_BYTES(read_sectors), FIELD_BYTES(write_sectors)); \
+ } while (0)
+
+#define DRAW_IO_BYTES(args, object, read_bytes, write_bytes) \
+ do { \
+ DRAW_IO_BYTES_READ(args, object, read_bytes); \
+ DRAW_IO_BYTES_WRITTEN(args, object, write_bytes); \
+ } while (0)
+
+#define DRAW_IO_BYTES_READ(args, object, read_bytes) \
+ __DRAW_IO_BYTES(args, object, read_bytes, COLOR_RX, "%s", _("Bytes Read"))
+
+#define DRAW_IO_BYTES_WRITTEN(args, object, read_bytes) \
+ __DRAW_IO_BYTES(args, object, read_bytes, COLOR_TX, "%s", _("Bytes Written"))
+
+#define __DRAW_IO_BYTES(args, object, bytes, color, label, ...) \
+ do { \
+ DRAW_AREA_WITH_LABEL(args, bytes, object, color, 0, label, __VA_ARGS__); \
+ PRINT_CAMM(args, bytes, object, BYTES); \
+ } while (0)
+
/*
This draws a bandwidth graph
*/