Листинг 1.
# NAME: # # CheckOMS.tcl : Script to test if OMS is running # # ARGUMENTS: #to the OMS # seconds to sleep between checks # smtp mail address to send notifications # # ex.: sysman/password 120 somebody@somewhere.com # # Prerequisits: To be run under Unix (functioning mailx utility) # # Changes Log: # 05-27-99 A Balbekov Original Creation # set argc [llength $argv] if {$argc == 1} {set argv [lindex $argv 0]} if {$argc != 3} { error "Usage: testoms.tcl " } set down 1 set up 0 set prev_status $up set OMS_connect_string [lindex $argv 0] set sleep_time [lindex $argv 1] set smtp_addr [lindex $argv 2] set OEMCTRL oemctrl set my_address [lindex [orainfo] 2] set hostname [lindex [split [lindex [orainfo] 2] )(] 4] orajobstat $my_address "Job started: [oratime]" # # Main indefinite loop - break is done by OEM console's remove job command # while { 1 == 1 } { catch {exec $OEMCTRL status oms $OMS_connect_string} out if { [lsearch -regexp $out properly] == -1} { if { $prev_status == $up } { set mail_success [catch {exec echo "$hostname: TestOMS: OMS is down: Timestamp [oratime]" | mailx -s "TestOMS: OMS is down" $smtp_addr} out] if { $mail_success == 0 } { set mail_success "Successfull" } else { set mail_success "UnSuccessfull" } orajobstat $my_address "$hostname: TestOMS: OMS is down: Timestamp [oratime] Notification: $mail_success" set prev_status $down } } else { if { $prev_status == $down } { set mail_success [catch {exec echo "$hostname: TestOMS: OMS is up: Timestamp [oratime]" | mailx -s "TestOMS: OMS is up" $smtp_addr} out] if { $mail_success == 0 } { set mail_success "Successfull" } else { set mail_success "UnSuccessfull" } orajobstat $my_address "$hostname: TestOMS: OMS is up: Timestamp [oratime] Notification: $mail_success" set prev_status $up } } orasleep $sleep_time }