Skip Headers
Oracle GlassFish Server Reference Manual
Release 3.1.2

Part Number E24938-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

run-script

runs a script for monitoring GlassFish Server events

Synopsis

run-script [--help] [--upload={true|false}] 
[--timeout timeout] [--target target] script-file-name 

Description

The run-script subcommand runs a script for monitoring GlassFish Server events. To stop the script, type Ctrl-C.

This subcommand is supported in remote mode only.

Options

--help
-?

Displays the help text for the subcommand.

--upload

Specifies whether the subcommand uploads the file to the DAS. In most situations, this option can be omitted.

Valid values are as follows:

false

The subcommand does not upload the file and attempts to access the file through the specified file name. If the DAS cannot access the file, the subcommand fails.

For example, the DAS might be running as a different user than the administration user and does not have read access to the file. In this situation, the subcommand fails if the --upload option is false.

true

The subcommand uploads the file to the DAS over the network connection.

The default value depends on whether the DAS is on the host where the subcommand is run or is on a remote host.

  • If the DAS is on the host where the subcommand is run, the default is false.

  • If the DAS is on a remote host, the default is true.

--timeout

Specifies the time in seconds to run the script before stopping it automatically. The default is 0 (zero), which means the script is never stopped automatically.

--target

Specifies the target on which you are running the script. Valid values are:

server

Runs the script on the domain administration server, also called the default server instance, which is named server. This is the default value.

cluster-name

Runs the script on every running server instance in the cluster.

instance-name

Runs the script on a particular standalone sever instance.

Operands

script-file-name

The name, including the absolute or relative path, of the file that contains the script to run. A relative path is relative to the directory from which the run-script subcommand is run.

Examples

Example 1   Running a Script for Monitoring GlassFish Server Events

This example runs the script /tools/mon/modulestarted.js for ten minutes (600 seconds).

asadmin> run-script --timeout 600 /tools/mon/modulestarted.js
Example 2   Counting the Number of Started and Stopped Web Modules

This example is a script that counts the number of standalone web modules and web modules in an enterprise archive (EAR) file that are started and the number of web modules that are stopped.

var nModuleStarted=0;
var nModuleStopped=0;

function webModuleStarted(appName, hostName) {
    nModuleStarted = nModuleStarted + 1;
    client.print( '\n js> web-module started event called on ' + 
                  'virtual_server_id =  ' + hostName + ', 
                  for application = ' + appName + ' 
                  and count = ' + nModuleStarted);
}

function webModuleStopped(appName, hostName) {
    nModuleStopped = nModuleStopped + 1;
    client.print( '\n js> web-module stopped event called on ' + 
                  'virtual_server_id= ' + hostName + ', 
                  for application = ' + appName + ' 
                  and count = ' + nModuleStopped);
}

params = java.lang.reflect.Array.newInstance(java.lang.String, 2);
params[0]="appName";
params[1]="hostName";


scriptContainer.registerListener(
    'glassfish:web:web-module:webModuleStartedEvent', params, 'webModuleStarted');
scriptContainer.registerListener(
    'glassfish:web:web-module:webModuleStartedEvent', params, 'webModuleStopped');

Exit Status

0

command executed successfully

1

error in executing the command

See Also

list-probes(1)

asadmin(1M)