Browse Source

pose la preuve de concept

master
vince vince 3 years ago
parent
commit
c8b176c71d
2 changed files with 162 additions and 10 deletions
  1. +147
    -0
      Makefile
  2. +15
    -10
      README.md

+ 147
- 0
Makefile View File

@ -0,0 +1,147 @@
NOW = $(shell date +%s )
STEP = 60
SUCCESS = 198754
DANGER = DC3545
INFO = 0DCAF0
DANGER1 = F8D7DA
DANGER2 = F1AEB5
DANGER3 = EA868F
DANGER4 = E35D6A
DANGER5 = DC3545
DANGER6 = B02A37
DANGER7 = 842029
DANGER8 = 58151C
DANGER9 = 2C0B0E
INFO1 = 0AA2C0
INFO2 = 0DCAF0
INFO3 = 3DD5F3
IFACE = eth0
FORMAT = SVG
EXTENSION = .$(shell echo $(FORMAT) |tr '[:upper:]' '[:lower:]')
DAY_IN_SECS = 86400
all:
cpu.rrd:
rrdtool create $@ --start $$(( $(NOW) - 1 )) --step $(STEP) --no-overwrite \
DS:user:GAUGE:120:0:100 \
DS:nice:GAUGE:120:0:100 \
DS:sys:GAUGE:120:0:100 \
DS:iowait:GAUGE:120:0:100 \
DS:steal:GAUGE:120:0:100 \
DS:irq:GAUGE:120:0:100 \
DS:soft:GAUGE:120:0:100 \
DS:guest:GAUGE:120:0:100 \
DS:gnice:GAUGE:120:0:100 \
DS:idle:GAUGE:120:0:100 \
RRA:LAST:0.5:1:1440 \
RRA:AVERAGE:0.5:420:1440 \
RRA:AVERAGE:0.5:1860:1440 \
RRA:AVERAGE:0.5:21900:1440
update_cpu: cpu.rrd
rrdtool update $< $(NOW):$(shell LANG=C sar -u ALL 0 -1 |tail -n1 |awk '{print $$3,$$4,$$5,$$6,$$7,$$8,$$9,$$10,$$11,$$12}' |tr ' ' ':' )
load.rrd:
rrdtool create $@ --start $$(( $(NOW) - 1 )) --step $(STEP) --no-overwrite \
DS:ldavg-1:GAUGE:120:0:U \
DS:ldavg-5:GAUGE:120:0:U \
DS:ldavg-15:GAUGE:120:0:U \
RRA:LAST:0.5:1:1440 \
RRA:AVERAGE:0.5:420:1440 \
RRA:AVERAGE:0.5:1860:1440 \
RRA:AVERAGE:0.5:21900:1440
update_load: load.rrd
rrdtool update $< $(NOW):$(shell LANG=C sar -q LOAD 0 -1 |tail -n1 |awk '{print $$4,$$5,$$6}' |tr ' ' ':' )
mem.rrd:
rrdtool create $@ --start $$(( $(NOW) - 1 )) --step $(STEP) --no-overwrite \
DS:kbmemfree:GAUGE:120:0:U \
DS:kbbuffers:GAUGE:120:0:U \
DS:kbcached:GAUGE:120:0:U \
DS:kbslab:GAUGE:120:0:U \
RRA:LAST:0.5:1:1440 \
RRA:AVERAGE:0.5:420:1440 \
RRA:AVERAGE:0.5:1860:1440 \
RRA:AVERAGE:0.5:21900:1440
update_mem: mem.rrd
rrdtool update $< $(NOW):$(shell LANG=C sar -r ALL 0 -1 |tail -n1 |awk '{print $$2,$$6,$$7,$$14}' |tr ' ' ':' )
net.rrd:
rrdtool create $@ --start $$(( $(NOW) - 1 )) --step $(STEP) --no-overwrite \
DS:rbytes:COUNTER:120:0:U \
DS:tbytes:COUNTER:120:0:U \
RRA:LAST:0.5:1:1440 \
RRA:AVERAGE:0.5:420:1440 \
RRA:AVERAGE:0.5:1860:1440 \
RRA:AVERAGE:0.5:21900:1440
update_net: net.rrd
rrdtool update $< $(NOW):$(shell cat /proc/net/dev |grep $(IFACE) |awk '{print $$2,$$10}' |tr ' ' ':' )
update: update_cpu update_load update_mem update_net
run:
while true; do make update; sleep $(STEP); done
cpu-daily$(EXTENSION): cpu.rrd
rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
DEF:user=$<:user:AVERAGE \
DEF:nice=$<:nice:AVERAGE \
DEF:sys=$<:sys:AVERAGE \
DEF:iowait=$<:iowait:AVERAGE \
DEF:steal=$<:steal:AVERAGE \
DEF:irq=$<:irq:AVERAGE \
DEF:soft=$<:soft:AVERAGE \
DEF:guest=$<:guest:AVERAGE \
DEF:gnice=$<:gnice:AVERAGE \
DEF:idle=$<:idle:AVERAGE \
AREA:user#$(DANGER1):user:STACK \
AREA:nice#$(DANGER2):nice:STACK \
AREA:sys#$(DANGER3):sys:STACK \
AREA:iowait#$(DANGER4):iowait:STACK \
AREA:steal#$(DANGER5):steal:STACK \
AREA:irq#$(DANGER6):irq:STACK \
AREA:soft#$(DANGER7):soft:STACK \
AREA:guest#$(DANGER8):guest:STACK \
AREA:gnice#$(DANGER9):gnice:STACK \
AREA:idle#$(SUCCESS):idle:STACK
load-daily$(EXTENSION): load.rrd
rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
DEF:ldavg-1=$<:ldavg-1:AVERAGE \
DEF:ldavg-5=$<:ldavg-5:AVERAGE \
DEF:ldavg-15=$<:ldavg-15:AVERAGE \
LINE1:ldavg-1#$(INFO1):ldavg-1 \
LINE1:ldavg-5#$(INFO2):ldavg-5 \
LINE1:ldavg-15#$(INFO3):ldavg-15
mem-daily$(EXTENSION): mem.rrd
rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
DEF:kbmemfree=$<:kbmemfree:AVERAGE \
DEF:kbbuffers=$<:kbbuffers:AVERAGE \
DEF:kbcached=$<:kbcached:AVERAGE \
DEF:kbslab=$<:kbslab:AVERAGE \
AREA:kbbuffers#$(DANGER1):kbbuffers:STACK \
AREA:kbcached#$(DANGER2):kbcached:STACK \
AREA:kbslab#$(DANGER3):kbslab:STACK \
AREA:kbbuffers#$(DANGER4):kbbuffers:STACK \
AREA:kbmemfree#$(SUCCESS):kbmemfree:STACK
net-daily$(EXTENSION): net.rrd
rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
DEF:rbytes=$<:rbytes:AVERAGE \
DEF:tbytes=$<:tbytes:AVERAGE \
CDEF:ntbytes=tbytes,-1,* \
AREA:rbytes#$(DANGER):rbytes \
AREA:ntbytes#$(SUCCESS):tbytes
graph: cpu-daily$(EXTENSION) load-daily$(EXTENSION) mem-daily$(EXTENSION) net-daily$(EXTENSION)

