Nagios + Event Handler + Java program

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Infrastructure Monitoring Nagios + Event Handler + Java program
# 1  
Old 03-09-2009
Nagios + Event Handler + Java program

Hi,

I am trying to start a java program from nagios event handler at CRITICAL + SOFT + 3 or CRITICAL + HARD status.


My Observations:
I used the echo command in mytest.sh and am getting the result in the nagios.debug log file.
But when I am running the java command in mytest.sh script that java program is not executing on port 7000.
I double checked on the permission and everything look good to me.



Following is my configuration status.

Nagios 3.0.7

JDK 1.5.0_07

define service {
service_description MY_XYZ_SERVICE
name MyxyzService
use tcp-service
contact_groups Admins
check_command check_tcp!7000
event_handler restart_xyz
hostgroup_name appservers
}



define command{
command_name restart_xyz
command_line /home/test/test1.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}


test1.sh
---------

#!/bin/sh

case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
SOFT)
case "$3" in
3)
echo -n "Restarting Myxyz service (3rd soft critical state)..."
/home/xyz/mytest.sh
;;
esac
;;

HARD)
echo -n "Restarting Myxyz service..."
/home/xyz/mytest.sh
;;
esac
;;
esac
exit 0


mytest.sh
-----------


#!/bin/bash

# echo "hello world This works perfectly when I remove the comment but the below java command is not executed."

nohup java -Xrs com.test.xyz.MyXYZServer 7000 &
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

java compile and run program help

What is the trick to get a java program to run and compile? I can't even get a basic skeleton to run and compile. What packages do I need? I figured the java-gcj and gcc-java packages was enough. Do I need any other packages? I thought I had to do this and it would work but its not. javac... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Programming

Program java arguments

Hello, The arguments are strings. In my code I need them to be a different type, I do the cast but it is not feasible ... Have you any idea? Thank you (8 Replies)
Discussion started by: chercheur857
8 Replies

3. Programming

need logic for java program

Hi All, I need to to wright a java programm for the following query. Qus: output need to genarate a number+ alphnumric sequence in java and get converted into ASCII code so that i can use mod logic on that. example Output: like 10 digit number 1AAAAAAAAA 1AAAAAAAAB 1AAAAAAAAC . .... (4 Replies)
Discussion started by: Ganesh Khandare
4 Replies

4. Shell Programming and Scripting

Executing a Java Program

I am entirely new to shell scripting and would like to create a script to execute a java program called Main. I've already compiled it and placed the .java and .class files at /root/javaTest. Next I made a shell script that simply contained: java /root/javaTest/Main . I made the script... (2 Replies)
Discussion started by: hypnotic_meat
2 Replies

5. Linux

running java program question

hi, i have just written a simple hello world java program in my linux server, installed jdk ... and tried to compile and run it and it gave me some errors. please details below: # cat HelloWorld.java import java.util.*; import java.io.*; public class HelloWorld { public static void... (4 Replies)
Discussion started by: k2k
4 Replies

6. UNIX for Dummies Questions & Answers

using a variable from java program in unix

Hi, I need to execute a java program in a shell script.I then need to assign the value being returned by the program into a unix variable.Is there any way i can access the value in a variable in java program? As in if my java code has a variable, . . . . valueA =x.getValue() ..... can... (1 Reply)
Discussion started by: inquisitive101
1 Replies

7. Shell Programming and Scripting

how can i run java program from any where

Hello all sorry didnt know where to post it i compiled simple program that using "System.getProperty("user.dir");" now i compiled the program under directory foo and and its running great when i do "java myapp" i included this directory in the $PATH env variable so i could see it fro any where... (1 Reply)
Discussion started by: umen
1 Replies

8. UNIX for Dummies Questions & Answers

executing the su command from a java program.

Say in unix (AIX) m/c, I am logged in with s1 user and want to start process p1 with user credentials of s2. I can do manually in this way: #su - s2 #enter password for s2> somePassword $ p1 But all this I have to do through a java program. How to pass the password through program. One... (1 Reply)
Discussion started by: shailendrat
1 Replies

9. Programming

Communication between a java and c++ program

Hi, I have the following problem. I have 2 programs, a java program and a c++ program. These 2 programs have to communicate with each other in full duplex mode. I want to use pipes for this communication. So when the c++ program pust something on the stdout the java program must be able to read... (4 Replies)
Discussion started by: lmnt22
4 Replies
Login or Register to Ask a Question