From 4447ed460e36348e410288c30cd6e15bb107ba34 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 16:26:46 +0100 Subject: [PATCH] rrdb : first working code --- .gitignore | 4 +++- gnocchi/README.md | 9 +++++---- influxdb/README.md | 5 ++++- rrdb/README.md | 14 ++++++++++++++ rrdb/commun.sh | 6 ++++++ rrdb/create.sh | 21 +++++++++++++++++++++ rrdb/getvalues.sh | 19 +++++++++++++++++++ rrdb/insert.sh | 14 ++++++++++++++ 8 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 rrdb/commun.sh create mode 100755 rrdb/create.sh create mode 100755 rrdb/getvalues.sh create mode 100755 rrdb/insert.sh diff --git a/.gitignore b/.gitignore index b0aef2a..4052870 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,9 @@ doc/*.idx doc/*.ilg doc/*.ind -*/foo.dat +*/*.dat + +rrdb/*.png diff --git a/gnocchi/README.md b/gnocchi/README.md index e447827..e8ad94e 100644 --- a/gnocchi/README.md +++ b/gnocchi/README.md @@ -2,10 +2,11 @@ ## blabla commercial - - -_The problem that [Gnocchi](https://gnocchi.xyz/) solves is the storage and indexing of -time series data and resources at a large scale. +_The problem that [Gnocchi](https://gnocchi.xyz/) solves is the storage and +indexing of time series data and resources at a large scale. This is useful in modern cloud platforms which are not only huge but also are dynamic and potentially multi-tenant. Gnocchi takes all of that into account._ + +Bref, il faut essayer ce truc. Un de ces jours... + diff --git a/influxdb/README.md b/influxdb/README.md index 8a603ab..f949aa4 100644 --- a/influxdb/README.md +++ b/influxdb/README.md @@ -12,7 +12,10 @@ purpose-built platform that InfluxData provides._ # On essaye ? -Ok, c'est parti. On va écrire un injecteur en Perl. Puis enchainer sur +Ok, c'est parti. Premier souci, la documentation est assez légère. + + +On va tenter d'écrire un injecteur en Perl. Puis enchainer sur une visualisation dynamique des données en lancer de rayon. Projet ambitieux ? Non, la suite sera bien pire. diff --git a/rrdb/README.md b/rrdb/README.md index 74d6528..1caad84 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -6,11 +6,25 @@ 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` + +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. + + + diff --git a/rrdb/commun.sh b/rrdb/commun.sh new file mode 100644 index 0000000..8b72f42 --- /dev/null +++ b/rrdb/commun.sh @@ -0,0 +1,6 @@ +# +# commun definitions for rrdb tests +# + +export RRDB=$HOME/TMP/tests.rrd + diff --git a/rrdb/create.sh b/rrdb/create.sh new file mode 100755 index 0000000..ebd852c --- /dev/null +++ b/rrdb/create.sh @@ -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 + + + + \ No newline at end of file diff --git a/rrdb/getvalues.sh b/rrdb/getvalues.sh new file mode 100755 index 0000000..861ade4 --- /dev/null +++ b/rrdb/getvalues.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +source ./commun.sh + +rrdtool fetch $RRDB LAST | +tr -d ':' | +awk ' + (!/nan/ && NF==2) { print $1, $2 } + ' \ + > toto + +gnuplot << __EOC__ +set term png size 800,600 +set output "graphe.png" +plot "toto" with lines +__EOC__ + +rm toto + diff --git a/rrdb/insert.sh b/rrdb/insert.sh new file mode 100755 index 0000000..3990eb0 --- /dev/null +++ b/rrdb/insert.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source ./commun.sh + +ctime=$(date +'%s') +value=$(cut -d ' ' -f 1 /proc/loadavg) + +# write value to a file +echo ${ctime} ${value} | tee -a bar.dat + +# inject value in the rrdb file +rrdtool update $RRDB ${ctime}:${value} + +