+ 15
- 10
README.md View File

@ -113,16 +113,21 @@ rrdtool graph cpu-daily.svg --imgformat SVG --end now --start end-86400s \
DEF:guest=cpu.rrd:guest:AVERAGE \
DEF:gnice=cpu.rrd:gnice:AVERAGE \
DEF:idle=cpu.rrd:idle:AVERAGE \
AREA:user:STACK \
AREA:nice:STACK \
AREA:sys:STACK \
AREA:iowait:STACK \
AREA:steal:STACK \
AREA:irq:STACK \
AREA:soft:STACK \
AREA:guest:STACK \
AREA:gnice:STACK \
AREA:idle:STACK
AREA:user#FF0000:user:STACK \
AREA:nice#FF1111:nice:STACK \
AREA:sys#FF2222:sys:STACK \
AREA:iowait#FF3333:iowait:STACK \
AREA:steal#FF4444:steal:STACK \
AREA:irq#FF5555:irq:STACK \
AREA:soft#FF6666:soft:STACK \
AREA:guest#FF7777:guest:STACK \
AREA:gnice#FF8888:gnice:STACK \
AREA:idle#00FF00:idle:STACK
```
Il faudra trouver des jolies couleurs. Et éviter le blanc parce qu'il n'est pas tracé.
## Notes
Pour vider les caches mémoire : `echo 2 > /proc/sys/vm/drop_caches`, cf [la
doc](https://www.kernel.org/doc/html/latest/admin-guide/sysctl/vm.html#drop-caches)

Loading…
Cancel
Save