|
| 1 | +# Copyright (c) 2021 Oracle Corporation |
| 2 | +# Licensed under the Universal Permissive License v 1.0 |
| 3 | +# as shown at https://oss.oracle.com/licenses/upl/ |
| 4 | + |
| 5 | +# Check the time difference between the client and the database |
| 6 | + |
| 7 | +# bengsig 21-may-2024 - Creation |
| 8 | + |
| 9 | +$include:"parameters.rwl" |
| 10 | + |
| 11 | +database rwl_run1 |
| 12 | + username rwl_run1_username |
| 13 | + password rwl_run1_password |
| 14 | + connect normal_connect |
| 15 | + dedicated |
| 16 | + default; |
| 17 | + |
| 18 | +string fulldate, unixstart; |
| 19 | +integer secpos; |
| 20 | +double oraepoch, clientepoch := epochseconds(); |
| 21 | + |
| 22 | +select |
| 23 | + to_char(sys_extract_utc(systimestamp),'J-SSSSS.FF') fulldate |
| 24 | +, to_char(to_date('1970.01.01.00:00:00','YYYY.MM.DD.HH24:MI:SS'),'J') unixstart |
| 25 | +from dual |
| 26 | +/ |
| 27 | + |
| 28 | +secpos := instrb(fulldate,"-"); |
| 29 | + |
| 30 | +oraepoch := 86400.0 * substrb(fulldate,1,secpos-1) |
| 31 | + + substrb(fulldate,secpos+1) |
| 32 | + - 86400.0*unixstart; |
| 33 | + |
| 34 | +if oraepoch - clientepoch between -1 and 1 then |
| 35 | + printf "datebase and client differ in UTC time by %.2fms\n", (oraepoch - clientepoch)*1000.0; |
| 36 | +elseif oraepoch - clientepoch between -10 and 10 then |
| 37 | + printf "WARNING: datebase and client differ in UTC time by %.3fs\n", oraepoch - clientepoch; |
| 38 | +else |
| 39 | + printf "<b>HIGH TIME SHIFT: datebase and client differ in UTC time by %.3fs</b>\n", oraepoch - clientepoch; |
| 40 | +end if; |
0 commit comments