如何处理 snmp 陷阱故障
我使用 pgrep 命令持续监视进程,并使用 snmp4j 将陷阱发送到另一台计算机。
这是我监视进程的代码:
String[] process = new String[] {"/bin/sh", "-c","pgrep httpd" };
Process proc = new ProcessBuilder(process).start();
InputStreamReader input = new InputStreamReader(proc.getInputStream());
BufferedReader reader = new BufferedReader(input);
String line = reader.readLine();
int rc = proc.waitFor();
reader.close();
input.close();
我使用 iptables 限制发送到计算机的陷阱数量,但是每当陷阱计数增加到配置的计数以上时,我就会收到以下错误:
org.snmp4j.MessageException: Operation not permitted
at org.snmp4j.MessageDispatcherImpl.sendPdu(Unknown Source)
at org.snmp4j.Snmp.sendMessage(Unknown Source)
at org.snmp4j.Snmp.send(Unknown Source)
at org.snmp4j.Snmp.send(Unknown Source)
当我收到此错误 /proc/(pid) 时机器中的 /fd 计数也会增加,然后达到最大 fd 计数,我收到以下错误消息:
- “消息:打开的文件太多 java.net.SocketException:太多 打开文件”
- 无法运行程序“/bin/sh”: java.io.IOException:错误=24,也是 许多打开的文件。
我该如何解决这个问题?
I am continuously monitoring a process by using pgrep command and sending traps to another machine by using snmp4j.
This is my code to monitor the process:
String[] process = new String[] {"/bin/sh", "-c","pgrep httpd" };
Process proc = new ProcessBuilder(process).start();
InputStreamReader input = new InputStreamReader(proc.getInputStream());
BufferedReader reader = new BufferedReader(input);
String line = reader.readLine();
int rc = proc.waitFor();
reader.close();
input.close();
I am limiting the number of traps sent to the machine with iptables but whenever the trap count increases above the configured count, I get the following error:
org.snmp4j.MessageException: Operation not permitted
at org.snmp4j.MessageDispatcherImpl.sendPdu(Unknown Source)
at org.snmp4j.Snmp.sendMessage(Unknown Source)
at org.snmp4j.Snmp.send(Unknown Source)
at org.snmp4j.Snmp.send(Unknown Source)
When I get this error /proc/(pid)/fd count also increases in the machine then reaches the maximum fd count and I get theese error messages:
- "MESSAGE: Too many open files
java.net.SocketException: Too many
open files" - Cannot run program "/bin/sh":
java.io.IOException: error=24, Too
many open files.
How can I resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论