2008年(91)
分类: LINUX
2008-03-23 18:44:33
以前生成的mrtg图,此时如果服务器做了调整,那么就要重新抓包,然后生成cfg文件。也就是说第一步和第二步,第三步要重新做了。可以覆盖原来那个cfg,但是前提是因为原来的cfg中的community没有变。否则不能覆盖。
本来有cfg 我没有删除,直接想覆盖原来的数据,所以用了:
/usr/local/mrtg/bin/cfgmaker --output=/home/mrtgqy/mrtgqy13703.cfg --global "WorkDir:/home/mrtg/"
--global "Options[_]: growright, bits" --snmp-options=:::::2
但是没有想到,cfg中的信息是不能被覆盖的。只有.png .gif .log这些历史数据才是有用的。
所以这些数据保存下来,而.cfig文件,删除重新生成。注意:其中的脚步,不能删哦。
92:/home/mrtgqy# ls
cfg.sh mrtg137200.cfg mrtg137205.ok mrtg138204.cfg mrtg158200.ok mrtgqy137200.ok
mrtg136200.cfg mrtg137200.ok mrtg137206.cfg mrtg138204.ok mrtg245129.cfg mrtgqy137201.cfg
mrtg136200.ok mrtg137201.cfg mrtg137206.ok mrtg138205.cfg mrtg245129.ok mrtgqy137201.ok
mrtg136201.cfg mrtg137201.ok mrtg138200.cfg mrtg138205.ok mrtg711.cfg mrtgqy137203.cfg
mrtg136201.ok mrtg137202.cfg mrtg138200.ok mrtg138206.cfg mrtg711.ok mrtgqy137203.ok
mrtg136202.cfg mrtg137202.ok mrtg138201.cfg mrtg138206.ok mrtgqy136200.cfg mrtg.sh
mrtg136202.ok mrtg137203.cfg mrtg138201.ok mrtg138209.cfg mrtgqy136200.ok mrtgzw136200.cfg_l
mrtg136203.cfg mrtg137203.ok mrtg138202.cfg mrtg138209.ok mrtgqy136201.cfg
mrtg136203.ok mrtg137204.cfg mrtg138202.ok mrtg138211.cfg mrtgqy136201.ok
mrtg136204.cfg mrtg137204.ok mrtg138203.cfg mrtg138211.ok mrtgqy13703.cfg
mrtg136204.ok mrtg137205.cfg mrtg138203.ok mrtg158200.cfg mrtgqy137200.cfg
192:/home/mrtgqy# less mrtg136200.cfg
# Created by
# /usr/local/mrtg/bin/cfgmaker --output=/home/mrtgqy/mrtg136200.cfg --global 'WorkDir: /home/mrtg' --global
'Options[_]:growright,bits' --snmp-options=:::::2
重新生成新的cfg但是原来的community是不会变的。
192:/home/mrtgqy# env LANG=C /usr/local/mrtg/bin/mrtg /home/mrtgqy/mrtg711.cfg &
[1] 4454
192:/home/mrtgqy# perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US",
LANG = "C"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
env LANG=C /usr/local/mrtg/bin/mrtg /home/mrtgqy/mrtg711.cfg
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US",
LANG = "C"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
是字体设置的问题。因为这个是debian 的系统
less locale.gen
# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED. Other
# combinations are possible, but may not be well tested. If you change
# this file, you need to rerun locale-gen.
#
en_US.UTF-8 UTF-8
en_US ISO-8859-1
zh_CN GB2312
zh_CN.GBK GBK
要添加这四个东西。然后运行/usr/sbin/locale-gen即可
当系统重新装后,原来备份的数据都是png格式的。这样原来的历史数据就做费了,杂个办呢?难道把现在生成的几百个服务器的cfg。全部删了。干脆把原来的png格式的图像文件改成.gif的。
ls /etc/mrtg/mrtg
10.163.18.74_7-month.png 10.163.23.25_1-month.png 10.163.28.3_75498298-year.gif
10.163.18.37_24-week.gif 10.163.18.74_7.old 10.163.23.25_1.old 10.163.28.3_75498298-year.png
10.163.18.37_24-week.png 10.163.18.74_7-week.gif 10.163.23.25_1-week.png 10.163.28.3_75498306-day.gif
10.163.18.37_24-year.gif 10.163.18.74_7-week.png 10.163.23.25_1-year.png 10.163.28.3_75498306-day.png
10.163.18.37_24-year.png 10.163.18.74_7-year.gif 10.163.23.25_21-day.png 10.163.28.3_75498306.html
10.163.18.42_10-day.gif 10.163.18.74_7-year.png 10.163.23.25_21.html 10.163.28.3_75498306.log
10.163.18.42_10-day.png 10.163.18.74_8-day.gif 10.163.23.25_21.log 10.163.28.3_75498306-month.gif
10.163.18.42_10.html 10.163.18.74_8-day.png 10.163.23.25_21-month.png 10.163.28.3_75498306-month.png
10.163.18.42_10.log 10.163.18.74_8.html 10.163.23.25_21.old
这个中原来的历史数据是..png的。而今天生成的数据是.gif 的,所以我们上午做的拷贝历史数据就完全没有意义了。郁闷呀。郁闷。
原因何在????因为我上午安装的GD库的版本太高了。不支持png的。那么怎么把成千上万的.png的文件换成.gif的文件呢。首先想到的事脚本实现。
此时想到了脚步的应用:rename
find -type f -name '*.png' | xargs rename 's/\.png$/\.gif/'
如果有的系统不是debian的,就不支持rename。所以要单独变成来实现:
find -type f -name '*.png' | xargs -n1 | while read ABC; do echo $ABC && mv $ABC ${ABC%.png}.gif ; done