如何将许多RRD文件导出到XML文件

发布于 2025-01-30 14:11:38 字数 463 浏览 1 评论 0原文

我有一组旧的RRD文件,因此我需要将它们转换为XML文件,然后在新服务器中再次转换为RRD文件。为了从整个目录创建XML文件,我使用了以下简单bash脚本。

#!/bin/bash

cd /varcacti/rra


for i in ./traffic_in*;
do
/usr/local/rrdtool/bin/rrdtool dump $i /home/newuser/rrd_dump_xml/$i.xml;
done

这提供了一组XML文件,但扩展名并不是我实际需要的。这提供了,

traffic_in_1111.rrd>>>traffic_in_1111.rrd.xml

但是我需要friffate_in_1111.rrd>>> clocals_in_1111.xml。有人可以帮助我修改我的代码吗?

I have set of old rrd files, so I need to convert them to xml files and again to rrd files in a new server. In order to create xml files from whole directory, I have used following simple bash script.

#!/bin/bash

cd /varcacti/rra


for i in ./traffic_in*;
do
/usr/local/rrdtool/bin/rrdtool dump $i /home/newuser/rrd_dump_xml/$i.xml;
done

This provides a set of xml files but the extension is not what I required actually. This provides,

traffic_in_1111.rrd>>>traffic_in_1111.rrd.xml

But I need traffic_in_1111.rrd>>>traffic_in_1111.xml. can someone help me to modify my code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨光如昨 2025-02-06 14:11:38

您想要

/home/newuser/rrd_dump_xml/"${i%.rrd}".xml
#..........................^^^^^^^^^^^

从字符串末端删除RRD扩展名。

您可能希望更具体地说明您要循环的文件:

for i in ./traffic_in*.rrd

You want

/home/newuser/rrd_dump_xml/"${i%.rrd}".xml
#..........................^^^^^^^^^^^

which removes the rrd extension from the end of the string.

You might want to be more specific with the files you're looping over:

for i in ./traffic_in*.rrd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文