zfs_common.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "zfs_common.h"
  3. struct arcstats arcstats = { 0 };
  4. void generate_charts_arcstats(const char *plugin, const char *module, int update_every) {
  5. // ARC reads
  6. unsigned long long aread = arcstats.hits + arcstats.misses;
  7. // Demand reads
  8. unsigned long long dhit = arcstats.demand_data_hits + arcstats.demand_metadata_hits;
  9. unsigned long long dmiss = arcstats.demand_data_misses + arcstats.demand_metadata_misses;
  10. unsigned long long dread = dhit + dmiss;
  11. // Prefetch reads
  12. unsigned long long phit = arcstats.prefetch_data_hits + arcstats.prefetch_metadata_hits;
  13. unsigned long long pmiss = arcstats.prefetch_data_misses + arcstats.prefetch_metadata_misses;
  14. unsigned long long pread = phit + pmiss;
  15. // Metadata reads
  16. unsigned long long mhit = arcstats.prefetch_metadata_hits + arcstats.demand_metadata_hits;
  17. unsigned long long mmiss = arcstats.prefetch_metadata_misses + arcstats.demand_metadata_misses;
  18. unsigned long long mread = mhit + mmiss;
  19. // l2 reads
  20. unsigned long long l2hit = arcstats.l2_hits;
  21. unsigned long long l2miss = arcstats.l2_misses;
  22. unsigned long long l2read = l2hit + l2miss;
  23. // --------------------------------------------------------------------
  24. {
  25. static RRDSET *st_arc_size = NULL;
  26. static RRDDIM *rd_arc_size = NULL;
  27. static RRDDIM *rd_arc_target_size = NULL;
  28. static RRDDIM *rd_arc_target_min_size = NULL;
  29. static RRDDIM *rd_arc_target_max_size = NULL;
  30. if (unlikely(!st_arc_size)) {
  31. st_arc_size = rrdset_create_localhost(
  32. "zfs"
  33. , "arc_size"
  34. , NULL
  35. , ZFS_FAMILY_SIZE
  36. , NULL
  37. , "ZFS ARC Size"
  38. , "MB"
  39. , plugin
  40. , module
  41. , NETDATA_CHART_PRIO_ZFS_ARC_SIZE
  42. , update_every
  43. , RRDSET_TYPE_AREA
  44. );
  45. rd_arc_size = rrddim_add(st_arc_size, "size", "arcsz", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  46. rd_arc_target_size = rrddim_add(st_arc_size, "target", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  47. rd_arc_target_min_size = rrddim_add(st_arc_size, "min", "min (hard limit)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  48. rd_arc_target_max_size = rrddim_add(st_arc_size, "max", "max (high water)", 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  49. }
  50. else
  51. rrdset_next(st_arc_size);
  52. rrddim_set_by_pointer(st_arc_size, rd_arc_size, arcstats.size);
  53. rrddim_set_by_pointer(st_arc_size, rd_arc_target_size, arcstats.c);
  54. rrddim_set_by_pointer(st_arc_size, rd_arc_target_min_size, arcstats.c_min);
  55. rrddim_set_by_pointer(st_arc_size, rd_arc_target_max_size, arcstats.c_max);
  56. rrdset_done(st_arc_size);
  57. }
  58. // --------------------------------------------------------------------
  59. if(likely(arcstats.l2exist)) {
  60. static RRDSET *st_l2_size = NULL;
  61. static RRDDIM *rd_l2_size = NULL;
  62. static RRDDIM *rd_l2_asize = NULL;
  63. if (unlikely(!st_l2_size)) {
  64. st_l2_size = rrdset_create_localhost(
  65. "zfs"
  66. , "l2_size"
  67. , NULL
  68. , ZFS_FAMILY_SIZE
  69. , NULL
  70. , "ZFS L2 ARC Size"
  71. , "MB"
  72. , plugin
  73. , module
  74. , NETDATA_CHART_PRIO_ZFS_L2_SIZE
  75. , update_every
  76. , RRDSET_TYPE_AREA
  77. );
  78. rd_l2_asize = rrddim_add(st_l2_size, "actual", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  79. rd_l2_size = rrddim_add(st_l2_size, "size", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
  80. }
  81. else
  82. rrdset_next(st_l2_size);
  83. rrddim_set_by_pointer(st_l2_size, rd_l2_size, arcstats.l2_size);
  84. rrddim_set_by_pointer(st_l2_size, rd_l2_asize, arcstats.l2_asize);
  85. rrdset_done(st_l2_size);
  86. }
  87. // --------------------------------------------------------------------
  88. {
  89. static RRDSET *st_reads = NULL;
  90. static RRDDIM *rd_aread = NULL;
  91. static RRDDIM *rd_dread = NULL;
  92. static RRDDIM *rd_pread = NULL;
  93. static RRDDIM *rd_mread = NULL;
  94. static RRDDIM *rd_l2read = NULL;
  95. if (unlikely(!st_reads)) {
  96. st_reads = rrdset_create_localhost(
  97. "zfs"
  98. , "reads"
  99. , NULL
  100. , ZFS_FAMILY_ACCESSES
  101. , NULL
  102. , "ZFS Reads"
  103. , "reads/s"
  104. , plugin
  105. , module
  106. , NETDATA_CHART_PRIO_ZFS_READS
  107. , update_every
  108. , RRDSET_TYPE_AREA
  109. );
  110. rd_aread = rrddim_add(st_reads, "areads", "arc", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  111. rd_dread = rrddim_add(st_reads, "dreads", "demand", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  112. rd_pread = rrddim_add(st_reads, "preads", "prefetch", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  113. rd_mread = rrddim_add(st_reads, "mreads", "metadata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  114. if(arcstats.l2exist)
  115. rd_l2read = rrddim_add(st_reads, "l2reads", "l2", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  116. }
  117. else
  118. rrdset_next(st_reads);
  119. rrddim_set_by_pointer(st_reads, rd_aread, aread);
  120. rrddim_set_by_pointer(st_reads, rd_dread, dread);
  121. rrddim_set_by_pointer(st_reads, rd_pread, pread);
  122. rrddim_set_by_pointer(st_reads, rd_mread, mread);
  123. if(arcstats.l2exist)
  124. rrddim_set_by_pointer(st_reads, rd_l2read, l2read);
  125. rrdset_done(st_reads);
  126. }
  127. // --------------------------------------------------------------------
  128. if(likely(arcstats.l2exist)) {
  129. static RRDSET *st_l2bytes = NULL;
  130. static RRDDIM *rd_l2_read_bytes = NULL;
  131. static RRDDIM *rd_l2_write_bytes = NULL;
  132. if (unlikely(!st_l2bytes)) {
  133. st_l2bytes = rrdset_create_localhost(
  134. "zfs"
  135. , "bytes"
  136. , NULL
  137. , ZFS_FAMILY_ACCESSES
  138. , NULL
  139. , "ZFS ARC L2 Read/Write Rate"
  140. , "kilobytes/s"
  141. , plugin
  142. , module
  143. , NETDATA_CHART_PRIO_ZFS_IO
  144. , update_every
  145. , RRDSET_TYPE_AREA
  146. );
  147. rd_l2_read_bytes = rrddim_add(st_l2bytes, "read", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL);
  148. rd_l2_write_bytes = rrddim_add(st_l2bytes, "write", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL);
  149. }
  150. else
  151. rrdset_next(st_l2bytes);
  152. rrddim_set_by_pointer(st_l2bytes, rd_l2_read_bytes, arcstats.l2_read_bytes);
  153. rrddim_set_by_pointer(st_l2bytes, rd_l2_write_bytes, arcstats.l2_write_bytes);
  154. rrdset_done(st_l2bytes);
  155. }
  156. // --------------------------------------------------------------------
  157. {
  158. static RRDSET *st_ahits = NULL;
  159. static RRDDIM *rd_ahits = NULL;
  160. static RRDDIM *rd_amisses = NULL;
  161. if (unlikely(!st_ahits)) {
  162. st_ahits = rrdset_create_localhost(
  163. "zfs"
  164. , "hits"
  165. , NULL
  166. , ZFS_FAMILY_EFFICIENCY
  167. , NULL
  168. , "ZFS ARC Hits"
  169. , "percentage"
  170. , plugin
  171. , module
  172. , NETDATA_CHART_PRIO_ZFS_HITS
  173. , update_every
  174. , RRDSET_TYPE_STACKED
  175. );
  176. rd_ahits = rrddim_add(st_ahits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  177. rd_amisses = rrddim_add(st_ahits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  178. }
  179. else
  180. rrdset_next(st_ahits);
  181. rrddim_set_by_pointer(st_ahits, rd_ahits, arcstats.hits);
  182. rrddim_set_by_pointer(st_ahits, rd_amisses, arcstats.misses);
  183. rrdset_done(st_ahits);
  184. }
  185. // --------------------------------------------------------------------
  186. {
  187. static RRDSET *st_dhits = NULL;
  188. static RRDDIM *rd_dhits = NULL;
  189. static RRDDIM *rd_dmisses = NULL;
  190. if (unlikely(!st_dhits)) {
  191. st_dhits = rrdset_create_localhost(
  192. "zfs"
  193. , "dhits"
  194. , NULL
  195. , ZFS_FAMILY_EFFICIENCY
  196. , NULL
  197. , "ZFS Demand Hits"
  198. , "percentage"
  199. , plugin
  200. , module
  201. , NETDATA_CHART_PRIO_ZFS_DHITS
  202. , update_every
  203. , RRDSET_TYPE_STACKED
  204. );
  205. rd_dhits = rrddim_add(st_dhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  206. rd_dmisses = rrddim_add(st_dhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  207. }
  208. else
  209. rrdset_next(st_dhits);
  210. rrddim_set_by_pointer(st_dhits, rd_dhits, dhit);
  211. rrddim_set_by_pointer(st_dhits, rd_dmisses, dmiss);
  212. rrdset_done(st_dhits);
  213. }
  214. // --------------------------------------------------------------------
  215. {
  216. static RRDSET *st_phits = NULL;
  217. static RRDDIM *rd_phits = NULL;
  218. static RRDDIM *rd_pmisses = NULL;
  219. if (unlikely(!st_phits)) {
  220. st_phits = rrdset_create_localhost(
  221. "zfs"
  222. , "phits"
  223. , NULL
  224. , ZFS_FAMILY_EFFICIENCY
  225. , NULL
  226. , "ZFS Prefetch Hits"
  227. , "percentage"
  228. , plugin
  229. , module
  230. , NETDATA_CHART_PRIO_ZFS_PHITS
  231. , update_every
  232. , RRDSET_TYPE_STACKED
  233. );
  234. rd_phits = rrddim_add(st_phits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  235. rd_pmisses = rrddim_add(st_phits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  236. }
  237. else
  238. rrdset_next(st_phits);
  239. rrddim_set_by_pointer(st_phits, rd_phits, phit);
  240. rrddim_set_by_pointer(st_phits, rd_pmisses, pmiss);
  241. rrdset_done(st_phits);
  242. }
  243. // --------------------------------------------------------------------
  244. {
  245. static RRDSET *st_mhits = NULL;
  246. static RRDDIM *rd_mhits = NULL;
  247. static RRDDIM *rd_mmisses = NULL;
  248. if (unlikely(!st_mhits)) {
  249. st_mhits = rrdset_create_localhost(
  250. "zfs"
  251. , "mhits"
  252. , NULL
  253. , ZFS_FAMILY_EFFICIENCY
  254. , NULL
  255. , "ZFS Metadata Hits"
  256. , "percentage"
  257. , plugin
  258. , module
  259. , NETDATA_CHART_PRIO_ZFS_MHITS
  260. , update_every
  261. , RRDSET_TYPE_STACKED
  262. );
  263. rd_mhits = rrddim_add(st_mhits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  264. rd_mmisses = rrddim_add(st_mhits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  265. }
  266. else
  267. rrdset_next(st_mhits);
  268. rrddim_set_by_pointer(st_mhits, rd_mhits, mhit);
  269. rrddim_set_by_pointer(st_mhits, rd_mmisses, mmiss);
  270. rrdset_done(st_mhits);
  271. }
  272. // --------------------------------------------------------------------
  273. if(likely(arcstats.l2exist)) {
  274. static RRDSET *st_l2hits = NULL;
  275. static RRDDIM *rd_l2hits = NULL;
  276. static RRDDIM *rd_l2misses = NULL;
  277. if (unlikely(!st_l2hits)) {
  278. st_l2hits = rrdset_create_localhost(
  279. "zfs"
  280. , "l2hits"
  281. , NULL
  282. , ZFS_FAMILY_EFFICIENCY
  283. , NULL
  284. , "ZFS L2 Hits"
  285. , "percentage"
  286. , plugin
  287. , module
  288. , NETDATA_CHART_PRIO_ZFS_L2HITS
  289. , update_every
  290. , RRDSET_TYPE_STACKED
  291. );
  292. rd_l2hits = rrddim_add(st_l2hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  293. rd_l2misses = rrddim_add(st_l2hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  294. }
  295. else
  296. rrdset_next(st_l2hits);
  297. rrddim_set_by_pointer(st_l2hits, rd_l2hits, l2hit);
  298. rrddim_set_by_pointer(st_l2hits, rd_l2misses, l2miss);
  299. rrdset_done(st_l2hits);
  300. }
  301. // --------------------------------------------------------------------
  302. {
  303. static RRDSET *st_list_hits = NULL;
  304. static RRDDIM *rd_mfu = NULL;
  305. static RRDDIM *rd_mru = NULL;
  306. static RRDDIM *rd_mfug = NULL;
  307. static RRDDIM *rd_mrug = NULL;
  308. if (unlikely(!st_list_hits)) {
  309. st_list_hits = rrdset_create_localhost(
  310. "zfs"
  311. , "list_hits"
  312. , NULL
  313. , ZFS_FAMILY_EFFICIENCY
  314. , NULL
  315. , "ZFS List Hits"
  316. , "hits/s"
  317. , plugin
  318. , module
  319. , NETDATA_CHART_PRIO_ZFS_LIST_HITS
  320. , update_every
  321. , RRDSET_TYPE_AREA
  322. );
  323. rd_mfu = rrddim_add(st_list_hits, "mfu", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  324. rd_mfug = rrddim_add(st_list_hits, "mfug", "mfu ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  325. rd_mru = rrddim_add(st_list_hits, "mru", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  326. rd_mrug = rrddim_add(st_list_hits, "mrug", "mru ghost", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  327. }
  328. else
  329. rrdset_next(st_list_hits);
  330. rrddim_set_by_pointer(st_list_hits, rd_mfu, arcstats.mfu_hits);
  331. rrddim_set_by_pointer(st_list_hits, rd_mru, arcstats.mru_hits);
  332. rrddim_set_by_pointer(st_list_hits, rd_mfug, arcstats.mfu_ghost_hits);
  333. rrddim_set_by_pointer(st_list_hits, rd_mrug, arcstats.mru_ghost_hits);
  334. rrdset_done(st_list_hits);
  335. }
  336. }
  337. void generate_charts_arc_summary(const char *plugin, const char *module, int update_every) {
  338. unsigned long long arc_accesses_total = arcstats.hits + arcstats.misses;
  339. unsigned long long real_hits = arcstats.mfu_hits + arcstats.mru_hits;
  340. unsigned long long real_misses = arc_accesses_total - real_hits;
  341. //unsigned long long anon_hits = arcstats.hits - (arcstats.mfu_hits + arcstats.mru_hits + arcstats.mfu_ghost_hits + arcstats.mru_ghost_hits);
  342. unsigned long long arc_size = arcstats.size;
  343. unsigned long long mru_size = arcstats.p;
  344. //unsigned long long target_min_size = arcstats.c_min;
  345. //unsigned long long target_max_size = arcstats.c_max;
  346. unsigned long long target_size = arcstats.c;
  347. //unsigned long long target_size_ratio = (target_max_size / target_min_size);
  348. unsigned long long mfu_size;
  349. if(arc_size > target_size)
  350. mfu_size = arc_size - mru_size;
  351. else
  352. mfu_size = target_size - mru_size;
  353. // --------------------------------------------------------------------
  354. {
  355. static RRDSET *st_arc_size_breakdown = NULL;
  356. static RRDDIM *rd_most_recent = NULL;
  357. static RRDDIM *rd_most_frequent = NULL;
  358. if (unlikely(!st_arc_size_breakdown)) {
  359. st_arc_size_breakdown = rrdset_create_localhost(
  360. "zfs"
  361. , "arc_size_breakdown"
  362. , NULL
  363. , ZFS_FAMILY_EFFICIENCY
  364. , NULL
  365. , "ZFS ARC Size Breakdown"
  366. , "percentage"
  367. , plugin
  368. , module
  369. , NETDATA_CHART_PRIO_ZFS_ARC_SIZE_BREAKDOWN
  370. , update_every
  371. , RRDSET_TYPE_STACKED
  372. );
  373. rd_most_recent = rrddim_add(st_arc_size_breakdown, "recent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
  374. rd_most_frequent = rrddim_add(st_arc_size_breakdown, "frequent", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_ROW_TOTAL);
  375. }
  376. else
  377. rrdset_next(st_arc_size_breakdown);
  378. rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_recent, mru_size);
  379. rrddim_set_by_pointer(st_arc_size_breakdown, rd_most_frequent, mfu_size);
  380. rrdset_done(st_arc_size_breakdown);
  381. }
  382. // --------------------------------------------------------------------
  383. {
  384. static RRDSET *st_memory = NULL;
  385. #ifndef __FreeBSD__
  386. static RRDDIM *rd_direct = NULL;
  387. #endif
  388. static RRDDIM *rd_throttled = NULL;
  389. #ifndef __FreeBSD__
  390. static RRDDIM *rd_indirect = NULL;
  391. #endif
  392. if (unlikely(!st_memory)) {
  393. st_memory = rrdset_create_localhost(
  394. "zfs"
  395. , "memory_ops"
  396. , NULL
  397. , ZFS_FAMILY_OPERATIONS
  398. , NULL
  399. , "ZFS Memory Operations"
  400. , "operations/s"
  401. , plugin
  402. , module
  403. , NETDATA_CHART_PRIO_ZFS_MEMORY_OPS
  404. , update_every
  405. , RRDSET_TYPE_LINE
  406. );
  407. #ifndef __FreeBSD__
  408. rd_direct = rrddim_add(st_memory, "direct", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  409. #endif
  410. rd_throttled = rrddim_add(st_memory, "throttled", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  411. #ifndef __FreeBSD__
  412. rd_indirect = rrddim_add(st_memory, "indirect", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  413. #endif
  414. }
  415. else
  416. rrdset_next(st_memory);
  417. #ifndef __FreeBSD__
  418. rrddim_set_by_pointer(st_memory, rd_direct, arcstats.memory_direct_count);
  419. #endif
  420. rrddim_set_by_pointer(st_memory, rd_throttled, arcstats.memory_throttle_count);
  421. #ifndef __FreeBSD__
  422. rrddim_set_by_pointer(st_memory, rd_indirect, arcstats.memory_indirect_count);
  423. #endif
  424. rrdset_done(st_memory);
  425. }
  426. // --------------------------------------------------------------------
  427. {
  428. static RRDSET *st_important_ops = NULL;
  429. static RRDDIM *rd_deleted = NULL;
  430. static RRDDIM *rd_mutex_misses = NULL;
  431. static RRDDIM *rd_evict_skips = NULL;
  432. static RRDDIM *rd_hash_collisions = NULL;
  433. if (unlikely(!st_important_ops)) {
  434. st_important_ops = rrdset_create_localhost(
  435. "zfs"
  436. , "important_ops"
  437. , NULL
  438. , ZFS_FAMILY_OPERATIONS
  439. , NULL
  440. , "ZFS Important Operations"
  441. , "operations/s"
  442. , plugin
  443. , module
  444. , NETDATA_CHART_PRIO_ZFS_IMPORTANT_OPS
  445. , update_every
  446. , RRDSET_TYPE_LINE
  447. );
  448. rd_evict_skips = rrddim_add(st_important_ops, "eskip", "evict skip", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  449. rd_deleted = rrddim_add(st_important_ops, "deleted", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
  450. rd_mutex_misses = rrddim_add(st_important_ops, "mtxmis", "mutex miss", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  451. rd_hash_collisions = rrddim_add(st_important_ops, "hash_collisions", "hash collisions", 1, 1, RRD_ALGORITHM_INCREMENTAL);
  452. }
  453. else
  454. rrdset_next(st_important_ops);
  455. rrddim_set_by_pointer(st_important_ops, rd_deleted, arcstats.deleted);
  456. rrddim_set_by_pointer(st_important_ops, rd_evict_skips, arcstats.evict_skip);
  457. rrddim_set_by_pointer(st_important_ops, rd_mutex_misses, arcstats.mutex_miss);
  458. rrddim_set_by_pointer(st_important_ops, rd_hash_collisions, arcstats.hash_collisions);
  459. rrdset_done(st_important_ops);
  460. }
  461. // --------------------------------------------------------------------
  462. {
  463. static RRDSET *st_actual_hits = NULL;
  464. static RRDDIM *rd_actual_hits = NULL;
  465. static RRDDIM *rd_actual_misses = NULL;
  466. if (unlikely(!st_actual_hits)) {
  467. st_actual_hits = rrdset_create_localhost(
  468. "zfs"
  469. , "actual_hits"
  470. , NULL
  471. , ZFS_FAMILY_EFFICIENCY
  472. , NULL
  473. , "ZFS Actual Cache Hits"
  474. , "percentage"
  475. , plugin
  476. , module
  477. , NETDATA_CHART_PRIO_ZFS_ACTUAL_HITS
  478. , update_every
  479. , RRDSET_TYPE_STACKED
  480. );
  481. rd_actual_hits = rrddim_add(st_actual_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  482. rd_actual_misses = rrddim_add(st_actual_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  483. }
  484. else
  485. rrdset_next(st_actual_hits);
  486. rrddim_set_by_pointer(st_actual_hits, rd_actual_hits, real_hits);
  487. rrddim_set_by_pointer(st_actual_hits, rd_actual_misses, real_misses);
  488. rrdset_done(st_actual_hits);
  489. }
  490. // --------------------------------------------------------------------
  491. {
  492. static RRDSET *st_demand_data_hits = NULL;
  493. static RRDDIM *rd_demand_data_hits = NULL;
  494. static RRDDIM *rd_demand_data_misses = NULL;
  495. if (unlikely(!st_demand_data_hits)) {
  496. st_demand_data_hits = rrdset_create_localhost(
  497. "zfs"
  498. , "demand_data_hits"
  499. , NULL
  500. , ZFS_FAMILY_EFFICIENCY
  501. , NULL
  502. , "ZFS Data Demand Efficiency"
  503. , "percentage"
  504. , plugin
  505. , module
  506. , NETDATA_CHART_PRIO_ZFS_DEMAND_DATA_HITS
  507. , update_every
  508. , RRDSET_TYPE_STACKED
  509. );
  510. rd_demand_data_hits = rrddim_add(st_demand_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  511. rd_demand_data_misses = rrddim_add(st_demand_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  512. }
  513. else
  514. rrdset_next(st_demand_data_hits);
  515. rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_hits, arcstats.demand_data_hits);
  516. rrddim_set_by_pointer(st_demand_data_hits, rd_demand_data_misses, arcstats.demand_data_misses);
  517. rrdset_done(st_demand_data_hits);
  518. }
  519. // --------------------------------------------------------------------
  520. {
  521. static RRDSET *st_prefetch_data_hits = NULL;
  522. static RRDDIM *rd_prefetch_data_hits = NULL;
  523. static RRDDIM *rd_prefetch_data_misses = NULL;
  524. if (unlikely(!st_prefetch_data_hits)) {
  525. st_prefetch_data_hits = rrdset_create_localhost(
  526. "zfs"
  527. , "prefetch_data_hits"
  528. , NULL
  529. , ZFS_FAMILY_EFFICIENCY
  530. , NULL
  531. , "ZFS Data Prefetch Efficiency"
  532. , "percentage"
  533. , plugin
  534. , module
  535. , NETDATA_CHART_PRIO_ZFS_PREFETCH_DATA_HITS
  536. , update_every
  537. , RRDSET_TYPE_STACKED
  538. );
  539. rd_prefetch_data_hits = rrddim_add(st_prefetch_data_hits, "hits", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  540. rd_prefetch_data_misses = rrddim_add(st_prefetch_data_hits, "misses", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
  541. }
  542. else
  543. rrdset_next(st_prefetch_data_hits);
  544. rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_hits, arcstats.prefetch_data_hits);
  545. rrddim_set_by_pointer(st_prefetch_data_hits, rd_prefetch_data_misses, arcstats.prefetch_data_misses);
  546. rrdset_done(st_prefetch_data_hits);
  547. }
  548. // --------------------------------------------------------------------
  549. {
  550. static RRDSET *st_hash_elements = NULL;
  551. static RRDDIM *rd_hash_elements_current = NULL;
  552. static RRDDIM *rd_hash_elements_max = NULL;
  553. if (unlikely(!st_hash_elements)) {
  554. st_hash_elements = rrdset_create_localhost(
  555. "zfs"
  556. , "hash_elements"
  557. , NULL
  558. , ZFS_FAMILY_HASH
  559. , NULL
  560. , "ZFS ARC Hash Elements"
  561. , "elements"
  562. , plugin
  563. , module
  564. , NETDATA_CHART_PRIO_ZFS_HASH_ELEMENTS
  565. , update_every
  566. , RRDSET_TYPE_LINE
  567. );
  568. rd_hash_elements_current = rrddim_add(st_hash_elements, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
  569. rd_hash_elements_max = rrddim_add(st_hash_elements, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
  570. }
  571. else
  572. rrdset_next(st_hash_elements);
  573. rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_current, arcstats.hash_elements);
  574. rrddim_set_by_pointer(st_hash_elements, rd_hash_elements_max, arcstats.hash_elements_max);
  575. rrdset_done(st_hash_elements);
  576. }
  577. // --------------------------------------------------------------------
  578. {
  579. static RRDSET *st_hash_chains = NULL;
  580. static RRDDIM *rd_hash_chains_current = NULL;
  581. static RRDDIM *rd_hash_chains_max = NULL;
  582. if (unlikely(!st_hash_chains)) {
  583. st_hash_chains = rrdset_create_localhost(
  584. "zfs"
  585. , "hash_chains"
  586. , NULL
  587. , ZFS_FAMILY_HASH
  588. , NULL
  589. , "ZFS ARC Hash Chains"
  590. , "chains"
  591. , plugin
  592. , module
  593. , NETDATA_CHART_PRIO_ZFS_HASH_CHAINS
  594. , update_every
  595. , RRDSET_TYPE_LINE
  596. );
  597. rd_hash_chains_current = rrddim_add(st_hash_chains, "current", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
  598. rd_hash_chains_max = rrddim_add(st_hash_chains, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
  599. }
  600. else
  601. rrdset_next(st_hash_chains);
  602. rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_current, arcstats.hash_chains);
  603. rrddim_set_by_pointer(st_hash_chains, rd_hash_chains_max, arcstats.hash_chain_max);
  604. rrdset_done(st_hash_chains);
  605. }
  606. // --------------------------------------------------------------------
  607. }