开发者

How to handle snmp traps failures

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 t开发者_如何学运维hen 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