CA::AutoSys - Interface to CA's AutoSys job control.
This module was born out of the need to control some AutoSys jobs via a Perl/CGI script. It is sort of a quick hack, but it works for me... should you have some wishes / requirements that are not mentioned in "TODOs", please let me know.
use CA::AutoSys; my $hdl = CA::AutoSys->new( [OPT] ) ; my $jobs = $hdl->find_jobs($jobname) ; while (my $job = $jobs->next_job()) { : } my $status = $job->get_status() ; my $children = $job->find_children() ; while (my $child = $children->next_child()) { : }
my $hdl = CA::AutoSys->new( [OPT] ) ;
Creates a new CA::AutoSys object.
Below is a list of valid options:
Specify the DSN of the AutoSys' database server to connect to. If nothing is specified, Sybase will be assumed: dbi:Sybase:server=<your_server> With this option you should be able to connect to databases other than Sybase.
This option is deprecated - rather use the dsn option. Specify the AutoSys' database server to connect to. Either this option or the dsn option above must be given. Please note, that when specifying this server option, a Sybase database backend is assumed.
Specify the database user. With an out-of-the-box AutoSys installation, the default user should work.
Specify the database password. With an out-of-the-box AutoSys installation, the default password should work.
Example:
my $hdl = CA::AutoSys->new(server => "AUTOSYS_DEV");
my $jobs = $hdl->find_jobs($jobname) ;
Finds jobs with a given name. When you have the wildcard character '%' somewhere in the job name, it will return all matching jobs, i.e.:
To find all jobs starting with the string 'MY_JOB':
$jobs = $hdl->find_jobs('MY_JOB%');
To find all jobs that have the string 'JOB' somewhere in the name:
$jobs = $hdl->find_jobs('%JOB%');
To find a job with an exact name:
$jobs = $hdl->find_jobs('JOB_42');
See also CA::AutoSys::Job
my $rc = $hdl->send_event( [OPT] ) ;
Sends an event to the given job. Returns 1 on success, 0 otherwise. At least the event name should be given. Depending on the event, more options may be necessary (see below). For details, consult your AutoSys' User Guide.
The name of the job - no wildcards allowed.
Event name. The following list contains all available event names in alphabetical order:
ALARM CHANGE_PRIORITY CHANGE_STATUS CHECK_HEARTBEAT CHK_BOX_TERM CHK_MAX_ALARM CHK_N_START CHK_RUN_WINDOW COMMENT DELETEJOB EXTERNAL_DEPENDENCY FORCE_STARTJOB HEARTBEAT JOB_OFF_HOLD JOB_OFF_ICE JOB_ON_HOLD JOB_ON_ICE KILLJOB QUE_RECOVERY REFRESH_BROKER RESEND_EXTERNAL_STATUS SEND_SIGNAL SET_GLOBAL STARTJOB
The job status when the event is CHANGE_STATUS. The following list contains all possible states for the CHANGE_STATUS event in alphabetical order:
CHANGE_STATUS
ACTIVATED FAILURE INACTIVE ON_HOLD ON_ICE QUE_WAIT REFRESH_DEPENDENCIES REFRESH_FILEWATCHER RESTART RUNNING STARTING SUCCESS TERMINATED
Use this when you want to schedule an event at a given time. The argument should have the format 'YYYY/MM/DD HH:MM:SS'.
To force a job start at a given time:
my $rc = $hdl->send_event(job_name => 'HAPPY_NEW_YEAR', event => 'FORCE_STARTJOB', event_time => '2007/12/31 23:59:59');
To mark an job as inactive:
my $rc = $hdl->send_event(job_name => 'JOB_42', event => 'CHANGE_STATUS', status => 'INACTIVE');
Make the interface more "perlish", e.g. return an array of jobs instead of forcing the user to call next_job() / next_child().
next_job()
next_child()
Make the interface more "OO", e.g. allow the user to send an event directly from an CA::AutoSys::Job object to the underlying job instead of having to use CA::AutoSys->send_event().
CA::AutoSys::Job
CA::AutoSys->send_event()
There are lots of missing AutoSys features, e.g. "alarms".
CA::AutoSys::Job, CA::AutoSys::Status
Sinisa Susnjar <sini@cpan.org>
See the CHANGES file.
Copyright (c) 2007 Sinisa Susnjar. All rights reserved.
This program is free software; you can use and redistribute it under the terms of the L-GPL. See the LICENSE file for details.
To install CA::AutoSys, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CA::AutoSys
CPAN shell
perl -MCPAN -e shell install CA::AutoSys
For more information on module installation, please visit the detailed CPAN module installation guide.