#!/bin/sh  
# \
exec oagtclsh "$0" "$@"

set auto_path [linsert $auto_path 0  /usr/local/oag/apps/lib/$env(HOST_ARCH)]
set auto_path [linsert $auto_path 0 /usr/local/oag/lib_patch/$env(HOST_ARCH)]

APSStandardSetup

if {[catch {exec who -b} result]} {
    exit
}
if {[llength $result] > 4} {
    set upSeconds [expr {[clock seconds] - [clock scan [lrange $result 3 end]]}]
} else {
    set upSeconds [expr {[clock seconds] - [clock scan [lrange $result 2 end]]}]
}
set upMinutes [expr {$upSeconds / 60.0}]
if {($upMinutes >= 16) && ($upMinutes < 26)} {
    set hostname [exec hostname]
    APSSendEMail -message "$hostname rebooted over 15 minutes ago. Please check data loggers to ensure that they have restarted properly." \
      -address asdops -subject "$hostname rebooted over 15 minutes ago."
}
