Home Forum Software New Firmware enables rrdtool graphing.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1421
    shogunx
    Participant

    Hi All,

    I operate node #11000001 in Daytona Beach, FL. I recently upgraded the firmware in this node to version 110. I also downloaded Pixel_K’s graphing script, but alas, it required a few more edits than just the relevant paths to get working with my firmware version. Also, I did not want to run from cron. I wound up with a small wrapper script that samples the data every 60 seconds, and several edits to the code itself. Here is the wrapper script:

    #!/bin/sh
    
    radd(){
            /home/shogunx/Pix.sh
            sleep 60
            radd
    }
    
    radd

    And here is the edited script. Note that data, graph and perhaps other paths will need to be updated for your local environment. As you can see, I simply placed these in a home directory, with the entire path defined in the variable. The IP address of the UradMonitor will need to be corrected for your network. I also changed the aspect ratio and size of the graph to better suit my needs, as well as outputting a temperature graph as well. Interestingly, the “cut” arguments specified the wrong data fields in my UradMonitor’s JSON output, so that had to be corrected as well.

    
    
    #!/bin/sh
    URL=http://192.168.23.72/j
    rrdpath="/usr/bin"
    rrddata="/home/shogunx/data/uRadMonitor"
    rrdscript="/home/shogunx/script"
    rrdgraph="/home/shogunx/graph/uRadMonitor"
    rrdfmt="--font AXIS:9: --font TITLE:9: --font UNIT:9: --font LEGEND:7: --font-render-mode mono --color ARROW#000000 --color GRID#8C8C8C --color MGRID#000000 -v \"cpm\" --alt-y-mrtg --width 1000 --height 600"
    jsondata=$( /usr/bin/curl -s $URL );
    v_cpm=$( echo $jsondata | cut -f 4 -d "," | cut -f 2  -d ":" )
    v_temp=$( echo $jsondata | cut -f 5 -d "," | cut -f 2  -d ":" )
    echo CPM : $v_cpm
    echo Temperature : $v_temp
    
    if ! [ -f $rrddata/uRadMonitor.rrd  ]; then
       $rrdpath/rrdtool create $rrddata/uRadMonitor.rrd -s 60 \
                DS:cpm:GAUGE:300:0:U   \
                DS:temp:GAUGE:300:-100:100  \
                RRA:AVERAGE:0.5:1:600  \
                RRA:AVERAGE:0.5:6:700  \
                RRA:AVERAGE:0.5:24:775 \
                RRA:AVERAGE:0.5:288:797 \
                RRA:MAX:0.5:1:600 \
                RRA:MAX:0.5:6:700 \
                RRA:MAX:0.5:24:775 \
                RRA:MAX:0.5:288:797
       echo fichier $rrddata/uRadMonitor.rrd cree
    fi
    
    $rrdpath/rrdtool updatev $rrddata/uRadMonitor.rrd N:$v_cpm:$v_temp
    
    $rrdpath/rrdtool graph --imgformat PNG $rrdgraph/rad-day.png   --start -86400 --end -600 --title "Radiation daily" $rrdfmt \
            DEF:cpm=$rrddata/uRadMonitor.rrd:cpm:AVERAGE \
                    AREA:cpm#00CCCC:"Count Per Minute\g" \
                            GPRINT:cpm:MAX:"  Maximum \: %5.1lf " \
                            GPRINT:cpm:AVERAGE:" Average \: %5.1lf " \
                            GPRINT:cpm:LAST:" Current \: %5.1lf \l"
    
    $rrdpath/rrdtool graph --imgformat PNG $rrdgraph/rad-week.png  --start -604800   -z    --title "Radiation weekly" $rrdfmt \
            DEF:cpm=$rrddata/uRadMonitor.rrd:cpm:AVERAGE \
                    AREA:cpm#00CCCC:"Count Per Minute\g" \
                            GPRINT:cpm:MAX:"  Maximum \: %5.1lf " \
                            GPRINT:cpm:AVERAGE:" Average \: %5.1lf " \
                            GPRINT:cpm:LAST:" Current \: %5.1lf \l"
    
    $rrdpath/rrdtool graph --imgformat PNG $rrdgraph/rad-month.png --start -2592000  -z    --title "Radiation monthly" $rrdfmt \
            DEF:cpm=$rrddata/uRadMonitor.rrd:cpm:AVERAGE \
                    AREA:cpm#00CCCC:"Count Per Minute\g" \
                            GPRINT:cpm:MAX:"  Maximum \: %5.1lf " \
                            GPRINT:cpm:AVERAGE:" Average \: %5.1lf " \
                            GPRINT:cpm:LAST:" Current \: %5.1lf \l"
    
    $rrdpath/rrdtool graph --imgformat PNG $rrdgraph/rad-year.png  --start -31536000 -z    --title "Radiation yearly" $rrdfmt \
            DEF:cpm=$rrddata/uRadMonitor.rrd:cpm:AVERAGE \
                    AREA:cpm#00CCCC:"Count Per Minute\g" \
                            GPRINT:cpm:MAX:"  Maximum \: %5.1lf " \
                            GPRINT:cpm:AVERAGE:" Average \: %5.1lf " \
                            GPRINT:cpm:LAST:" Current \: %5.1lf \l"
    
    $rrdpath/rrdtool graph --imgformat PNG $rrdgraph/temp-day.png   --start -86400 --end -600 --title "Temperature daily" $rrdfmt \
            DEF:cpm=$rrddata/uRadMonitor.rrd:temp:AVERAGE \
                    AREA:cpm#00CCCC:"Degrees Celsius\g" \
    • This topic was modified 9 years, 8 months ago by uRADMonitor.
    #1424
    uRADMonitor
    Keymaster

    Great stuff, I just promoted it to sticky. Thanks for sharing!

    #1428
    Bjorn Roesbeke
    Participant

    Where is the rrdscript variable used?

    #1434
    shogunx
    Participant

    Good eye, Bjorn. It appears to be declared, but unused. I just checked the directory, and there is no output to it. Perhaps Pixel had intended a use for it, but never implemented the function.

    #1435
    Pixel_K
    Participant

    Nice work, yes the value position shifted in the latest firmware (which added a missing comma), hence the additional modifications.

    you can delete the rrdscript line, it’s a leftover from earlier script version.

    I would use a while loop instead a recursive call, which is a bad practice in this case.

    #1436
    shogunx
    Participant

    Hi Pixel_K. Thank you, nice work yourself. Ack on the rrdscript line, and I understand the versioning problem on the cut arguments. Sure, while loop is cleaner. Cron is cleaner too, actually. I just wanted to leave the shell attached to an xterm, so I could watch the data as it comes in. Having scratched my itch, I decided that was good enough. Want to use this thread like a version control system, with the latest code revisions in the most recent posts?

    Ideally we could have the script act like an installer on the first run as well, asking the user what ip address the urad is on, where to store the data, etc. It could even test for curl and rrdtool on debian based derivatives (and likely others) and prompt an apt-get install of those if not present. I only say this because there will be a great many not so technical users, and we want to be able to collect data from their devices as well.

    #1444
    uRADMonitor
    Keymaster

    shogunx, for something as useful as this, let me know if you would like to do the version control in a blog post instead.

    #1486
    shogunx
    Participant

    That is probably a good idea.

    #1487
    Pixel_K
    Participant

    I still have to update mine to #111, but that’s a great idea, so the script can live it’s own life.

    #1488
    uRADMonitor
    Keymaster

    Scott, your account should now be able to write blog posts. Feel free to give it a try!

    #2058

    Meanwhile I’ve done my own implementation but written in Perl.

    Some key features are:
    – automatic conversion to uSv/h when generating the graphs (the conversion is done using the appropriate factor for the detector present in the device);
    – works with model A2 (pressure graphs).

    You can find it on GitHub.

    Also you can view the live graphs from my uRADMonitor device readings here.

    #2060
    uRADMonitor
    Keymaster

    Hi Nox, that’s another excellent contribution, thanks for sharing!

    As offered to the other guys, would you be interested in presenting your SW setup in a blog article, with backlinks to your website, I can update your account accordingly. Let me know.

    #3471
    Nicolas_Daly
    Participant

    Hi,

    Excellent post. I used to be mad about graphing everything and this is a good excuse to get back to it.

    I’ve gone for a 60 second step and added a trend of 2 Hours on the daily graph

    	 CDEF:trend_cpm=cpm,7200,TREND \
                    AREA:cpm#00CCCC:"Count Per Minute\g" \
                            GPRINT:cpm:MAX:" Maximum \: %5.1lf " \
                            GPRINT:cpm:AVERAGE:" Average \: %5.1lf " \
                            GPRINT:cpm:LAST:" Current \: %5.1lf \l"  \
    		  LINE2:trend_cpm#000000:"Count Per Minute Trend 2 Hour\g"   
    #3472
    Nicolas_Daly
    Participant

    Excuse the double post. I’ve found the odd time when curl requests hang so may I suggest changing

    jsondata=$( /usr/bin/curl -s $URL );
    to
    jsondata=$( /usr/bin/curl -s $URL --max-time 5 --retry 10 --retry-delay 1);

    #4541
    Urs Wirthmueller
    Participant

    The script looks great.

    Would it be possible to adapt it to the A3 model?

    Also – as I suppose the script does download the data locally. Is it possible to download those data from the uradmonitor server including the credentials in the script?

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.