event_schedule()
Schedule a PATROL event
When you schedule a PATROL event, you are scheduling the event's Notification command (if any) for execution by the PATROL Agent.
Syntax
[argument1],...,[argument20])
event_schedule(delete,scheduleID)
event_schedule(list)
event_schedule(modify,scheduleID,time,origin,catalog,class,
type,severity,[argument1],...,[argument20])
event_schedule(resume,scheduleID,time)
event_schedule(suspend,scheduleID)
Parameters
Parameter | Definition |
---|---|
scheduleID | event identifier within the scheduling queue on which theevent_schedule() function will act. scheduleID is returned by the event_schedule("add") function |
time | string specifying the time the PATROL Agent will schedule the event Valid Values |
origin | character string containing the application class or instance name that is identified as having created the event |
catalog | character string name of the catalog to which the event belongs The event_schedule() function requires that catalog be previously defined to the PATROL Event Manager. To use the PATROL standard event catalog, specify STANDARD or STD . |
class | character string name of the class to which the event belongs The event_schedule() function requires that class be previously defined to the PATROL Event Manager. |
type | event type as displayed in the PATROL Event Manager*Valid Values* |
severity | integer value indicating the severity of the event*Valid Values* |
argumentn | arguments passed to the PATROL event description This function permits a maximum of 20 arguments. |
Description
The event_schedule() function handles the scheduling of events in the PATROL Agent. Scheduling an event means inserting it into the PATROL Agent schedule queue for triggering at a specified time. When the event is triggered, its notification command is executed. Scheduling an event implies that you are scheduling the OS or PSL Notification command corresponding to that event for execution. The following topics describe each of the event_schedule() function options.
event_schedule() Function Add Option
The event_schedule("add") function causes the PATROL Agent to add the specified event to the PATROL Agent schedule queue for triggering at time. The event_schedule("add") function returns scheduleID if successful, or the empty string if not.
event_schedule() Function Delete Option
The event_schedule("delete") function removes the event identified by scheduleID from the PATROL Agent schedule queue. The scheduleID is returned by the event_schedule("add") function. The event_schedule("delete") function returns the string OK if successful, or an error messages string if not.
event_schedule() Function List Option
The event_schedule("list") function returns a list of events contained in the PATROL Agent schedule queue. The following is a sample of the output from the event_schedule("list") function:
123 Fri Mar 15 15:57:31 active
126 Fri Mar 15 15:57:31 suspended
226 Fri Mar 16 15:57:31 suspended
event_schedule() Function Modify Option
The event_schedule("modify") function modifies the properties of an event in the PATROL Agent schedule queue. The scheduleID is returned by the event_schedule("add") function. The event_schedule("modify") function returns the string OK if successful, or an error message string if not.
event_schedule() Function Resume Option
The event_schedule("resume") function reinstates an event that has been suspended in the PATROL Agent schedule queue. The scheduleID is returned by the event_schedule("add") function. The event_schedule("resume") function returns the string OK if successful, or an error message string if not.
event_schedule() Function Suspend Option
The event_schedule("suspend") function suspends an event in the PATROL Agent schedule queue. The PATROL Agent does not send the suspended event and the event remains in the PATROL Agent schedule queue in the suspended state. The scheduleID is returned by the event_schedule("add") function. The event_schedule("suspend") function returns the string OK if successful, or an error message string if not.
Example
The following examples show different uses for event_schedule().
Schedule Event Notification
The following event_schedule() function adds an event to the PATROL Agent schedule queue:
"add", # schedule a new event
"Fri Mar 15 15:57:31", # trigger on 03-15-96 at 3:57 pm
"MyOrigin", # origin is MyOrigin
"STD", # catalog is STANDARD
"41", # class is 41
"INFORMATION", # type is INFORMATION
"3", # severity is 3
"myarg" # first dynamic argument is myarg
);
Delete Scheduled Event
The following event_schedule() function deletes the event schedule_id (created in the previous example) from the PATROL Agent schedule queue:
"deleting event . . .\n result : " .
event_schedule("delete",schedule_id) . "\n")
. "\n"
);
Return a List of Scheduled Events
The following event_schedule() function returns a list of the events in the PATROL Agent schedule queue:
"List of Scheduled Events :",
event_schedule("list")
. "\n"
);
Scheduling PSL or OS Activities
As indicated in the comments, this example shows how to schedule PSL or OS activities using the event_schedule() function:
# using the PSL event_schedule() function. When an event is triggered,
# the agent executes the Notification command defined in the event
# catalog. This notification command can be PSL or OS.
# This is why when you schedule an event, you are basically
# scheduling its notification command to be executed as 'a job'.
#
# In this example I will schedule 6 events: ("STANDARD","EventArchive").
# When this event is executed it dumps all events matching the filter
# into a file
my_date = "Tue Mar 19 14:57:30 1997"; # must be higher than 'date'
my_new_date = "Tue Mar 19 15:55:30 1997"; # must be higher than my_date
my_event_catalog = "STANDARD"; # put here your own event catalog
my_event_Class = "EventArchive"; # put here your own event class to schedule
my_dump_file = "/tmp/events.arc"; # put here desired dump destination
# Schedule 3 events ("STANDARD","EventArchive")
# and store their schedule id in sh1, sh2, sh3
#
# This example schedule same job. In practice this is useless
sh1= event_schedule(
"add",
my_date,
"job1",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh1."<-\n\n");
sh2= event_schedule(
"add",
my_date,
"job2",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh2."<-\n\n");
sh3= event_schedule(
"add",
my_date,
"job3",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh3."<-\n\n");
# List all scheduled events
print("list->\n".event_schedule("list")."<-\n\n");
# Schedule 3 more events for execution at my_new_date
# and store their schedule ids in sh4, sh5, sh6
sh4= event_schedule(
"add",
my_date,
"job4",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh4."<-\n\n");
sh5= event_schedule(
"add",
my_date,
"job5",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh5."<-\n\n");
sh6= event_schedule(
"add",
my_date,
"job6",
my_event_catalog, my_event_class,
"INFORMATION","3",
my_dump_file
);
print("add event : ->".sh6."<-\n\n");
# Delete job6 and list all jobs
print("delete job 6: ->".event_schedule("delete",sh6)."<-\n\n");
print("list->\n".event_schedule("list")."<-\n\n");
# Suspend job 2 and list all jobs
print("suspend job 2: ->".event_schedule("suspend",sh2)."<-\n\n");
print("list->\n".event_schedule("list")."<-\n\n");
# Resume job 2 to be executed at my_new_date instead of my_date
# List all jobs
print("resume job 2: ->".event_schedule("resume",sh2, my_new_date)."<-\n\n");
print("list->\n".event_schedule("list")."<-\n\n");
# Modify job 4 and list all jobs
print(
"modify job 4: ->".
event_schedule(
"modify",
"4",
my_new_date,
"new_job4",
my_event_catalog, my_event_class,
"INFORMATION","5",
my_dump_file
)
."<-\n\n"
);
print("list->\n".event_schedule("list")."<-\n\n");