Navigation



Examples

Here a simple example showing how JExecDaemon can be used to remotely execute hddtemp and lm_senors on a Linux system.

Configuration file

<Config xmlns="http://www.unlogic.se/projects/jexecdaemon/1.0/schemas/config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.unlogic.se/projects/jexecdaemon/1.0/schemas/config config.xsd">

    <ShutdownSocket>
        <Port>25000</Port>
        <Password>secret</Password>
    </ShutdownSocket>

    <Executors>
        <Executor>
            <Name>LM Sensors</Name>
            <Port>25001</Port>
            <Command>/usr/bin/sensors</Command>
        </Executor>
        <Executor>
            <Name>HDDTemp</Name>
            <Port>25002</Port>
            <Command>hddtemp</Command>
            <Arguments>
                <Argument>/dev/sda</Argument>
                <Argument>/dev/sdb</Argument>
                <Argument>/dev/sdc</Argument>
                <Argument>/dev/sdd</Argument>
            </Arguments>
            <WorkingDirectory>/usr/bin</WorkingDirectory>
            <Timeout>5000</Timeout>
        </Executor>       
    </Executors>
</Config>

Startup

Starting JExecDaemon using the start.sh (use start.bat on windows systems)

[unlogic@itx-server bin]$ ./start.sh
JExecDaemon 1.0 starting...
Starting executor LM Sensors on address 0.0.0.0:25001
Starting executor HDDTemp on address 0.0.0.0:25002
Starting shutdown socket on address 0.0.0.0:25000
JExecDaemon 1.0 started with 2 executors

Executing a command

Connecting to a given port using a telnet client triggers JExecDaemon to execute the program mapped to that port and reply with the output from the program.

unlogic@itx-server bin]$ telnet localhost 25001
Trying 127.0.0.1...
Connected to itx-server (127.0.0.1).
Escape character is '^]'.
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +37.0°C  (high = +78.0°C, crit = +100.0°C) 

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +37.0°C  (high = +78.0°C, crit = +100.0°C) 

Connection closed by foreign host.


[unlogic@itx-server bin]$ telnet localhost 25002
Trying 127.0.0.1...
Connected to itx-server (127.0.0.1).
Escape character is '^]'.
/dev/sda: ST3500320AS: 37°C
/dev/sdb: ST3500320AS: 36°C
/dev/sdc: ST3500320AS: 37°C
/dev/sdd: ST3500630AS: 41°C
Connection closed by foreign host.

If no telnet client is available JExecDaemon ships with a simple Java based test client which can be invoked using the test.sh/test.bat scripts.

[unlogic@itx-server bin]$ ./test.sh localhost 25001
Connecting to JExecDaemon at localhost:25001 ... connected!
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +39.0°C  (high = +78.0°C, crit = +100.0°C)  

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +37.0°C  (high = +78.0°C, crit = +100.0°C)  

 [unlogic@itx-server bin]$ ./test.sh localhost 25002
Connecting to JExecDaemon at localhost:25002 ... connected!
/dev/sda: ST3500320AS: 37°C
/dev/sdb: ST3500320AS: 36°C
/dev/sdc: ST3500320AS: 37°C
/dev/sdd: ST3500630AS: 41°C