cgroups are enabled/disabled using their new names (it was needed because docker names are not persistent) #115
Costa Tsaousis (ktsaou) committed
Apr 25, 2016 at 22:26 UTC
e501a515b86b2a6f973dcd65a139b787ce03d52e
6 files changed
+141
-70
netdata-installer.sh
+2
-2
@@ -134,7 +134,7 @@ if [ "${UID}" -ne 0 ]
134
then
135
cat <<NONROOTNOPREFIX
136
137
-Sorry! This will wrong!
137
+Sorry! This will fail!
138
139
You are attempting to install netdata as non-root, but you plan to install it
140
in system paths.
@@ -415,7 +415,7 @@ do
415
fi
416
fi
417
418
- run chmod 0775 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
418
+ run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
419
done
420
421
if [ ${UID} -eq 0 ]
plugins.d/cgroup-name.sh
+9
-3
@@ -15,7 +15,7 @@ fi
15
16
if [ -f "${CONFIG}" ]
17
then
18
- NAME="$(cat "${CONFIG}" | grep "^${CGROUP}" | cut -d ' ' -f 2)"
18
+ NAME="$(cat "${CONFIG}" | grep "^${CGROUP} " | sed "s/[[:space:]]\+/ /g" | cut -d ' ' -f 2)"
19
if [ -z "${NAME}" ]
20
then
21
echo >&2 "${0}: cannot find cgroup '${CGROUP}' in '${CONFIG}'."
@@ -24,11 +24,17 @@ else
24
echo >&2 "${0}: configuration file '${CONFIG}' is not available."
25
fi
26
27
+if [ -z "${NAME}" -a "${CGROUP:0:7}" = "docker/" ]
28
+ then
29
+ NAME="$(docker ps | grep "^${CGROUP:7:12}" | sed "s/[[:space:]]\+/ /g" | cut -d ' ' -f 2)"
30
+ [ -z "${NAME}" ] && NAME="${CGROUP:0:19}"
31
+fi
32
+
33
if [ -z "${NAME}" ]
34
then
29
- if [ ${#CGROUP} -gt 12 ]
35
+ if [ ${#CGROUP} -gt 20 ]
36
then
31
- NAME="${CGROUP:0:12}"
37
+ NAME="${CGROUP:0:20}"
38
else
39
NAME="${CGROUP}"
40
fi
src/apps_plugin.c
+4
@@ -2397,6 +2397,10 @@ int main(int argc, char **argv)
2397
// disable syslog for apps.plugin
2398
error_log_syslog = 0;
2399
2400
+ // set errors flood protection to 100 logs per hour
2401
+ error_log_errors_per_period = 100;
2402
+ error_log_throttle_period = 3600;
2403
+
2404
host_prefix = getenv("NETDATA_HOST_PREFIX");
2405
if(host_prefix == NULL) {
2406
info("NETDATA_HOST_PREFIX is not passed from netdata");
src/log.c
+1
@@ -131,6 +131,7 @@ void debug_int( const char *file, const char *function, const unsigned long line
131
vfprintf( stdout, fmt, args );
132
va_end( args );
133
fprintf(stdout, "\n");
134
+ fflush( stdout );
135
136
if(output_log_syslog) {
137
va_start( args, fmt );
src/log.h
+1
@@ -24,6 +24,7 @@
24
#define D_RRD_CALLS 0x00020000
25
#define D_DICTIONARY 0x00040000
26
#define D_MEMORY 0x00080000
27
+#define D_CGROUP 0x00100000
28
29
//#define DEBUG (D_WEB_CLIENT_ACCESS|D_LISTENER|D_RRD_STATS)
30
//#define DEBUG 0xffffffff
src/sys_fs_cgroup.c
+124
-65
@@ -68,9 +68,11 @@ struct blkio {
68
69
unsigned long long Read;
70
unsigned long long Write;
71
+/*
72
unsigned long long Sync;
73
unsigned long long Async;
74
unsigned long long Total;
75
+*/
76
};
77
78
// https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
@@ -145,7 +147,7 @@ struct cgroup {
147
char *id;
148
uint32_t hash;
149
148
- char *name;
150
+ char *chart_id;
151
152
struct cpuacct_stat cpuacct_stat;
153
struct cpuacct_usage cpuacct_usage;
@@ -260,16 +262,20 @@ void cgroup_read_blkio(struct blkio *io) {
262
263
static uint32_t Read_hash = 0;
264
static uint32_t Write_hash = 0;
265
+/*
266
static uint32_t Sync_hash = 0;
267
static uint32_t Async_hash = 0;
268
static uint32_t Total_hash = 0;
269
+*/
270
271
if(unlikely(Read_hash == 0)) {
272
Read_hash = simple_hash("Read");
273
Write_hash = simple_hash("Write");
274
+/*
275
Sync_hash = simple_hash("Sync");
276
Async_hash = simple_hash("Async");
277
Total_hash = simple_hash("Total");
278
+*/
279
}
280
281
io->updated = 0;
@@ -289,9 +295,11 @@ void cgroup_read_blkio(struct blkio *io) {
295
296
io->Read = 0;
297
io->Write = 0;
298
+/*
299
io->Sync = 0;
300
io->Async = 0;
301
io->Total = 0;
302
+*/
303
304
for(i = 0; i < lines ; i++) {
305
char *s = procfile_lineword(ff, i, 1);
@@ -303,6 +311,7 @@ void cgroup_read_blkio(struct blkio *io) {
311
else if(hash == Write_hash && !strcmp(s, "Write"))
312
io->Write += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
313
314
+/*
315
else if(hash == Sync_hash && !strcmp(s, "Sync"))
316
io->Sync += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
317
@@ -311,6 +320,7 @@ void cgroup_read_blkio(struct blkio *io) {
320
321
else if(hash == Total_hash && !strcmp(s, "Total"))
322
io->Total += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
323
+*/
324
}
325
326
io->updated = 1;
@@ -526,6 +536,8 @@ void cgroup_read_memory(struct memory *mem) {
536
}
537
538
void cgroup_read(struct cgroup *cg) {
539
+ debug(D_CGROUP, "reading metrics for cgroups '%s'", cg->id);
540
+
541
cgroup_read_cpuacct_stat(&cg->cpuacct_stat);
542
cgroup_read_cpuacct_usage(&cg->cpuacct_usage);
543
cgroup_read_memory(&cg->memory);
@@ -537,103 +549,125 @@ void cgroup_read(struct cgroup *cg) {
549
cgroup_read_blkio(&cg->io_queued);
550
}
551
540
-void read_all_cgroups(struct cgroup *cg) {
541
- struct cgroup *i;
552
+void read_all_cgroups(struct cgroup *root) {
553
+ debug(D_CGROUP, "reading metrics for all cgroups");
554
+
555
+ struct cgroup *cg;
556
543
- for(i = cg; i ; i = i->next)
544
- cgroup_read(i);
557
+ for(cg = root; cg ; cg = cg->next)
558
+ if(cg->enabled)
559
+ cgroup_read(cg);
560
}
561
562
// ----------------------------------------------------------------------------
563
// add/remove/find cgroup objects
564
550
-#define CGROUP_NAME_LINE_MAX 1024
565
+#define CGROUP_CHARTID_LINE_MAX 1024
566
+
567
+void cgroup_get_chart_id(struct cgroup *cg) {
568
+ debug(D_CGROUP, "getting the name of cgroup '%s'", cg->id);
569
552
-void cgroup_get_name(struct cgroup *cg) {
570
pid_t cgroup_pid;
554
- char buffer[CGROUP_NAME_LINE_MAX + 1];
571
+ char buffer[CGROUP_CHARTID_LINE_MAX + 1];
572
556
- snprintf(buffer, CGROUP_NAME_LINE_MAX, "exec %s '%s'",
557
- config_get("plugin:cgroups", "script to get cgroup names", PLUGINS_DIR "/cgroup-name.sh"), cg->name);
573
+ snprintf(buffer, CGROUP_CHARTID_LINE_MAX, "exec %s '%s'",
574
+ config_get("plugin:cgroups", "script to get cgroup names", PLUGINS_DIR "/cgroup-name.sh"), cg->chart_id);
575
576
+ debug(D_CGROUP, "executing command '%s' for cgroup '%s'", buffer, cg->id);
577
FILE *fp = mypopen(buffer, &cgroup_pid);
578
if(!fp) {
579
error("CGROUP: Cannot popen(\"%s\", \"r\").", buffer);
580
return;
581
}
564
- char *s = fgets(buffer, CGROUP_NAME_LINE_MAX, fp);
582
+ debug(D_CGROUP, "reading from command '%s' for cgroup '%s'", buffer, cg->id);
583
+ char *s = fgets(buffer, CGROUP_CHARTID_LINE_MAX, fp);
584
+ debug(D_CGROUP, "closing command for cgroup '%s'", cg->id);
585
mypclose(fp, cgroup_pid);
586
+ debug(D_CGROUP, "closed command for cgroup '%s'", cg->id);
587
588
if(s && *s && *s != '\n') {
589
+ debug(D_CGROUP, "cgroup '%s' should be renamed to '%s'", cg->id, s);
590
+
591
trim(s);
569
- netdata_fix_chart_name(s);
570
- free(cg->name);
571
- cg->name = strdup(s);
572
- if(!cg->name)
573
- fatal("CGROUP: Cannot allocate memory for name cgroup %s name: '%s'", cg->id, s);
592
+ netdata_fix_chart_id(s);
593
+ free(cg->chart_id);
594
+ cg->chart_id = strdup(s);
595
+ if(!cg->chart_id)
596
+ fatal("CGROUP: Cannot allocate memory for chart id of cgroup '%s' chart id: '%s'", cg->id, s);
597
+
598
+ debug(D_CGROUP, "cgroup '%s' renamed to '%s'", cg->id, cg->chart_id);
599
}
600
+ else debug(D_CGROUP, "cgroup '%s' is not to be renamed (will be shown as '%s')", cg->id, cg->chart_id);
601
}
602
603
struct cgroup *cgroup_add(const char *id) {
604
+ debug(D_CGROUP, "adding cgroup '%s'", id);
605
+
606
if(cgroup_root_count >= cgroup_root_max) {
607
info("Maximum number of cgroups reached (%d). Not adding cgroup '%s'", cgroup_root_count, id);
608
return NULL;
609
}
610
611
int def = cgroup_enable_new_cgroups_detected_at_runtime;
584
- const char *name = id;
585
- if(!*name) {
586
- name = "/";
612
+ const char *chart_id = id;
613
+ if(!*chart_id) {
614
+ chart_id = "/";
615
616
// disable by default the host cgroup
617
def = 0;
618
+ debug(D_CGROUP, "cgroup '%s' is the host container (by default %s)", id, (def)?"enabled":"disabled");
619
}
620
else {
592
- if(*name == '/') name++;
621
+ if(*chart_id == '/') chart_id++;
622
623
// disable by default the parent cgroup
624
// for known cgroup managers
596
- if(!strcmp(name, "lxc") || !strcmp(name, "docker"))
625
+ if(!strcmp(chart_id, "lxc") || !strcmp(chart_id, "docker")) {
626
def = 0;
627
+ debug(D_CGROUP, "cgroup '%s' is container manager (by default %s)", id, (def)?"enabled":"disabled");
628
+ }
629
}
630
600
- char option[FILENAME_MAX + 1];
601
- snprintf(option, FILENAME_MAX, "enable cgroup %s", name);
602
- if(!config_get_boolean("plugin:cgroups", option, def))
603
- return NULL;
604
-
631
struct cgroup *cg = calloc(1, sizeof(struct cgroup));
606
- if(cg) {
607
- cg->id = strdup(id);
608
- if(!cg->id) fatal("Cannot allocate memory for cgroup '%s'", id);
609
-
610
- cg->hash = simple_hash(cg->id);
632
+ if(!cg) fatal("Cannot allocate memory for cgroup '%s'", id);
633
612
- cg->name = strdup(name);
613
- if(!cg->name) fatal("Cannot allocate memory for cgroup '%s'", id);
634
+ debug(D_CGROUP, "adding cgroup '%s'", id);
635
615
- if(!cgroup_root)
616
- cgroup_root = cg;
617
- else {
618
- // append it
619
- struct cgroup *e;
620
- for(e = cgroup_root; e->next ;e = e->next) ;
621
- e->next = cg;
622
- }
636
+ cg->id = strdup(id);
637
+ if(!cg->id) fatal("Cannot allocate memory for cgroup '%s'", id);
638
624
- cgroup_root_count++;
639
+ cg->hash = simple_hash(cg->id);
640
626
- // fprintf(stderr, " > added cgroup No %d, with id '%s' (%u) and name '%s'\n", cgroup_root_count, cg->id, cg->hash, cg->name);
641
+ cg->chart_id = strdup(chart_id);
642
+ if(!cg->chart_id) fatal("Cannot allocate memory for cgroup '%s'", id);
643
628
- // fix the name by calling the external script
629
- cgroup_get_name(cg);
644
+ if(!cgroup_root)
645
+ cgroup_root = cg;
646
+ else {
647
+ // append it
648
+ struct cgroup *e;
649
+ for(e = cgroup_root; e->next ;e = e->next) ;
650
+ e->next = cg;
651
}
631
- else fatal("Cannot allocate memory for cgroup '%s'", id);
652
+
653
+ cgroup_root_count++;
654
+
655
+ // fprintf(stderr, " > added cgroup No %d, with id '%s' (%u) and name '%s'\n", cgroup_root_count, cg->id, cg->hash, cg->name);
656
+
657
+ // fix the name by calling the external script
658
+ cgroup_get_chart_id(cg);
659
+
660
+ char option[FILENAME_MAX + 1];
661
+ snprintf(option, FILENAME_MAX, "enable cgroup %s", cg->chart_id);
662
+ cg->enabled = config_get_boolean("plugin:cgroups", option, def);
663
+ debug(D_CGROUP, "finally: new cgroup '%s' is named '%s' and is %s (default was %s)", cg->id, cg->chart_id, (cg->enabled)?"enabled":"disabled", (def)?"enabled":"disabled");
664
665
return cg;
666
}
667
668
void cgroup_remove(struct cgroup *cg) {
669
+ debug(D_CGROUP, "removing cgroup '%s'", cg->id);
670
+
671
if(cg == cgroup_root) {
672
cgroup_root = cg->next;
673
}
@@ -664,12 +698,14 @@ void cgroup_remove(struct cgroup *cg) {
698
free(cg->io_queued.filename);
699
700
free(cg->id);
667
- free(cg->name);
701
+ free(cg->chart_id);
702
free(cg);
703
}
704
705
// find if a given cgroup exists
706
struct cgroup *cgroup_find(const char *id) {
707
+ debug(D_CGROUP, "searching for cgroup '%s'", id);
708
+
709
uint32_t hash = simple_hash(id);
710
711
// fprintf(stderr, " > searching for '%s' (%u)\n", id, hash);
@@ -680,6 +716,7 @@ struct cgroup *cgroup_find(const char *id) {
716
break;
717
}
718
719
+ debug(D_CGROUP, "cgroup '%s' %s", id, (cg)?"found":"not found");
720
return cg;
721
}
722
@@ -688,7 +725,7 @@ struct cgroup *cgroup_find(const char *id) {
725
726
// callback for find_file_in_subdirs()
727
void found_dir_in_subdir(const char *dir) {
691
- // fprintf(stderr, "found dir '%s'\n", dir);
728
+ debug(D_CGROUP, "examining cgroup dir '%s'", dir);
729
730
struct cgroup *cg = cgroup_find(dir);
731
if(!cg) {
@@ -705,6 +742,7 @@ void found_dir_in_subdir(const char *dir) {
742
return;
743
}
744
}
745
+ debug(D_CGROUP, "will add dir '%s' as cgroup", dir);
746
cg = cgroup_add(dir);
747
}
748
@@ -729,7 +767,7 @@ void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(co
767
))
768
continue;
769
732
- // fprintf(stderr, "examining '%s/%s'\n", this, de->d_name);
770
+ debug(D_CGROUP, "examining '%s/%s'", this, de->d_name);
771
772
if(de->d_type == DT_DIR) {
773
char *s = malloc(dirlen + strlen(de->d_name) + 2);
@@ -747,6 +785,8 @@ void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(co
785
}
786
787
void mark_all_cgroups_as_not_available() {
788
+ debug(D_CGROUP, "marking all cgroups as not available");
789
+
790
struct cgroup *cg;
791
792
// mark all as not available
@@ -755,6 +795,7 @@ void mark_all_cgroups_as_not_available() {
795
}
796
797
struct cgroup *find_all_cgroups() {
798
+ debug(D_CGROUP, "searching for cgroups");
799
800
mark_all_cgroups_as_not_available();
801
@@ -772,53 +813,67 @@ struct cgroup *find_all_cgroups() {
813
// fprintf(stderr, " >>> CGROUP '%s' (%u - %s) with name '%s'\n", cg->id, cg->hash, cg->available?"available":"stopped", cg->name);
814
815
if(!cg->available) {
775
- cgroup_remove(cg);
816
+ // do not remove the cgroup
817
+ // it will be added back on the next scan
818
+ // cgroup_remove(cg);
819
continue;
820
}
821
822
+ debug(D_CGROUP, "checking paths for cgroup '%s'", cg->id);
823
+
824
// check for newly added cgroups
825
// and update the filenames they read
826
char filename[FILENAME_MAX + 1];
827
if(cgroup_enable_cpuacct_stat && !cg->cpuacct_stat.filename) {
828
snprintf(filename, FILENAME_MAX, "%s%s/cpuacct.stat", cgroup_cpuacct_base, cg->id);
829
cg->cpuacct_stat.filename = strdup(filename);
830
+ debug(D_CGROUP, "cpuacct.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename);
831
}
832
if(cgroup_enable_cpuacct_usage && !cg->cpuacct_usage.filename) {
833
snprintf(filename, FILENAME_MAX, "%s%s/cpuacct.usage_percpu", cgroup_cpuacct_base, cg->id);
834
cg->cpuacct_usage.filename = strdup(filename);
835
+ debug(D_CGROUP, "cpuacct.usage_percpu filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_usage.filename);
836
}
837
if(cgroup_enable_memory && !cg->memory.filename) {
838
snprintf(filename, FILENAME_MAX, "%s%s/memory.stat", cgroup_memory_base, cg->id);
839
cg->memory.filename = strdup(filename);
840
+ debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename);
841
}
842
if(cgroup_enable_blkio) {
843
if(!cg->io_service_bytes.filename) {
844
snprintf(filename, FILENAME_MAX, "%s%s/blkio.io_service_bytes", cgroup_blkio_base, cg->id);
845
cg->io_service_bytes.filename = strdup(filename);
846
+ debug(D_CGROUP, "io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
847
}
848
if(!cg->io_serviced.filename) {
849
snprintf(filename, FILENAME_MAX, "%s%s/blkio.io_serviced", cgroup_blkio_base, cg->id);
850
cg->io_serviced.filename = strdup(filename);
851
+ debug(D_CGROUP, "io_serviced filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename);
852
}
853
if(!cg->throttle_io_service_bytes.filename) {
854
snprintf(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_service_bytes", cgroup_blkio_base, cg->id);
855
cg->throttle_io_service_bytes.filename = strdup(filename);
856
+ debug(D_CGROUP, "throttle_io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename);
857
}
858
if(!cg->throttle_io_serviced.filename) {
859
snprintf(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_serviced", cgroup_blkio_base, cg->id);
860
cg->throttle_io_serviced.filename = strdup(filename);
861
+ debug(D_CGROUP, "throttle_io_serviced filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename);
862
}
863
if(!cg->io_merged.filename) {
864
snprintf(filename, FILENAME_MAX, "%s%s/blkio.io_merged", cgroup_blkio_base, cg->id);
865
cg->io_merged.filename = strdup(filename);
866
+ debug(D_CGROUP, "io_merged filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename);
867
}
868
if(!cg->io_queued.filename) {
869
snprintf(filename, FILENAME_MAX, "%s%s/blkio.io_queued", cgroup_blkio_base, cg->id);
870
cg->io_queued.filename = strdup(filename);
871
+ debug(D_CGROUP, "io_queued filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename);
872
}
873
}
874
}
875
876
+ debug(D_CGROUP, "done searching for cgroups");
877
return cgroup_root;
878
}
879
@@ -828,6 +883,8 @@ struct cgroup *find_all_cgroups() {
883
#define CHART_TITLE_MAX 300
884
885
void update_cgroup_charts(int update_every) {
886
+ debug(D_CGROUP, "updating cgroups charts");
887
+
888
char type[RRD_ID_LENGTH_MAX + 1];
889
char title[CHART_TITLE_MAX + 1];
890
@@ -835,21 +892,21 @@ void update_cgroup_charts(int update_every) {
892
RRDSET *st;
893
894
for(cg = cgroup_root; cg ; cg = cg->next) {
838
- if(!cg->available) continue;
895
+ if(!cg->available || !cg->enabled) continue;
896
897
if(cg->id[0] == '\0')
898
strcpy(type, "cgroup_host");
899
else if(cg->id[0] == '/')
843
- snprintf(type, RRD_ID_LENGTH_MAX, "cgroup_%s", cg->name);
900
+ snprintf(type, RRD_ID_LENGTH_MAX, "cgroup_%s", cg->chart_id);
901
else
845
- snprintf(type, RRD_ID_LENGTH_MAX, "cgroup_%s", cg->name);
902
+ snprintf(type, RRD_ID_LENGTH_MAX, "cgroup_%s", cg->chart_id);
903
904
netdata_fix_chart_id(type);
905
906
if(cg->cpuacct_stat.updated) {
907
st = rrdset_find_bytype(type, "cpu");
908
if(!st) {
852
- snprintf(title, CHART_TITLE_MAX, "CPU Usage for cgroup %s", cg->name);
909
+ snprintf(title, CHART_TITLE_MAX, "CPU Usage for cgroup %s", cg->chart_id);
910
st = rrdset_create(type, "cpu", NULL, "cpu", "cgroup.cpu", title, "%", 40000, update_every, RRDSET_TYPE_STACKED);
911
912
rrddim_add(st, "user", NULL, 100, hz, RRDDIM_INCREMENTAL);
@@ -868,7 +925,7 @@ void update_cgroup_charts(int update_every) {
925
926
st = rrdset_find_bytype(type, "cpu_per_core");
927
if(!st) {
871
- snprintf(title, CHART_TITLE_MAX, "CPU Usage Per Core for cgroup %s", cg->name);
928
+ snprintf(title, CHART_TITLE_MAX, "CPU Usage Per Core for cgroup %s", cg->chart_id);
929
st = rrdset_create(type, "cpu_per_core", NULL, "cpu", "cgroup.cpu_per_core", title, "%", 40100, update_every, RRDSET_TYPE_STACKED);
930
931
for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
@@ -889,7 +946,7 @@ void update_cgroup_charts(int update_every) {
946
if(cg->memory.cache + cg->memory.rss + cg->memory.rss_huge + cg->memory.mapped_file > 0) {
947
st = rrdset_find_bytype(type, "mem");
948
if(!st) {
892
- snprintf(title, CHART_TITLE_MAX, "Memory Usage for cgroup %s", cg->name);
949
+ snprintf(title, CHART_TITLE_MAX, "Memory Usage for cgroup %s", cg->chart_id);
950
st = rrdset_create(type, "mem", NULL, "mem", "cgroup.mem", title, "MB", 40200, update_every,
951
RRDSET_TYPE_STACKED);
952
@@ -913,7 +970,7 @@ void update_cgroup_charts(int update_every) {
970
971
st = rrdset_find_bytype(type, "writeback");
972
if(!st) {
916
- snprintf(title, CHART_TITLE_MAX, "Writeback Memory for cgroup %s", cg->name);
973
+ snprintf(title, CHART_TITLE_MAX, "Writeback Memory for cgroup %s", cg->chart_id);
974
st = rrdset_create(type, "writeback", NULL, "mem", "cgroup.writeback", title, "MB", 40300,
975
update_every, RRDSET_TYPE_AREA);
976
@@ -931,7 +988,7 @@ void update_cgroup_charts(int update_every) {
988
if(cg->memory.pgpgin + cg->memory.pgpgout > 0) {
989
st = rrdset_find_bytype(type, "mem_activity");
990
if(!st) {
934
- snprintf(title, CHART_TITLE_MAX, "Memory Activity for cgroup %s", cg->name);
991
+ snprintf(title, CHART_TITLE_MAX, "Memory Activity for cgroup %s", cg->chart_id);
992
st = rrdset_create(type, "mem_activity", NULL, "mem", "cgroup.mem_activity", title, "MB/s",
993
40400, update_every, RRDSET_TYPE_LINE);
994
@@ -948,7 +1005,7 @@ void update_cgroup_charts(int update_every) {
1005
if(cg->memory.pgfault + cg->memory.pgmajfault > 0) {
1006
st = rrdset_find_bytype(type, "pgfaults");
1007
if(!st) {
951
- snprintf(title, CHART_TITLE_MAX, "Memory Page Faults for cgroup %s", cg->name);
1008
+ snprintf(title, CHART_TITLE_MAX, "Memory Page Faults for cgroup %s", cg->chart_id);
1009
st = rrdset_create(type, "pgfaults", NULL, "mem", "cgroup.pgfaults", title, "MB/s", 40500,
1010
update_every, RRDSET_TYPE_LINE);
1011
@@ -966,7 +1023,7 @@ void update_cgroup_charts(int update_every) {
1023
if(cg->io_service_bytes.updated && cg->io_service_bytes.Read + cg->io_service_bytes.Write > 0) {
1024
st = rrdset_find_bytype(type, "io");
1025
if(!st) {
969
- snprintf(title, CHART_TITLE_MAX, "I/O Bandwidth (all disks) for cgroup %s", cg->name);
1026
+ snprintf(title, CHART_TITLE_MAX, "I/O Bandwidth (all disks) for cgroup %s", cg->chart_id);
1027
st = rrdset_create(type, "io", NULL, "disk", "cgroup.io", title, "KB/s", 41200,
1028
update_every, RRDSET_TYPE_LINE);
1029
@@ -983,7 +1040,7 @@ void update_cgroup_charts(int update_every) {
1040
if(cg->io_serviced.updated && cg->io_serviced.Read + cg->io_serviced.Write > 0) {
1041
st = rrdset_find_bytype(type, "serviced_ops");
1042
if(!st) {
986
- snprintf(title, CHART_TITLE_MAX, "Serviced I/O Operations (all disks) for cgroup %s", cg->name);
1043
+ snprintf(title, CHART_TITLE_MAX, "Serviced I/O Operations (all disks) for cgroup %s", cg->chart_id);
1044
st = rrdset_create(type, "serviced_ops", NULL, "disk", "cgroup.serviced_ops", title, "operations/s", 41200,
1045
update_every, RRDSET_TYPE_LINE);
1046
@@ -1000,7 +1057,7 @@ void update_cgroup_charts(int update_every) {
1057
if(cg->throttle_io_service_bytes.updated && cg->throttle_io_service_bytes.Read + cg->throttle_io_service_bytes.Write > 0) {
1058
st = rrdset_find_bytype(type, "io");
1059
if(!st) {
1003
- snprintf(title, CHART_TITLE_MAX, "Throttle I/O Bandwidth (all disks) for cgroup %s", cg->name);
1060
+ snprintf(title, CHART_TITLE_MAX, "Throttle I/O Bandwidth (all disks) for cgroup %s", cg->chart_id);
1061
st = rrdset_create(type, "io", NULL, "disk", "cgroup.io", title, "KB/s", 41200,
1062
update_every, RRDSET_TYPE_LINE);
1063
@@ -1018,7 +1075,7 @@ void update_cgroup_charts(int update_every) {
1075
if(cg->throttle_io_serviced.updated && cg->throttle_io_serviced.Read + cg->throttle_io_serviced.Write > 0) {
1076
st = rrdset_find_bytype(type, "throttle_serviced_ops");
1077
if(!st) {
1021
- snprintf(title, CHART_TITLE_MAX, "Throttle Serviced I/O Operations (all disks) for cgroup %s", cg->name);
1078
+ snprintf(title, CHART_TITLE_MAX, "Throttle Serviced I/O Operations (all disks) for cgroup %s", cg->chart_id);
1079
st = rrdset_create(type, "throttle_serviced_ops", NULL, "disk", "cgroup.throttle_serviced_ops", title, "operations/s", 41200,
1080
update_every, RRDSET_TYPE_LINE);
1081
@@ -1035,7 +1092,7 @@ void update_cgroup_charts(int update_every) {
1092
if(cg->io_queued.updated) {
1093
st = rrdset_find_bytype(type, "queued_ops");
1094
if(!st) {
1038
- snprintf(title, CHART_TITLE_MAX, "Queued I/O Operations (all disks) for cgroup %s", cg->name);
1095
+ snprintf(title, CHART_TITLE_MAX, "Queued I/O Operations (all disks) for cgroup %s", cg->chart_id);
1096
st = rrdset_create(type, "queued_ops", NULL, "disk", "cgroup.queued_ops", title, "operations", 42000,
1097
update_every, RRDSET_TYPE_LINE);
1098
@@ -1052,7 +1109,7 @@ void update_cgroup_charts(int update_every) {
1109
if(cg->io_merged.updated && cg->io_merged.Read + cg->io_merged.Write > 0) {
1110
st = rrdset_find_bytype(type, "merged_ops");
1111
if(!st) {
1055
- snprintf(title, CHART_TITLE_MAX, "Merged I/O Operations (all disks) for cgroup %s", cg->name);
1112
+ snprintf(title, CHART_TITLE_MAX, "Merged I/O Operations (all disks) for cgroup %s", cg->chart_id);
1113
st = rrdset_create(type, "merged_ops", NULL, "disk", "cgroup.merged_ops", title, "operations/s", 42100,
1114
update_every, RRDSET_TYPE_LINE);
1115
@@ -1066,6 +1123,8 @@ void update_cgroup_charts(int update_every) {
1123
rrdset_done(st);
1124
}
1125
}
1126
+
1127
+ debug(D_CGROUP, "done updating cgroups charts");
1128
}
1129
1130
// ----------------------------------------------------------------------------