system-io.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_SYSTEM_IO_H
  3. #define NETDATA_SYSTEM_IO_H
  4. #include "common-contexts.h"
  5. static inline void common_system_io(uint64_t read_bytes, uint64_t write_bytes, int update_every) {
  6. static RRDSET *st_io = NULL;
  7. static RRDDIM *rd_in = NULL, *rd_out = NULL;
  8. if(unlikely(!st_io)) {
  9. st_io = rrdset_create_localhost(
  10. "system"
  11. , "io"
  12. , NULL
  13. , "disk"
  14. , NULL
  15. , "Disk I/O"
  16. , "KiB/s"
  17. , _COMMON_PLUGIN_NAME
  18. , _COMMON_PLUGIN_MODULE_NAME
  19. , NETDATA_CHART_PRIO_SYSTEM_IO
  20. , update_every
  21. , RRDSET_TYPE_AREA
  22. );
  23. rd_in = rrddim_add(st_io, "in", "reads", 1, 1024, RRD_ALGORITHM_INCREMENTAL);
  24. rd_out = rrddim_add(st_io, "out", "writes", -1, 1024, RRD_ALGORITHM_INCREMENTAL);
  25. }
  26. // this always have to be in base units, so that exporting sends base units to other time-series db
  27. rrddim_set_by_pointer(st_io, rd_in, (collected_number)read_bytes);
  28. rrddim_set_by_pointer(st_io, rd_out, (collected_number)write_bytes);
  29. rrdset_done(st_io);
  30. }
  31. #endif //NETDATA_SYSTEM_IO_H