磁盘故障检测perl脚本

发布于 2024-12-27 19:54:09 字数 244 浏览 2 评论 0原文

我需要编写一个脚本来每分钟检查磁盘并报告它是否因任何原因而失败。该错误可能是磁盘绝对故障和坏扇区等。

首先,我想知道是否有任何脚本可以执行与标准程序相同的操作(因为我真的不想重新发明轮子)。

其次,我想知道我是否想在 /var/log/messages 中查找错误,是否有我可以使用的磁盘标准错误字符串列表?

我在网上查找了很多,有很多信息,但同时却没有相关信息。

任何帮助将不胜感激。

谢谢,

I need to write a script to check the disk every minute and report if it is failing by any reason. The error could be the absolute disk failure and a bad sector and so on .

First, I wonder if there is any script out there that does the same as it should be a standard procedure (because I really do not want to reinvent the wheel).

Second, I wonder if I want to look for errors in /var/log/messages, is there any list of standard error strings for disks that I can use?

I look for that on the net a lot, there are lots of info and at the same time no info about that.

Any help will be much appreciated.

Thanks,

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

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

发布评论

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

评论(2

┊风居住的梦幻卍 2025-01-03 19:54:09

您可以简单地解析 dmesg 的输出,它通常会报告相当详细的信息关于驱动器错误,这就是我之前收集故障驱动器统计信息的方式。

通过使用 Parse,您可能会获得更好、更详细的记录信息: :Syslog 或较低级别的内核直接报告。

You could simply parse the output of dmesg which usually reports fairly detailed information about drive errors, well that's how I've collected stats on failing drives before.

You might get better more well documented information by using Parse::Syslog or lower level kernel reporting directly though.

欲拥i 2025-01-03 19:54:09

Logwatch 执行考验的 /var/log/messages 部分(以及您选择添加的任何其他日志文件)。您可以选择使用它,或者使用它的代码来推出您自己的解决方案(全部都是用 perl 编写的)。

如果您的硬盘支持 SMART,我建议您使用 smartctl 输出进行诊断,因为它包含许多很好的信息,可以随着时间的推移进行监控以检测故障。

Logwatch does the /var/log/messages part of the ordeal (as well as any other logfiles that you choose to add). You can either choose to use that, or to use its code to roll your own sollution (it's all written in perl).

If your harddrives support SMART, i suggest you use smartctl output for diagnostics as it includes a lot of nice info that can be monitored over time to detect failure.

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