@cryptotaxi247 / netdata-1 / commits / 17d9d6d6c

added systemd services disk charts

Costa Tsaousis (ktsaou) committed Jan 16, 2017 at 02:20 UTC 17d9d6d6ccd1ff67ad87f13277cd042f68777a59
1 file changed +186 -9
src/sys_fs_cgroup.c
+186 -9
@@ -293,6 +293,20 @@ struct cgroup {
293 RRDDIM *rd_cpu;
294 RRDDIM *rd_mem_usage;
295
296 + RRDDIM *rd_io_service_bytes_read;
297 + RRDDIM *rd_io_serviced_read;
298 + RRDDIM *rd_throttle_io_read;
299 + RRDDIM *rd_throttle_io_serviced_read;
300 + RRDDIM *rd_io_queued_read;
301 + RRDDIM *rd_io_merged_read;
302 +
303 + RRDDIM *rd_io_service_bytes_write;
304 + RRDDIM *rd_io_serviced_write;
305 + RRDDIM *rd_throttle_io_write;
306 + RRDDIM *rd_throttle_io_serviced_write;
307 + RRDDIM *rd_io_queued_write;
308 + RRDDIM *rd_io_merged_write;
309 +
310 struct cgroup *next;
311
312 } *cgroup_root = NULL;
@@ -1242,9 +1256,35 @@ void find_all_cgroups() {
1256
1257 #define CHART_TITLE_MAX 300
1258
1245 -void update_services_charts(int update_every, int do_cpu, int do_mem_usage) {
1246 - static RRDSET *st_cpu = NULL;
1247 - static RRDSET *st_mem_usage = NULL;
1259 +void update_services_charts(int update_every,
1260 + int do_cpu,
1261 + int do_mem_usage,
1262 + int do_io,
1263 + int do_io_ops,
1264 + int do_throttle_io,
1265 + int do_throttle_ops /*,
1266 + int do_queued_ops,
1267 + int do_merged_ops */
1268 +) {
1269 + static RRDSET
1270 + *st_cpu = NULL,
1271 + *st_mem_usage = NULL,
1272 +
1273 + *st_io_read = NULL,
1274 + *st_io_serviced_read = NULL,
1275 + *st_throttle_io_read = NULL,
1276 + *st_throttle_ops_read = NULL,
1277 + /*
1278 + *st_queued_ops_read = NULL,
1279 + *st_merged_ops_read = NULL,
1280 + * */
1281 +
1282 + *st_io_write = NULL,
1283 + *st_io_serviced_write = NULL,
1284 + *st_throttle_io_write = NULL,
1285 + *st_throttle_ops_write = NULL/*,
1286 + *st_queued_ops_write = NULL,
1287 + *st_merged_ops_write = NULL*/;
1288
1289 // create the charts
1290
@@ -1270,6 +1310,70 @@ void update_services_charts(int update_every, int do_cpu, int do_mem_usage) {
1310 else rrdset_next(st_mem_usage);
1311 }
1312
1313 + if(do_io) {
1314 + if(unlikely(!st_io_read)) {
1315 + st_io_read = rrdset_find_bytype("services", "io_read");
1316 + if(!st_io_read)
1317 + st_io_read = rrdset_create("services", "io_read", NULL, "disk", "services.io_read", "Systemd Services Disk Read Bandwidth", "KB/s", 30012, update_every, RRDSET_TYPE_STACKED);
1318 + }
1319 + else rrdset_next(st_io_read);
1320 +
1321 + if(unlikely(!st_io_write)) {
1322 + st_io_write = rrdset_find_bytype("services", "io_write");
1323 + if(!st_io_write)
1324 + st_io_write = rrdset_create("services", "io_write", NULL, "disk", "services.io_write", "Systemd Services Disk Write Bandwidth", "KB/s", 30013, update_every, RRDSET_TYPE_STACKED);
1325 + }
1326 + else rrdset_next(st_io_write);
1327 + }
1328 +
1329 + if(do_io_ops) {
1330 + if(unlikely(!st_io_serviced_read)) {
1331 + st_io_serviced_read = rrdset_find_bytype("services", "io_ops_read");
1332 + if(!st_io_serviced_read)
1333 + st_io_serviced_read = rrdset_create("services", "io_ops_read", NULL, "disk", "services.io_ops_read", "Systemd Services Disk Read Operations", "operations/s", 30014, update_every, RRDSET_TYPE_STACKED);
1334 + }
1335 + else rrdset_next(st_io_serviced_read);
1336 +
1337 + if(unlikely(!st_io_serviced_write)) {
1338 + st_io_serviced_write = rrdset_find_bytype("services", "io_ops_write");
1339 + if(!st_io_serviced_write)
1340 + st_io_serviced_write = rrdset_create("services", "io_ops_write", NULL, "disk", "services.io_ops_write", "Systemd Services Disk Write Operations", "operations/s", 30015, update_every, RRDSET_TYPE_STACKED);
1341 + }
1342 + else rrdset_next(st_io_serviced_write);
1343 + }
1344 +
1345 + if(do_throttle_io) {
1346 + if(unlikely(!st_throttle_io_read)) {
1347 + st_throttle_io_read = rrdset_find_bytype("services", "throttle_io_read");
1348 + if(!st_throttle_io_read)
1349 + st_throttle_io_read = rrdset_create("services", "throttle_io_read", NULL, "disk", "services.throttle_io_read", "Systemd Services Throttle Disk Read Bandwidth", "KB/s", 30016, update_every, RRDSET_TYPE_STACKED);
1350 + }
1351 + else rrdset_next(st_throttle_io_read);
1352 +
1353 + if(unlikely(!st_throttle_io_write)) {
1354 + st_throttle_io_write = rrdset_find_bytype("services", "throttle_io_write");
1355 + if(!st_throttle_io_write)
1356 + st_throttle_io_write = rrdset_create("services", "throttle_io_write", NULL, "disk", "services.throttle_io_write", "Systemd Services Throttle Disk Write Bandwidth", "KB/s", 30017, update_every, RRDSET_TYPE_STACKED);
1357 + }
1358 + else rrdset_next(st_throttle_io_write);
1359 + }
1360 +
1361 + if(do_throttle_ops) {
1362 + if(unlikely(!st_throttle_ops_read)) {
1363 + st_throttle_ops_read = rrdset_find_bytype("services", "throttle_io_ops_read");
1364 + if(!st_throttle_ops_read)
1365 + st_throttle_ops_read = rrdset_create("services", "throttle_io_ops_read", NULL, "disk", "services.throttle_io_ops_read", "Systemd Services Throttle Disk Read Operations", "operations/s", 30018, update_every, RRDSET_TYPE_STACKED);
1366 + }
1367 + else rrdset_next(st_throttle_ops_read);
1368 +
1369 + if(unlikely(!st_throttle_ops_write)) {
1370 + st_throttle_ops_write = rrdset_find_bytype("services", "throttle_io_ops_write");
1371 + if(!st_throttle_ops_write)
1372 + st_throttle_ops_write = rrdset_create("services", "throttle_io_ops_write", NULL, "disk", "services.throttle_io_ops_write", "Systemd Services Throttle Disk Write Operations", "operations/s", 30019, update_every, RRDSET_TYPE_STACKED);
1373 + }
1374 + else rrdset_next(st_throttle_ops_write);
1375 + }
1376 +
1377 // update the values
1378 struct cgroup *cg;
1379 for(cg = cgroup_root; cg ; cg = cg->next) {
@@ -1282,17 +1386,69 @@ void update_services_charts(int update_every, int do_cpu, int do_mem_usage) {
1386 rrddim_set_by_pointer(st_cpu, cg->rd_cpu, cg->cpuacct_stat.user + cg->cpuacct_stat.system);
1387 }
1388
1285 - if(do_mem_usage) {
1389 + if(do_mem_usage && cg->memory.updated) {
1390 if(unlikely(!cg->rd_mem_usage))
1391 cg->rd_mem_usage = rrddim_add(st_mem_usage, cg->chart_id, cg->chart_title, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1392
1393 rrddim_set_by_pointer(st_mem_usage, cg->rd_mem_usage, cg->memory.usage_in_bytes);
1394 }
1395 +
1396 + if(do_io && cg->io_service_bytes.updated) {
1397 + if(unlikely(!cg->rd_io_service_bytes_read))
1398 + cg->rd_io_service_bytes_read = rrddim_add(st_io_read, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1399 +
1400 + rrddim_set_by_pointer(st_io_read, cg->rd_io_service_bytes_read, cg->io_service_bytes.Read);
1401 +
1402 + if(unlikely(!cg->rd_io_service_bytes_write))
1403 + cg->rd_io_service_bytes_write = rrddim_add(st_io_write, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1404 +
1405 + rrddim_set_by_pointer(st_io_write, cg->rd_io_service_bytes_write, cg->io_service_bytes.Write);
1406 + }
1407 +
1408 + if(do_io_ops && cg->io_serviced.updated) {
1409 + if(unlikely(!cg->rd_io_serviced_read))
1410 + cg->rd_io_serviced_read = rrddim_add(st_io_serviced_read, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1411 +
1412 + rrddim_set_by_pointer(st_io_serviced_read, cg->rd_io_serviced_read, cg->io_serviced.Read);
1413 +
1414 + if(unlikely(!cg->rd_io_serviced_write))
1415 + cg->rd_io_serviced_write = rrddim_add(st_io_serviced_write, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1416 +
1417 + rrddim_set_by_pointer(st_io_serviced_write, cg->rd_io_serviced_write, cg->io_serviced.Write);
1418 + }
1419 +
1420 + if(do_throttle_io && cg->throttle_io_service_bytes.updated) {
1421 + if(unlikely(!cg->rd_throttle_io_read))
1422 + cg->rd_throttle_io_read = rrddim_add(st_throttle_io_read, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1423 +
1424 + rrddim_set_by_pointer(st_throttle_io_read, cg->rd_throttle_io_read, cg->throttle_io_service_bytes.Read);
1425 +
1426 + if(unlikely(!cg->rd_throttle_io_write))
1427 + cg->rd_throttle_io_write = rrddim_add(st_throttle_io_write, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1428 +
1429 + rrddim_set_by_pointer(st_throttle_io_write, cg->rd_throttle_io_write, cg->throttle_io_service_bytes.Write);
1430 + }
1431 +
1432 + if(do_throttle_ops && cg->throttle_io_serviced.updated) {
1433 + if(unlikely(!cg->rd_throttle_io_serviced_read))
1434 + cg->rd_throttle_io_serviced_read = rrddim_add(st_throttle_ops_read, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1435 +
1436 + rrddim_set_by_pointer(st_throttle_ops_read, cg->rd_throttle_io_serviced_read, cg->throttle_io_serviced.Read);
1437 +
1438 + if(unlikely(!cg->rd_throttle_io_serviced_write))
1439 + cg->rd_throttle_io_serviced_write = rrddim_add(st_throttle_ops_write, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1440 +
1441 + rrddim_set_by_pointer(st_throttle_ops_write, cg->rd_throttle_io_serviced_write, cg->throttle_io_serviced.Write);
1442 + }
1443 }
1444
1445 // complete the iteration
1446 if(do_cpu) rrdset_done(st_cpu);
1447 if(do_mem_usage) rrdset_done(st_mem_usage);
1448 + if(do_io) { rrdset_done(st_io_read); rrdset_done(st_io_write); }
1449 + if(do_io_ops) { rrdset_done(st_io_serviced_read); rrdset_done(st_io_serviced_write); }
1450 + if(do_throttle_io) { rrdset_done(st_throttle_io_read); rrdset_done(st_throttle_io_write); }
1451 + if(do_throttle_ops) { rrdset_done(st_throttle_ops_read); rrdset_done(st_throttle_ops_write); }
1452 }
1453
1454 static inline char *cgroup_chart_type(char *buffer, const char *id, size_t len) {
@@ -1313,8 +1469,14 @@ void update_cgroup_charts(int update_every) {
1469 char type[RRD_ID_LENGTH_MAX + 1];
1470 char title[CHART_TITLE_MAX + 1];
1471
1316 - int services_do_cpu = 0;
1317 - int services_do_mem_usage = 0;
1472 + int services_do_cpu = 0,
1473 + services_do_mem_usage = 0,
1474 + services_do_io = 0,
1475 + services_do_io_ops = 0,
1476 + services_do_throttle_io = 0,
1477 + services_do_throttle_ops = 0,
1478 + services_do_queued_ops = 0,
1479 + services_do_merged_ops = 0;
1480
1481 struct cgroup *cg;
1482 for(cg = cgroup_root; cg ; cg = cg->next) {
@@ -1322,7 +1484,13 @@ void update_cgroup_charts(int update_every) {
1484
1485 if(cgroup_enable_systemd_services && cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE) {
1486 if(cg->cpuacct_stat.updated && (cg->cpuacct_stat.user || cg->cpuacct_stat.system)) services_do_cpu++;
1325 - if(cg->memory.usage_in_bytes_updated) services_do_mem_usage++;
1487 + if(cg->memory.usage_in_bytes_updated && (cg->memory.usage_in_bytes)) services_do_mem_usage++;
1488 + if(cg->io_service_bytes.updated && (cg->io_service_bytes.Read || cg->io_service_bytes.Write)) services_do_io++;
1489 + if(cg->io_serviced.updated && (cg->io_serviced.Read || cg->io_serviced.Write)) services_do_io_ops++;
1490 + if(cg->throttle_io_service_bytes.updated && (cg->throttle_io_service_bytes.Read || cg->throttle_io_service_bytes.Write)) services_do_throttle_io++;
1491 + if(cg->throttle_io_serviced.updated && (cg->throttle_io_serviced.Read || cg->throttle_io_serviced.Write)) services_do_throttle_ops++;
1492 + if(cg->io_queued.updated && (cg->io_queued.Read || cg->io_queued.Write)) services_do_queued_ops++;
1493 + if(cg->io_merged.updated && (cg->io_merged.Read || cg->io_merged.Write)) services_do_merged_ops++;
1494 continue;
1495 }
1496
@@ -1599,8 +1767,17 @@ void update_cgroup_charts(int update_every) {
1767
1768 debug(D_CGROUP, "done updating cgroups charts");
1769
1602 - if(cgroup_enable_systemd_services && services_do_cpu)
1603 - update_services_charts(update_every, services_do_cpu, services_do_mem_usage);
1770 + if(cgroup_enable_systemd_services)
1771 + update_services_charts(update_every,
1772 + services_do_cpu,
1773 + services_do_mem_usage,
1774 + services_do_io,
1775 + services_do_io_ops,
1776 + services_do_throttle_io,
1777 + services_do_throttle_ops/*,
1778 + services_do_queued_ops,
1779 + services_do_merged_ops*/
1780 + );
1781 }
1782
1783 // ----------------------------------------------------------------------------