REST API无法正常工作

时间:2015-10-21 10:26:13

标签: java rest nagios

如果我们在命令行中运行以下命令,它可以正常工作。但是当我们从基于nagios的工具运行此命令时,它会出现以下错误: -

java -jar /opt/monitor/nagios/notify/REST/RestInterface.jar 
/opt/monitor/nagios/notify/REST/settings.xml "2015-10-20 12:57:11" L  

结果代码:1

错误输出:

java.io.IOException: Couldn't get lock for RestInterface.log    
        at java.util.logging.FileHandler.openFiles(FileHandler.java:389)    
        at java.util.logging.FileHandler.(FileHandler.java:363)    
        at com.google.nagios.notify.RestInterface.loggerInit(Unknown Source)    
        at com.google.nagios.notify.RestInterface.main(Unknown Source)    
Oct 20, 2015 12:57:11 PM com.google.nagios.notify.RestInterface logToOS  
SEVERE: null  
java.io.IOException: Cannot run program "EVENTCREATE": error=2, No such file   or directory    
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)    
        at java.lang.Runtime.exec(Runtime.java:617)    
        at java.lang.Runtime.exec(Runtime.java:450)    
          at java.lang.Runtime.exec(Runtime.java:347)    
        at com.google.nagios.notify.RestInterface.logToOS(Unknown Source)    
         at com.google.nagios.notify.RestInterface.loggerInit(Unknown Source)    
        at com.google.nagios.notify.RestInterface.main(Unknown Source)  
Caused by: java.io.IOException: error=2, No such file or directory    
        at java.lang.UNIXProcess.forkAndExec(Native Method)    
        at java.lang.UNIXProcess.(UNIXProcess.java:186)  
        at java.lang.ProcessImpl.start(ProcessImpl.java:130)    
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)    
        ... 6 more  
Exception in thread "main" java.lang.NullPointerException      
        at com.google.nagios.notify.RestInterface.loggerInit(Unknown Source)      
        at com.google.nagios.notify.RestInterface.main(Unknown Source)    

1 个答案:

答案 0 :(得分:2)

似乎RestInterface.log被其他进程锁定。只需杀死其他进程即可写入文件。