added more memory charts
Costa Tsaousis (ktsaou) committed
Apr 16, 2014 at 02:52 UTC
48e730e35bc9e51c929b35e2751da4b3b5d148d2
2 files changed
+122
-13
netdata.c
+113
-7
@@ -3550,6 +3550,7 @@ int do_proc_stat() {
3550
RRD_STATS *st = rrd_stats_find_bytype("system", id);
3551
if(!st) {
3552
st = rrd_stats_create("system", id, NULL, "cpu", "CPU Interrupts", "interrupts/s", save_history);
3553
+ st->isdetail = 1;
3554
3555
rrd_stats_dimension_add(st, "interrupts", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3556
}
@@ -3621,6 +3622,7 @@ int do_proc_stat() {
3622
RRD_STATS *st = rrd_stats_find_bytype("system", "forks");
3623
if(!st) {
3624
st = rrd_stats_create("system", "forks", NULL, "cpu", "New Processes", "processes/s", save_history);
3625
+ st->isdetail = 1;
3626
3627
rrd_stats_dimension_add(st, "started", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_INCREMENTAL, NULL);
3628
}
@@ -3668,8 +3670,7 @@ int do_proc_meminfo() {
3670
NFS_Unstable = 0, Bounce = 0, WritebackTmp = 0, CommitLimit = 0, Committed_AS = 0,
3671
VmallocTotal = 0, VmallocUsed = 0, VmallocChunk = 0,
3672
AnonHugePages = 0, HugePages_Total = 0, HugePages_Free = 0, HugePages_Rsvd = 0, HugePages_Surp = 0, Hugepagesize = 0,
3671
- DirectMap4k = 0, DirectMap2M = 0,
3672
- MemUsed = 0;
3673
+ DirectMap4k = 0, DirectMap2M = 0, HardwareCorrupted = 0;
3674
3675
for(;1;) {
3676
char *p = fgets(buffer, MAX_PROC_MEMINFO_LINE, fp);
@@ -3719,6 +3720,7 @@ int do_proc_meminfo() {
3720
else if(!VmallocTotal && strcmp(name, "VmallocTotal") == 0) VmallocTotal = value;
3721
else if(!VmallocUsed && strcmp(name, "VmallocUsed") == 0) VmallocUsed = value;
3722
else if(!VmallocChunk && strcmp(name, "VmallocChunk") == 0) VmallocChunk = value;
3723
+ else if(!HardwareCorrupted && strcmp(name, "HardwareCorrupted") == 0) HardwareCorrupted = value;
3724
else if(!AnonHugePages && strcmp(name, "AnonHugePages") == 0) AnonHugePages = value;
3725
else if(!HugePages_Total && strcmp(name, "HugePages_Total") == 0) HugePages_Total = value;
3726
else if(!HugePages_Free && strcmp(name, "HugePages_Free") == 0) HugePages_Free = value;
@@ -3733,16 +3735,16 @@ int do_proc_meminfo() {
3735
// --------------------------------------------------------------------
3736
3737
// http://stackoverflow.com/questions/3019748/how-to-reliably-measure-available-memory-in-linux
3736
- MemUsed = MemTotal - MemFree - Cached - Buffers;
3738
+ unsigned long long MemUsed = MemTotal - MemFree - Cached - Buffers;
3739
3740
RRD_STATS *st = rrd_stats_find("system.ram");
3741
if(!st) {
3742
st = rrd_stats_create("system", "ram", NULL, "mem", "System RAM", "percentage", save_history);
3743
3742
- rrd_stats_dimension_add(st, "buffers", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_PCENT_OVER_ROW_TOTAL, NULL);
3743
- rrd_stats_dimension_add(st, "used", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_PCENT_OVER_ROW_TOTAL, NULL);
3744
- rrd_stats_dimension_add(st, "cached", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_PCENT_OVER_ROW_TOTAL, NULL);
3745
- rrd_stats_dimension_add(st, "free", NULL, sizeof(unsigned long long), 0, 1, 1, RRD_DIMENSION_PCENT_OVER_ROW_TOTAL, NULL);
3744
+ rrd_stats_dimension_add(st, "buffers", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3745
+ rrd_stats_dimension_add(st, "used", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3746
+ rrd_stats_dimension_add(st, "cached", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3747
+ rrd_stats_dimension_add(st, "free", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3748
}
3749
else rrd_stats_next(st);
3750
@@ -3752,6 +3754,110 @@ int do_proc_meminfo() {
3754
rrd_stats_dimension_set(st, "buffers", &Buffers, NULL);
3755
rrd_stats_done(st);
3756
3757
+ // --------------------------------------------------------------------
3758
+
3759
+ unsigned long long SwapUsed = SwapTotal - SwapFree;
3760
+
3761
+ st = rrd_stats_find("system.swap");
3762
+ if(!st) {
3763
+ st = rrd_stats_create("system", "swap", NULL, "mem", "System Swap", "percentage", save_history);
3764
+ st->isdetail = 1;
3765
+
3766
+ rrd_stats_dimension_add(st, "free", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3767
+ rrd_stats_dimension_add(st, "used", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3768
+ }
3769
+ else rrd_stats_next(st);
3770
+
3771
+ rrd_stats_dimension_set(st, "used", &SwapUsed, NULL);
3772
+ rrd_stats_dimension_set(st, "free", &SwapFree, NULL);
3773
+ rrd_stats_done(st);
3774
+
3775
+ // --------------------------------------------------------------------
3776
+
3777
+ st = rrd_stats_find("mem.hwcorrupt");
3778
+ if(!st) {
3779
+ st = rrd_stats_create("mem", "hwcorrupt", NULL, "mem", "Hardware Corrupted ECC", "MB", save_history);
3780
+ st->isdetail = 1;
3781
+
3782
+ rrd_stats_dimension_add(st, "HardwareCorrupted", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3783
+ }
3784
+ else rrd_stats_next(st);
3785
+
3786
+ rrd_stats_dimension_set(st, "HardwareCorrupted", &HardwareCorrupted, NULL);
3787
+ rrd_stats_done(st);
3788
+
3789
+ // --------------------------------------------------------------------
3790
+
3791
+ st = rrd_stats_find("mem.committed");
3792
+ if(!st) {
3793
+ st = rrd_stats_create("mem", "committed", NULL, "mem", "Committed (Allocated) Memory", "MB", save_history);
3794
+ st->isdetail = 1;
3795
+
3796
+ rrd_stats_dimension_add(st, "Committed_AS", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3797
+ }
3798
+ else rrd_stats_next(st);
3799
+
3800
+ rrd_stats_dimension_set(st, "Committed_AS", &Committed_AS, NULL);
3801
+ rrd_stats_done(st);
3802
+
3803
+ // --------------------------------------------------------------------
3804
+
3805
+ st = rrd_stats_find("mem.writeback");
3806
+ if(!st) {
3807
+ st = rrd_stats_create("mem", "writeback", NULL, "mem", "Writeback Memory", "MB", save_history);
3808
+ st->isdetail = 1;
3809
+
3810
+ rrd_stats_dimension_add(st, "Dirty", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3811
+ rrd_stats_dimension_add(st, "Writeback", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3812
+ rrd_stats_dimension_add(st, "FuseWriteback", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3813
+ rrd_stats_dimension_add(st, "NfsWriteback", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3814
+ rrd_stats_dimension_add(st, "Bounce", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3815
+ }
3816
+ else rrd_stats_next(st);
3817
+
3818
+ rrd_stats_dimension_set(st, "Dirty", &Dirty, NULL);
3819
+ rrd_stats_dimension_set(st, "Writeback", &Writeback, NULL);
3820
+ rrd_stats_dimension_set(st, "FuseWriteback", &WritebackTmp, NULL);
3821
+ rrd_stats_dimension_set(st, "NfsWriteback", &NFS_Unstable, NULL);
3822
+ rrd_stats_dimension_set(st, "Bounce", &Bounce, NULL);
3823
+ rrd_stats_done(st);
3824
+
3825
+ // --------------------------------------------------------------------
3826
+
3827
+ st = rrd_stats_find("mem.kernel");
3828
+ if(!st) {
3829
+ st = rrd_stats_create("mem", "kernel", NULL, "mem", "Memory Used by Kernel", "MB", save_history);
3830
+ st->isdetail = 1;
3831
+
3832
+ rrd_stats_dimension_add(st, "Slab", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3833
+ rrd_stats_dimension_add(st, "KernelStack", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3834
+ rrd_stats_dimension_add(st, "PageTables", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3835
+ rrd_stats_dimension_add(st, "VmallocUsed", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3836
+ }
3837
+ else rrd_stats_next(st);
3838
+
3839
+ rrd_stats_dimension_set(st, "KernelStack", &KernelStack, NULL);
3840
+ rrd_stats_dimension_set(st, "Slab", &Slab, NULL);
3841
+ rrd_stats_dimension_set(st, "PageTables", &PageTables, NULL);
3842
+ rrd_stats_dimension_set(st, "VmallocUsed", &VmallocUsed, NULL);
3843
+ rrd_stats_done(st);
3844
+
3845
+ // --------------------------------------------------------------------
3846
+
3847
+ st = rrd_stats_find("mem.slab");
3848
+ if(!st) {
3849
+ st = rrd_stats_create("mem", "slab", NULL, "mem", "Reclaimable Kernel Memory", "MB", save_history);
3850
+ st->isdetail = 1;
3851
+
3852
+ rrd_stats_dimension_add(st, "reclaimable", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3853
+ rrd_stats_dimension_add(st, "unreclaimable", NULL, sizeof(unsigned long long), 0, 1, 1024, RRD_DIMENSION_ABSOLUTE, NULL);
3854
+ }
3855
+ else rrd_stats_next(st);
3856
+
3857
+ rrd_stats_dimension_set(st, "reclaimable", &SReclaimable, NULL);
3858
+ rrd_stats_dimension_set(st, "unreclaimable", &SUnreclaim, NULL);
3859
+ rrd_stats_done(st);
3860
+
3861
return 0;
3862
}
3863
web/netdata.js
+9
-6
@@ -238,7 +238,14 @@ function loadCharts(base_url, doNext) {
238
};
239
240
// set the chart type
241
- if(json.charts[i].type == "tc" || json.charts[i].id.substring(0, 7) == "cpu.cpu" || json.charts[i].name == 'system.cpu' || json.charts[i].name == 'system.ram') {
241
+ if(json.charts[i].type == "tc"
242
+ || json.charts[i].id.substring(0, 7) == "cpu.cpu"
243
+ || json.charts[i].name == 'system.cpu'
244
+ || json.charts[i].name == 'system.ram'
245
+ || json.charts[i].name == 'system.swap'
246
+ || json.charts[i].name == 'mem.slab'
247
+ || json.charts[i].name == 'mem.kernel'
248
+ ) {
249
250
// default for all stacked AreaChart
251
json.charts[i].chartType = "AreaChart";
@@ -256,6 +263,7 @@ function loadCharts(base_url, doNext) {
263
|| json.charts[i].id == "system.swapio"
264
|| json.charts[i].id == "ipv4.mcast"
265
|| json.charts[i].id == "ipv4.bcast"
266
+ || json.charts[i].id == "mem.committed"
267
) {
268
269
// default for all AreaChart
@@ -306,11 +314,6 @@ function loadCharts(base_url, doNext) {
314
json.charts[i].category = "Memory";
315
json.charts[i].glyphicon = "glyphicon-dashboard";
316
json.charts[i].group = 5;
309
-
310
- if(json.charts[i].name == "mem.ram") {
311
- json.charts[i].chartOptions.vAxis.minValue = 0;
312
- json.charts[i].chartOptions.vAxis.maxValue = 100;
313
- }
317
break;
318
319
case "tc":