1 |
torben |
2009 |
package dk.daoas.PumpClient; |
2 |
|
|
|
3 |
|
|
import org.datacontract.schemas._2004._07.DaoMqPump2.StatusData; |
4 |
|
|
import org.tempuri.RemoteControlLocator; |
5 |
|
|
|
6 |
|
|
import Samples.ServiceModel.Microsoft.IRemoteControl; |
7 |
|
|
|
8 |
|
|
public class PumpClientMain { |
9 |
|
|
|
10 |
|
|
final static int EXIT_OK = 0; |
11 |
|
|
final static int EXIT_WARN = 1; |
12 |
|
|
final static int EXIT_CRIT = 2; |
13 |
|
|
final static int EXIT_UNKNOWN = 3; |
14 |
|
|
|
15 |
|
|
public static void main(String[] args) { |
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
if (args.length != 1) { |
20 |
|
|
System.out.println("Missing Commandline argument: transport name" ); |
21 |
|
|
System.exit(EXIT_CRIT); |
22 |
|
|
|
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
try { |
26 |
|
|
RemoteControlLocator loc = new RemoteControlLocator(); |
27 |
|
|
IRemoteControl remote = loc.getBasicHttpBinding_IRemoteControl(); |
28 |
|
|
|
29 |
|
|
StatusData status = remote.getTransportStatus( args[0] ); |
30 |
|
|
|
31 |
|
|
if (status.getTransportEnabled() == true) { |
32 |
|
|
if (status.getLastrunOk() == true) { |
33 |
|
|
System.out.println("Transport running OK"); |
34 |
|
|
System.exit(EXIT_OK); |
35 |
|
|
} else { |
36 |
|
|
System.out.println("Transport error"); |
37 |
|
|
System.exit(EXIT_CRIT); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
} else { |
41 |
|
|
System.out.println("Transport disabled"); |
42 |
|
|
System.exit(EXIT_WARN); |
43 |
|
|
|
44 |
|
|
} |
45 |
|
|
System.out.println( status.getTransportEnabled() ); |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
} catch (Exception e) { |
50 |
|
|
System.out.println("Communication error: " + e.getMessage() ); |
51 |
|
|
System.exit(EXIT_UNKNOWN); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
} |