Subversion Repositories DevTools

Rev

Rev 1350 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1350 Rev 1361
Line 17... Line 17...
17
//
17
//
18
public class NagiosThread extends Thread {
18
public class NagiosThread extends Thread {
19
    // Server socket
19
    // Server socket
20
    private ServerSocket srv;
20
    private ServerSocket srv;
21
 
21
 
-
 
22
    // BuildDaemon
-
 
23
    private BuildDaemon mBuildDaemon;
-
 
24
 
22
    // Flag that indicates whether the poller is running or not.
25
    // Flag that indicates whether the poller is running or not.
23
    private volatile boolean isRunning = true;
26
    private volatile boolean isRunning = true;
24
 
27
 
25
    /**Logger
28
    /**Logger
26
     * @attribute
29
     * @attribute
27
     */
30
     */
28
    private static final Logger mLogger = Logger.getLogger(NagiosThread.class);
31
    private static final Logger mLogger = Logger.getLogger(NagiosThread.class);
29
    
32
    
30
    // Constructor.
33
    // Constructor.
31
    public NagiosThread(ServerSocket srv) {
34
    public NagiosThread(ServerSocket srv, BuildDaemon bd) {
32
        this.isRunning = true;
35
        this.isRunning = true;
33
        this.srv = srv;
36
        this.srv = srv;
-
 
37
        this.mBuildDaemon = bd;
34
    }
38
    }
35
 
39
 
36
    // Method for terminating the listener
40
    // Method for terminating the listener
37
    public void terminate() {
41
    public void terminate() {
38
        mLogger.fatal("NagiosThread terminate");
42
        mLogger.fatal("NagiosThread terminate");
Line 55... Line 59...
55
            // Write the status message to the outputstream
59
            // Write the status message to the outputstream
56
            // Currently this is too simple, but it is a start
60
            // Currently this is too simple, but it is a start
57
            //
61
            //
58
            try {
62
            try {
59
                BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
63
                BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
-
 
64
                if ( mBuildDaemon == null ) {
-
 
65
                    wr.write("Build Daemon status: NULL\n");
-
 
66
                } else if ( mBuildDaemon.checkThreads() ) {
60
                wr.write("Build Daemon status: OK\n");
67
                    wr.write("Build Daemon status: OK\n");
-
 
68
                } else {
-
 
69
                    wr.write("Build Daemon status: NOT HAPPY\n");
-
 
70
                }
-
 
71
 
61
                wr.write("Version: "+ this.getClass().getPackage().getImplementationVersion() + "\n");
72
                wr.write("Version: "+ this.getClass().getPackage().getImplementationVersion() + "\n");
62
                wr.write("HostName: "+ BuildDaemon.mHostname + "\n");
73
                wr.write("HostName: "+ mBuildDaemon.mHostname + "\n");
-
 
74
 
-
 
75
                File cwd = new File(".");
-
 
76
                wr.write( "Usable space: " + cwd.getUsableSpace() + "\n");
-
 
77
                
63
                wr.flush();
78
                wr.flush();
64
            } catch (IOException e) {
79
            } catch (IOException e) {
65
                mLogger.fatal("NagiosThread caught Exception writing to port:" + e.getMessage() );
80
                mLogger.fatal("NagiosThread caught Exception writing to port:" + e.getMessage() );
66
            }
81
            }
67
 
82