Menu

creating graph and statistics

JensH
2009-06-23
2012-12-14
  • JensH

    JensH - 2009-06-23

    Hi,
    I have recently installed and configured  RRDTool (http://oss.oetiker.ch/rrdtool/) on my Linkstation to create weather graphs from my ABB EIB weather station by using linknx as "wrapper". Is someone interested learning how this works? If yes, I could write down my experience in some HOWTO.

    I could also imagine, that graphs can be created from other values - like
    1) timely "traffic" distribution, measured with motion detectors,
    2) average duration of lights burning
    3) temperatures in a building over time
    etc...

    AND it could be an option, to extend KnxWeb to show the history graphs for a device ... but this is just an early idea.

    Is this of any interest?
    Best Regards, Jens

     
    • jef2000

      jef2000 - 2009-06-24

      Hi,

      I have created a section "Interesting tools" in the wiki and an entry called "
      How to create graphs with RRDTool". You can describe your experience there. It will for sure be interesting.

      http://linknx.wiki.sourceforge.net/How+to+create+graphs+with+RRDTool

      Regards,

      Jean-François

       
    • EPIX

      EPIX - 2009-06-25

      YES!!

      I'm VERY interested
      (Also how you installed and configured RRD)

      Greez
      EPIX

       
    • JensH

      JensH - 2009-06-25

      OK, good to know. Will do in the next days - latest after the weekend.
      BR Jens

       
    • JensH

      JensH - 2009-07-21

      Ok, done in a first version
      BR auto-mate

       
  • nightflyer502

    nightflyer502 - 2011-09-13

    Hi!

    Unfortunaly I have ha RRD-Tool problem to solve.

    I log the temperature every minute. I do this every day, week, month and year.
    I also want to to display this on a graph.
    As far as I've already managed, but the monthly/yearly graph is a bit confusing.

    Is it possible to bring rrd-tool to display only the daily minimum and maximum values ​​as a monthly/yearly graph?

    I would be very pleased about help!
    Thank you very much!

    Hannes

     
  • Othmar

    Othmar - 2011-09-13

    Is it possible to bring rrd-tool to display only the daily minimum and maximum values ​​as a monthly/yearly graph

    If you have used definitions for MIN and MAX when creating your RRD  then you can just use these definitions on the graph.
    If you have not used these definitions when creating the RRD you have no chance I think because all you have in your database are average values for the time steps (typically 2hours for monthly or halfday for yearly) defined by your RRD.
    Even if you update every minute your RRD typically only stores the 5min average values, again depending on the RRD definition.
    Regards, Othmar

     
  • nightflyer502

    nightflyer502 - 2011-09-15

    hmmm…

    I've created my databases like it is described in this howto ->
    https://sourceforge.net/apps/mediawiki/linknx/index.php?title=How_to_create_graphs_with_RRDTool

    Im sorry im not a rrdtool-Pro.

    How should i change this scripts so that they only display the daily max and the daily min temp over a period, for example a month?

    Thank you very very very much!

     
  • JensH

    JensH - 2011-09-16

    Hi,
    if you have used the definition as in the wiki above, the following should create the daily min/max graph over the a month time. (at least it does for me)
    I run this daily once.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    #!/usr/bin/perl
    ###########################################
    ###########################################
    use warnings;
    use strict;
    use lib "/opt/lib/perl5"; 
    use RRDs;
    use Getopt::Std;
    my %opt;
    
    getopts('ugf', \%opt);
    
    my $DB_temp     = "/var/rrdtool/temp.rrd";
    my $SERVER = "/var/rrdtool";
    my $PIC = "/opt/rrdtool/www"; 
    if(exists $opt{g}) {
      RRDs::graph("$PIC/temp-m.png",
        "--vertical-label=Temperatur",
        "--start","end-1months",
        "--end", "now", 
        "--width","720","--height","200",
        "--x-grid", "DAY:1:WEEK:1:DAY:1:86400:%d",          
        "DEF:mytemp1=$DB_temp:temp:MIN",
        "DEF:mytemp2=$DB_temp:temp:AVERAGE",
        "DEF:mytemp3=$DB_temp:temp:MAX",
        "VDEF:tempmax=mytemp3,MAXIMUM",
        "VDEF:tempavg=mytemp2,AVERAGE",
        "VDEF:tempmin=mytemp1,MINIMUM",
        "COMMENT:         \\n",
        "AREA:mytemp3#FF000080:Maximum\\t",
        "GPRINT:tempmax:%2.1lf C\\n",
        "LINE1:mytemp3#FF0000",
        "AREA:mytemp1#FFFFFF",
        "AREA:mytemp1#A0A0FF80",
        "LINE1:mytemp1#0000FF",
        "LINE1:tempmin#0000FF:Minimum\\t",      
        "GPRINT:tempmin:%2.1lf C\\n",
        "LINE1:tempavg#00FF00:Average\\t",
        "GPRINT:tempavg:%2.1lf C\\n",   
        "LINE1:tempmax#FF0000",
        "LINE1:tempavg#00FF00", 
        ) or
            die "graph failed ($RRDs::error)";  
     }
    

    This is the weekly & 3 day view:
    (I made the 3days to have mor details shown)

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    #!/usr/bin/perl
    ###########################################
    ###########################################
    use warnings;
    use strict;
    use lib "/opt/lib/perl5"; 
    use RRDs;
    use Getopt::Std;
    my %opt;
    
    getopts('ugf', \%opt);
    
    my $DB_temp     = "/var/rrdtool/temp.rrd";
    my $SERVER = "/var/rrdtool";
    my $PIC = "/opt/rrdtool/www"; 
    if(exists $opt{g}) {
      RRDs::graph("$PIC/temp-w.png",
        "--vertical-label=Temperatur",
        "--start","end-7d",
        "--end", "now", 
        "--width","720","--height","200",
        "--x-grid", "HOUR:3:DAY:1:DAY:1:86400:%A",  
        "DEF:mytemp1=$DB_temp:temp:MIN",
        "DEF:mytemp2=$DB_temp:temp:AVERAGE",
        "DEF:mytemp3=$DB_temp:temp:MAX",
        "VDEF:tempmax=mytemp3,MAXIMUM",
        "VDEF:tempavg=mytemp2,AVERAGE",
        "VDEF:tempmin=mytemp1,MINIMUM",
        "COMMENT:         \\n",
        "AREA:mytemp3#FF000080:Maximum\\t",
        "GPRINT:tempmax:%2.1lf C\\n",
        "LINE1:mytemp3#FF0000",
        "AREA:mytemp1#FFFFFF",
        "AREA:mytemp1#A0A0FF80",
        "LINE1:mytemp1#0000FF",
        "LINE1:tempmin#0000FF:Minimum\\t",      
        "GPRINT:tempmin:%2.1lf C\\n",
        "LINE1:tempavg#00FF00:Average\\t",
        "GPRINT:tempavg:%2.1lf C\\n",   
        "LINE1:tempmax#FF0000",
        "LINE1:tempavg#00FF00", 
        ) or
            die "graph failed ($RRDs::error)";  
                 
    ###########################################
    # 3 days History
    ###########################################
      RRDs::graph("$PIC/temp-3d.png",
        "--vertical-label=Temperatur",
        "--start","now-3d",
        "--end", "now", 
        "--width","1024","--height","200",
        "--x-grid", "MINUTE:60:HOUR:6:HOUR:6:0:%a:%H:00",
        "DEF:mytemp1=$DB_temp:temp:MIN",
        "DEF:mytemp2=$DB_temp:temp:LAST",
        "DEF:mytemp3=$DB_temp:temp:MAX",
        "VDEF:tempmax=mytemp3,MAXIMUM",
        "VDEF:tempavg=mytemp2,AVERAGE",
        "VDEF:tempmin=mytemp1,MINIMUM",
        "VDEF:templast=mytemp2,LAST",
        "AREA:mytemp3#FF000044:Maximum\\t",
        "GPRINT:tempmax:%2.1lf C\\n",
        "AREA:mytemp1#FFFFFF",
        "LINE1:tempmin#0000FF:Minimum\\t",      
        "GPRINT:tempmin:%2.1lf C\\n",
        "LINE1:tempavg#00FF00:Average\\t",
        "GPRINT:tempavg:%2.1lf C\\n",   
        "LINE1:mytemp2#000000:Actual\\t",
        "GPRINT:templast:%2.1lf C\\n",
        "LINE1:tempmax#FF0000",
        "LINE1:tempavg#00FF00", 
        ) or
            die "graph failed ($RRDs::error)";
    
    }
    

    This is the one, which generates the Annual overview:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    #!/usr/bin/perl
    ###########################################
    ###########################################
    use warnings;
    use strict;
    use lib "/opt/lib/perl5"; 
    use RRDs;
    use Getopt::Std;
    my %opt;
    
    getopts('ugf', \%opt);
    
    my $DB_temp     = "/var/rrdtool/temp.rrd";
    my $SERVER = "/var/rrdtool";
    my $PIC = "/opt/rrdtool/www"; 
    if(exists $opt{g}) {
      RRDs::graph("$PIC/temp-y.png",
        "--vertical-label=Temperatur",
        "--start","end-1years",
        "--end", "now", 
        "--width","720","--height","200",
        "--x-grid", "WEEK:1:MONTH:1:MONTH:1:2500000:%b",            
        "DEF:mytemp1=$DB_temp:temp:MIN",
        "DEF:mytemp2=$DB_temp:temp:AVERAGE",
        "DEF:mytemp3=$DB_temp:temp:MAX",
        "VDEF:tempmax=mytemp3,MAXIMUM",
        "VDEF:tempavg=mytemp2,AVERAGE",
        "VDEF:tempmin=mytemp1,MINIMUM",
        "COMMENT:         \\n",
        "AREA:mytemp3#FF000080:Maximum\\t",
        "GPRINT:tempmax:%2.1lf C\\n",
        "LINE1:mytemp3#FF0000",
        "AREA:mytemp1#FFFFFF",
        "AREA:mytemp1#A0A0FF80",
        "LINE1:mytemp1#0000FF",
        "LINE1:tempmin#0000FF:Minimum\\t",      
        "GPRINT:tempmin:%2.1lf C\\n",
        "LINE1:tempavg#00FF00:Average\\t",
        "GPRINT:tempavg:%2.1lf C\\n",   
        "LINE1:tempmax#FF0000",
        "LINE1:tempavg#00FF00", 
        ) or
            die "graph failed ($RRDs::error)";  
                 
    }
    

    Hope that helps, best Regards, Jens.

    PS.: I know there is an issue with the rendering the negative maximum temperatures - The numbers are ok, but the area-fill could be done better. But I was too lazy to change this by now. You can just switch to lines instead of areas, if you want.

     
  • nightflyer502

    nightflyer502 - 2011-09-17

    Hi Jens!

    You are my personal Hero!

    It works really perfekt and fits to 100 percent!

    Thank you very much!

    LG Hannes

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.