[rrd-users] how can i rebuild my rrd files ?

mozatkey mozatkey at gmail.com
Mon Jul 9 04:53:49 CEST 2012



于 2012年07月04日 09:48, mozatkey 写道:
> thanks Karl, about #2
>
> i am trying this:
> 1.rrdtool dump old.rrd tmp.xml
> 2.modify tmp.xml add HWPREDICT SEASONAL DEVSEASONAL DEVPREDICT 
> FAILURES default unkonwn
> 3.rrdtool restore tmp.xml new.rrd
>
i did this on my rrd files.
> if it works, i will response you as soon as possible.
>
and observed for a week, it works very well.
>
> 于 2012年07月02日 23:20, Karl Fischer 写道:
>> Am 02.07.2012 11:21, schrieb mozatkey:
>>> hi,all:
>>>
>>> 1. How can I get the creating script if only having xxx.rrd ?
>>> There are a lot of rrd files, i can't get all the creating script for
>>> each one, because they have been modified many times by handle 
>>> operation.
>>>
>>> 2.How can I set the HWPREDICT with those old rrd files?
>>> These old rrds files don't set the HWPREDICT, but now i have to use it.
>>>
>>> 3. Is there any orders like: "show create rrd" and "alter xxx.rrd add
>>> HWPREDICT" in rrdtool , just as what we did in pl/sql?
>> can't answer #2, but as a "show create" I'm using a little bash script.
>> On purpose it's bash only, no sed, no awk, no perl etc.
>>
>> It's not perfect (eg. doesn't support the HWPREDICT stuff etc.) but it
>> works for my purpose. Feel free to add the missing functions ...
>>
>> it works like this:
>>
>> showcreate.sh /tmp/CPU.rrd
>>
>> rrdtool create "/tmp/CPU.rrd"
>>          --step 2
>>          DS:loadavg:GAUGE:120:0:1e+03
>>          DS:user:COUNTER:120:0:1e+02
>>          DS:nice:COUNTER:120:0:1e+02
>>          DS:system:COUNTER:120:0:1e+02
>>          DS:iowait:COUNTER:120:0:1e+02
>>          DS:irq:COUNTER:120:0:1e+02
>>          DS:softrq:COUNTER:120:0:1e+02
>>          RRA:AVERAGE:5e-01:2:345600
>>          RRA:AVERAGE:5e-01:30:576000
>>          RRA:AVERAGE:5e-01:300:157680
>>          RRA:AVERAGE:5e-01:1800:52560
>>
>>
>> $ cat /usr/local/bin/showcreate.sh
>>
>> #!/bin/bash
>>
>> RRDTOOL=($(which rrdtool))
>>
>> function rrdinfo() {
>>    $RRDTOOL info $1 \
>>    | while read line; do
>>        key=${line%% = *}
>>        pri=${key%%[*}
>>        ind=${key%%]*}
>>        ind=${ind##*[}
>>        sub=${key##*.}
>>        value=${line##* = }
>>        num=${value/0000e/e}
>>        num=${num/0000e/e}
>>        num=${num/00e/e}
>>        num=${num/0e/e}
>>        num=${num/.e/e}
>>        num=${num/e+00/}
>>        num=${num/#NaN/U}
>>        case "$pri" in
>>          filename)
>>            echo "rrdtool create $value"
>>            ;;
>>          step)
>>            echo -e "\t--step $value"
>>            ;;
>>          ds)
>>            case "$sub" in
>>              value)
>>                echo -e "\tDS:$DS:$TYPE:$HB:$MIN:$MAX"
>>                ;;
>>              type)
>>                DS=$ind
>>                TYPE=${value//\"}
>>                case "$TYPE" in
>>                  GAUGE|COUNTER|DERIVE|ABSOLUTE)
>>                    # ok
>>                    ;;
>>                  *)
>>                    echo "unknown data source type $TYPE"
>>                    exit 1
>>                    ;;
>>                esac
>>                ;;
>>              minimal_heartbeat)
>>                HB=$value
>>                ;;
>>              min)
>>                MIN=$num
>>                ;;
>>              max)
>>                MAX=$num
>>                ;;
>>            esac
>>            ;;
>>          rra)
>>            case "$sub" in
>>              unknown_datapoints)
>>                if [ -n "$CF" ]; then
>>                  echo -e "\tRRA:$CF:$XFF:$PDPS:$ROWS"
>>                  CF=""
>>                fi
>>                ;;
>>              cf)
>>                CF=${value//\"}
>>                case "$CF" in
>>                  AVERAGE|MIN|MAX|LAST)
>>                    # OK
>>                    ;;
>>                  *)
>>                    echo "unknown consolidation $CF"
>>                    exit 1
>>                    ;;
>>                esac
>>                ;;
>>              xff)
>>                XFF=$num
>>                ;;
>>              pdp_per_row)
>>                PDPS=$num
>>                ;;
>>              rows)
>>                ROWS=$num
>>                ;;
>>            esac
>>            ;;
>>        esac
>>      done
>>      echo ""
>> }
>>
>> while [ -n "$1" ]; do
>>    if [ -r $1 ]; then
>>      rrdinfo $1
>>    fi
>>    shift
>> done
>
>




More information about the rrd-users mailing list