MRTG和/或间隔一分钟不工作



我正在Ubuntu 16.04上测试MRTG 2.17.4。我将其配置为使用rrdtool来记录数据。我有"间隔:1"在我的/etc/mrtg.cfg.我在/etc/cron.编辑了cron作业D/mrtg为:

*/1 *   * * *   root    if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ] && [ -d "$(grep '^[[:space:]]*[^#]*[[:space:]]*WorkDir' /etc/mrtg.cfg | awk '{ print $NF }')" ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg --debug="time,log" 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi

请注意,我增加了调试选项"时间,日志"来帮助排除故障。在我的/var/log/mrtg/mrtg.log中,我看到按照预期每一分钟记录一次数据,但是它没有尝试每分钟计算一次吞吐量。相反,它每5分钟做一次。其他时候,它只是说"得到了???/???"

--time: prog start Sat Nov 12 21:54:01 2016
--time: loop start Sat Nov 12 21:54:01 2016
--time: snmp read start Sat Nov 12 21:54:01 2016
--time: target loop start Sat Nov 12 21:54:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479012841:171337092:172912456')
--log:  got: ???/???
--time: prog start Sat Nov 12 21:55:01 2016
--time: loop start Sat Nov 12 21:55:01 2016
--time: snmp read start Sat Nov 12 21:55:01 2016
--time: target loop start Sat Nov 12 21:55:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479012901:171686542:173262414')
--log:  got: 5804.75277777778/5813.21944444444
--time: prog start Sat Nov 12 21:56:02 2016
--time: loop start Sat Nov 12 21:56:02 2016
--time: snmp read start Sat Nov 12 21:56:02 2016
--time: target loop start Sat Nov 12 21:56:02 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479012962:172034542:173610922')
--log:  got: ???/???
--time: prog start Sat Nov 12 21:57:01 2016
--time: loop start Sat Nov 12 21:57:01 2016
--time: snmp read start Sat Nov 12 21:57:01 2016
--time: target loop start Sat Nov 12 21:57:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479013021:172376742:173953630')
--log:  got: ???/???
--time: prog start Sat Nov 12 21:58:01 2016
--time: loop start Sat Nov 12 21:58:01 2016
--time: snmp read start Sat Nov 12 21:58:01 2016
--time: target loop start Sat Nov 12 21:58:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479013081:172724742:174302138')
--log:  got: ???/???
--time: prog start Sat Nov 12 21:59:01 2016
--time: loop start Sat Nov 12 21:59:01 2016
--time: snmp read start Sat Nov 12 21:59:01 2016
--time: target loop start Sat Nov 12 21:59:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479013141:173077092:174654996')
--log:  got: ???/???
--time: prog start Sat Nov 12 22:00:02 2016
--time: loop start Sat Nov 12 22:00:02 2016
--time: snmp read start Sat Nov 12 22:00:02 2016
--time: target loop start Sat Nov 12 22:00:02 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479013202:173426542:175004954')
--log:  got: 5781.22263205829/5789.66200182149
--time: prog start Sat Nov 12 22:01:01 2016
--time: loop start Sat Nov 12 22:01:01 2016
--time: snmp read start Sat Nov 12 22:01:01 2016
--time: target loop start Sat Nov 12 22:01:01 2016
--log: RRDs::tune(/var/mrtg/192.168.1.40_24.rrd -a ds0:125000000 -a ds1:125000000 -d ds0:COUNTER -d ds1:COUNTER)
--log: RRDs::update(/var/mrtg/192.168.1.40_24.rrd, '1479013261:173768742:175347662')
--log:  got: ???/???

我不是特别担心它不计算每分钟的速率,但我需要数据存储在rrd数据库中。但是当我尝试使用rrdtool获取时,它仍然显示5分钟的数据。我哪里做错了?

rrdtool fetch 192.168.1.40_24.rrd AVERAGE -a -s -1h -r 1m -a
                            ds0                 ds1
1479010500: 1.0150000000e+04 1.0158466667e+04
1479010800: 1.0150000000e+04 1.0158466667e+04
1479011100: 1.0145166667e+04 1.0153661556e+04
1479011400: 1.0021447006e+04 1.0029884972e+04
1479011700: 5.8127796610e+03 5.8212468060e+03
1479012000: 5.7859754098e+03 5.7944147796e+03
1479012300: 5.8089454941e+03 5.8174389793e+03
1479012600: 5.8006990960e+03 5.8091662411e+03
1479012900: 5.8047527778e+03 5.8132194444e+03
1479013200: 5.7812226321e+03 5.7896620018e+03
1479013500: 5.7946912568e+03 5.8031847421e+03
1479013800: 5.8049794444e+03 5.8134465895e+03
1479014100: -nan -nan

谢谢!Difan

查看MRTG配置文件和RRD文件中rrdtool info的输出可能会有所帮助。

然而,可能的原因是您最初以5分钟的间隔创建RRD文件,然后稍后更改为1分钟的间隔。如果您这样做,那么MRTG将不会重新创建RRD文件,尽管它将更改为每1分钟收集一次数据。Mrtg只能更改RRD的MaxBytes,如果它在创建后被修改;其他设置(RRDRowCount, Interval)只能在初始创建时使用,并且随后在MRTG cfg文件中更改它们不会导致RRD文件更改。

如果在RRD文件上使用rrdtool info,您可能会看到它的步长为5分钟(300秒)。改变这个的唯一方法是删除RRD文件(丢失您的历史数据),并允许MRTG以60秒的间隔在您的cfg文件中指定重新创建它。

请注意,如果您的5min RRD文件中有很多有价值的历史数据,您必须保留这些数据,那么可以使用第三方实用程序将这些数据转储为XML并重新创建一个新的RRD,但是这个任务有点复杂。寻找rrdmigraterrdmerge。最新的RRDtool在这方面也有一些功能。

相关内容

  • 没有找到相关文章

最新更新