je vais tout casser ?

This commit is contained in:
tTh
2019-04-01 20:49:13 +02:00
62 changed files with 2672 additions and 159 deletions

View File

@@ -1,3 +1,39 @@
<<<<<<< HEAD
## Round Robin Database
=======
# Round Robin Database
Un grand classique du genre. Délicat à comprendre au début.
Les principes sous-jacents sont assez pointus, et leur mise en oeuvre
loin d'être évidente pour les newbies.
La lecture de la manpage `rrdtutorial` est indispensable.
https://oss.oetiker.ch/rrdtool/tut/rrd-beginners.en.html
## premier exemple
Un petit peu de code fabriqué à la rache.
- `create.sh`
- `update.sh`
- `getvalues.sh`
- `mkgraph.sh`
Suffisant pour comprendre le principe général, mais très flou
sur les détails.
## et après ?
Trouver une interface en C pour faciliter la vie des gens.
>>>>>>> b47e467d21cec6ee688b4407d3ec54fa33e67ba6
Un grand classique du genre.

6
rrdb/commun.sh Normal file
View File

@@ -0,0 +1,6 @@
#
# commun definitions for rrdb tests
#
export RRDB=$HOME/TMP/tests.rrd

21
rrdb/create.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
#
# creating the test database
#
source ./commun.sh
starttime=$(date +'%s')
echo creating $RRDB at ${starttime}s since epoch
rrdtool create $RRDB \
--start $starttime \
--step 60 \
DS:value:GAUGE:150:0:10 \
RRA:AVERAGE:0.5:1:60

29
rrdb/getvalues.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
source ./commun.sh
tmpf="somevalues.dat"
rrdtool fetch $RRDB LAST \
--start 0 |
tr -d ':' |
awk '
(!/nan/ && NF==2) { print $1, $2 }
' \
> ${tmpf}
#
# as an example, we are gnuploting our datas
#
gnuplot << __EOC__
set term png size 1024,512
set output "graphe.png"
set grid
set xdata time
set timefmt "%s"
set format x "%m/%d\n%H:%M"
plot "${tmpf}" using 1:2 with lines
__EOC__
# rm ${tmpf}

14
rrdb/insert.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
source ./commun.sh
ctime=$(date +'%s')
value=$(cut -d ' ' -f 1 /proc/loadavg)
# display and write value to a file
echo ${ctime} ${value} | tee -a bar.dat
# inject value in the rrdb file
rrdtool update $RRDB ${ctime}:${value}

11
rrdb/mkgraph.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
source ./commun.sh
rrdtool graph value.png \
--start 0 --end now \
-w 800 -h 600 \
DEF:value=${RRDB}:value:LAST \
LINE1:value#0000FF