如何在RRD图参数的参数中添加公式?

时间:2017-09-05 04:34:09

标签: perl rrdtool rrd

E.g. I have following code,

our $timeseries = {
   _type      => 'array',
   _pdpstep   => 300,    # Time resolution
   _heartbeat => 700,    # Time of loss before going to Unknown
   _storage   => 'day',
   _ylabel    => "dBm",
   _mandatory => 'yes',

   # hwEntityOpticalRxPower dBm * 100
   ahwEORxPowre    => { label      => 'Rx Power',
                        type       => 'GAUGE',
                        probe      => '1.2.3.4.5.6.7.8',
                        min        => -3999,
                        multiplier => 0.01,
                      },

   # hwEntityOpticalTxPower dBm * 100
   bhwEOTxPower    => { label      => 'Tx Power',
                        type       => 'GAUGE',
                        probe      => '1.2.3.4.5.6.7.8',
                        # -4000 means no signal
                        min        => -3999,
                        multiplier => 0.01,
                      },

};

这个数据是mw(毫瓦),我想把它转换成分贝 - 毫瓦(dBm),为此,我增加了乘数0.01值。但它没有以dBm为单位转换价值。我怎样才能做到这一点?我可以在这里添加任何公式吗?

1 个答案:

答案 0 :(得分:1)

使用子例程并将数据传递给它。

data => calc(0.01),

然后在其他地方定义子例程

sub calc
{
    my $var = shift;
    return $var+100;
}