|
|
- 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
- FS ?= /
-
- FORMAT = SVG
- EXTENSION = .$(shell echo $(FORMAT) |tr '[:upper:]' '[:lower:]')
-
- DAY_IN_SECS = 86400
- WEEK_IN_SECS = 604800
- MONTH_IN_SECS = 2678400
-
- BUILD_DIR = web
-
- 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 ' ' ':' )
-
- disk.rrd:
- rrdtool create $@ --start $$(( $(NOW) - 1 )) --step $(STEP) --no-overwrite \
- DS:mbfsfree:GAUGE:120:0:U \
- DS:mbfsused: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_disk: disk.rrd
- rrdtool update $< $(NOW):$(shell LANG=C sar -F MOUNT --fs=$(FS) 0 -1 |tail -n 1 |awk '{print $$2,$$3}' |tr ' ' ':' )
-
- update: update_cpu update_load update_mem update_net update_disk
-
- run:
- while true; do make update; sleep $(STEP); done
-
- $(BUILD_DIR)/cpu-daily$(EXTENSION): cpu.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
- --title "Processeur" \
- --upper-limit 100 \
- 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
-
- $(BUILD_DIR)/load-daily$(EXTENSION): load.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
- --title "Charge système" \
- DEF:ldavg-1=$<:ldavg-1:AVERAGE \
- DEF:ldavg-5=$<:ldavg-5:AVERAGE \
- DEF:ldavg-15=$<:ldavg-15:AVERAGE \
- LINE1:ldavg-1#$(INFO1):"sur 1 minute" \
- LINE1:ldavg-5#$(INFO2):"sur 5 minutes" \
- LINE1:ldavg-15#$(INFO3):"sur 15 minutes"
-
- $(BUILD_DIR)/mem-daily$(EXTENSION): mem.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
- --title "Mémoire" \
- DEF:kbmemfree=$<:kbmemfree:AVERAGE \
- CDEF:memfree=kbmemfree,1024,* \
- DEF:kbbuffers=$<:kbbuffers:AVERAGE \
- CDEF:buffers=kbbuffers,1024,* \
- DEF:kbcached=$<:kbcached:AVERAGE \
- CDEF:cached=kbcached,1024,* \
- DEF:kbslab=$<:kbslab:AVERAGE \
- CDEF:slab=kbslab,1024,* \
- AREA:buffers#$(DANGER1):"buffers":STACK \
- AREA:cached#$(DANGER2):"cached":STACK \
- AREA:slab#$(DANGER3):"slab":STACK \
- AREA:memfree#$(SUCCESS):"libre":STACK
-
- $(BUILD_DIR)/net-daily$(EXTENSION): net.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
- --title "Réseau (jour)" \
- DEF:rbytes=$<:rbytes:AVERAGE \
- CDEF:rbytesps=rbytes,60,/ \
- VDEF:rbytespsmax=rbytesps,MAXIMUM \
- DEF:tbytes=$<:tbytes:AVERAGE \
- CDEF:tbytesps=tbytes,60,/ \
- VDEF:tbytespsmax=tbytesps,MAXIMUM \
- CDEF:ntbytes=tbytes,-1,* \
- HRULE:0#$(INFO) \
- AREA:rbytes#$(DANGER):"reçu" \
- COMMENT:"maximum " \
- GPRINT:rbytespsmax:"%6.2lf %So/s" \
- AREA:ntbytes#$(SUCCESS):"envoyé" \
- COMMENT:"maximum " \
- GPRINT:tbytespsmax:"%6.2lf %So/s"
-
- $(BUILD_DIR)/net-weekly$(EXTENSION): net.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(WEEK_IN_SECS) \
- --title "Réseau (semaine)" \
- DEF:rbytes=$<:rbytes:AVERAGE \
- CDEF:rbytesps=rbytes,60,/ \
- VDEF:rbytespsmax=rbytesps,MAXIMUM \
- DEF:tbytes=$<:tbytes:AVERAGE \
- CDEF:tbytesps=tbytes,60,/ \
- VDEF:tbytespsmax=tbytesps,MAXIMUM \
- CDEF:ntbytes=tbytes,-1,* \
- HRULE:0#$(INFO) \
- AREA:rbytes#$(DANGER):"reçu" \
- COMMENT:"maximum " \
- GPRINT:rbytespsmax:"%6.2lf %So/s" \
- AREA:ntbytes#$(SUCCESS):"envoyé" \
- COMMENT:"maximum " \
- GPRINT:tbytespsmax:"%6.2lf %So/s"
-
- $(BUILD_DIR)/net-monthly$(EXTENSION): net.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(MONTH_IN_SECS) \
- --title "Réseau (mois)" \
- DEF:rbytes=$<:rbytes:AVERAGE \
- CDEF:rbytesps=rbytes,60,/ \
- VDEF:rbytespsmax=rbytesps,MAXIMUM \
- DEF:tbytes=$<:tbytes:AVERAGE \
- CDEF:tbytesps=tbytes,60,/ \
- VDEF:tbytespsmax=tbytesps,MAXIMUM \
- CDEF:ntbytes=tbytes,-1,* \
- HRULE:0#$(INFO) \
- AREA:rbytes#$(DANGER):"reçu" \
- COMMENT:"maximum " \
- GPRINT:rbytespsmax:"%6.2lf %So/s" \
- AREA:ntbytes#$(SUCCESS):"envoyé" \
- COMMENT:"maximum " \
- GPRINT:tbytespsmax:"%6.2lf %So/s"
-
- $(BUILD_DIR)/disk-daily$(EXTENSION): disk.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(DAY_IN_SECS) \
- --title "Disque (jour)" \
- --lower-limit 0 \
- DEF:mbfsfree=$<:mbfsfree:AVERAGE \
- CDEF:bfsfree=mbfsfree,1024,*,1024,* \
- VDEF:avgbfsfree=bfsfree,AVERAGE \
- DEF:mbfsused=$<:mbfsused:AVERAGE \
- CDEF:bfsused=mbfsused,1024,*,1024,* \
- CDEF:pfsused1=bfsused,100,*,bfsused,bfsfree,+,/ \
- VDEF:pfsused2=pfsused1,AVERAGE \
- AREA:bfsused#$(DANGER):"utilisé":STACK \
- GPRINT:pfsused2:"%3.2lf %%" \
- AREA:bfsfree#$(SUCCESS):"libre":STACK \
- GPRINT:avgbfsfree:"%4.0lf %So"
-
- $(BUILD_DIR)/disk-weekly$(EXTENSION): disk.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(WEEK_IN_SECS) \
- --title "Disque (semaine)" \
- --lower-limit 0 \
- DEF:mbfsfree=$<:mbfsfree:AVERAGE \
- CDEF:bfsfree=mbfsfree,1024,*,1024,* \
- VDEF:avgbfsfree=bfsfree,AVERAGE \
- DEF:mbfsused=$<:mbfsused:AVERAGE \
- CDEF:bfsused=mbfsused,1024,*,1024,* \
- CDEF:pfsused1=bfsused,100,*,bfsused,bfsfree,+,/ \
- VDEF:pfsused2=pfsused1,AVERAGE \
- AREA:bfsused#$(DANGER):"utilisé":STACK \
- GPRINT:pfsused2:"%3.2lf %%" \
- AREA:bfsfree#$(SUCCESS):"libre":STACK \
- GPRINT:avgbfsfree:"%4.0lf %So"
-
- $(BUILD_DIR)/disk-monthly$(EXTENSION): disk.rrd
- rrdtool graph $@ --imgformat $(FORMAT) --end now --start end-$(MONTH_IN_SECS) \
- --title "Disque (mois)" \
- --lower-limit 0 \
- DEF:mbfsfree=$<:mbfsfree:AVERAGE \
- CDEF:bfsfree=mbfsfree,1024,*,1024,* \
- VDEF:avgbfsfree=bfsfree,AVERAGE \
- DEF:mbfsused=$<:mbfsused:AVERAGE \
- CDEF:bfsused=mbfsused,1024,*,1024,* \
- CDEF:pfsused1=bfsused,100,*,bfsused,bfsfree,+,/ \
- VDEF:pfsused2=pfsused1,AVERAGE \
- AREA:bfsused#$(DANGER):"utilisé":STACK \
- GPRINT:pfsused2:"%3.2lf %%" \
- AREA:bfsfree#$(SUCCESS):"libre":STACK \
- GPRINT:avgbfsfree:"%4.0lf %So"
-
-
-
- .PHONY: $(BUILD_DIR)/index.html
-
- $(BUILD_DIR)/index.html: index.php
- php $< >$@
-
- # $(BUILD_DIR)/%.html: %.php
- # php $< >$@
-
- graph: $(BUILD_DIR)/cpu-daily$(EXTENSION) $(BUILD_DIR)/load-daily$(EXTENSION) $(BUILD_DIR)/mem-daily$(EXTENSION) $(BUILD_DIR)/net-daily$(EXTENSION) $(BUILD_DIR)/net-weekly$(EXTENSION) $(BUILD_DIR)/net-monthly$(EXTENSION) $(BUILD_DIR)/disk-daily$(EXTENSION) $(BUILD_DIR)/disk-weekly$(EXTENSION) $(BUILD_DIR)/disk-monthly$(EXTENSION) $(BUILD_DIR)/index.html
-
|