I'm trying to store ADSL stats for my router. I didn't do rrdtool info on the others beccause they are now showing the correct value after using the same command as in the script to update. The weird thing is that the actual float values are store fine.

Both of the values are GAUGE.

root@pi:/scripts# ./routerstats.sh&&rrdtool info rrd/attn.rrd|grep last 
+ awk ' /^Max/      { maxup = $5; maxdown = $10; }
    /^Channel/  { curup = $6; curdown = $11; }
    /^SNR/      { snrdown = $3; snrup = $4; }
    /^Attn/     { attndown = $2; attnup = $3; }
    /^Pwr/      { pwrdown = $2; pwrup = $3; }
    END     { up = sprintf("N:%s:%s", maxup, curup);
              down = sprintf("N:%s:%s", maxdown, curdown);
              snr = sprintf("N:%s:%s", snrdown, snrup);
              attn = sprintf("N:%s:%s", attndown, attnup);
              pwr = sprintf("N:%s:%s", pwrdown, pwrup);
              system("echo up " up);
              system("echo down " down);
              system("echo snr " snr);
              system("echo attn " attn);
              system("echo pwr " pwr);
              system("rrdtool update /scripts/rrd/up.rrd -t max N:" maxup);
              system("rrdtool update /scripts/rrd/down.rrd -t max N:" maxdown);
              system("rrdtool update /scripts/rrd/snr.rrd -t down N:" snrdown);
              system("rrdtool update /scripts/rrd/attn.rrd -t down N:" attndown);
              system("rrdtool update /scripts/rrd/pwr.rrd -t down N:" pwrdown);
              system("rrdtool update /scripts/rrd/up.rrd -t current N:" curup);
              system("rrdtool update /scripts/rrd/down.rrd -t current N:" curdown);
              system("rrdtool update /scripts/rrd/snr.rrd -t up N:" snrup);
              system("rrdtool update /scripts/rrd/attn.rrd -t up N:" attnup);
              system("rrdtool update /scripts/rrd/pwr.rrd -t up N:" pwrup);
up N:1080:512
down N:10788:2048
snr N:20.4:12.0
attn N:26.0:15.0
pwr N:5.1:4.0
' to float not complete: tail 'nversion of '12.0
' to float not complete: tail 'onversion of '15.0
' to float not complete: tail 'nversion of '4.0
last_update = 1441477923
ds[down].last_ds = "U"
ds[up].last_ds = "U"

The data passed into awk:

Status: Showtime
Last Retrain Reason:    0
Last initialization procedure status:   0
Max:    Upstream rate = 1120 Kbps, Downstream rate = 10816 Kbps
Channel:        FAST, Upstream rate = 512 Kbps, Downstream rate = 2048 Kbps

Link Power State:       L0
Mode:                   G.DMT 
TPS-TC:                 ATM Mode
Trellis:                ON
Line Status:            No Defect
Training Status:        Showtime
                Down            Up
SNR (dB):        21.4            12.0
Attn(dB):        26.0            15.0
Pwr(dBm):        5.0             2.9

Judging by the corruption of the error message:

conversion of '12.0' to float not complete: tail '...'

it is probably that your data has carriage-returns at the end of the lines. These are not treated as whitespace by awk on unix. The simplest solution is to pipe your data through

sed 's/\r$//'

for example, before passing it through awk.

  • Sorry, I edited the question. it won't work because then awk won't have any \r to look for the beginning of each line. Could it be used just before passing the data to rrdtool? – Wilhelm Erasmus Sep 5 '15 at 19:47
  • Pass your data through cat -vet to visualise all the control characters and newlines (shown by $ at end of line). carriage-return appears as ^M, tab as ^I and so on. If lines have no newline but only carriage-return, you can convert the carriage-return to newline with tr '\r' '\n'. – meuh Sep 6 '15 at 7:00
  • When I do the sed 's/\r$//' it seems to remove all the internal newlines as well as the carriage-returns. There's a problem with the login at the moment but it now shows: spawn telnet Trying Connected to Escape character is '^]'. TD-X0000 0.0 DSL Modem Router Authorization failed after trying 5 times!!!. Please login after 452 seconds! Connection closed by foreign host.$ – Wilhelm Erasmus Sep 6 '15 at 9:50
  • I'm not sure what is going on. Try to keep the various stages separate using files to hold the intermediate data and check with cat -vet on the file to see what is happening at each stage. The sed is to apply only to the saved data coming from the telnet. – meuh Sep 6 '15 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.