Adding simple tests
This commit is contained in:
82
check_date.ksh
Executable file
82
check_date.ksh
Executable file
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/ksh
|
||||||
|
echo "Checking date command availability and date arithmetic support..."
|
||||||
|
|
||||||
|
# Check for date commands
|
||||||
|
echo "Available date commands:"
|
||||||
|
if command -v date >/dev/null 2>&1; then
|
||||||
|
echo " date: $(which date)"
|
||||||
|
DATE_CMD="date"
|
||||||
|
else
|
||||||
|
echo " date: NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v gdate >/dev/null 2>&1; then
|
||||||
|
echo " gdate: $(which gdate)"
|
||||||
|
if [ -z "$DATE_CMD" ]; then
|
||||||
|
DATE_CMD="gdate"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " gdate: NOT FOUND in PATH"
|
||||||
|
# Check common HP-UX locations for gdate
|
||||||
|
echo " Checking common HP-UX locations for gdate..."
|
||||||
|
for gdate_path in /usr/local/bin/gdate /opt/gnu/bin/gdate /usr/contrib/bin/gdate /opt/coreutils/bin/gdate; do
|
||||||
|
if [ -x "$gdate_path" ]; then
|
||||||
|
echo " gdate: FOUND at $gdate_path"
|
||||||
|
if [ -z "$DATE_CMD" ]; then
|
||||||
|
DATE_CMD="$gdate_path"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$DATE_CMD" ] || [ "$DATE_CMD" = "date" ]; then
|
||||||
|
echo " gdate: NOT FOUND in common locations"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v perl >/dev/null 2>&1; then
|
||||||
|
echo " perl: $(which perl)"
|
||||||
|
PERL_AVAILABLE=1
|
||||||
|
else
|
||||||
|
echo " perl: NOT FOUND"
|
||||||
|
PERL_AVAILABLE=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DATE_CMD" ]; then
|
||||||
|
echo "ERROR: No date command found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Testing date arithmetic with: $DATE_CMD"
|
||||||
|
|
||||||
|
# Test basic date
|
||||||
|
echo "Basic date output:"
|
||||||
|
$DATE_CMD +"%Y-%m-%d %H:%M:%S"
|
||||||
|
|
||||||
|
# Test date arithmetic like used in rman_db.ksh
|
||||||
|
echo ""
|
||||||
|
echo "Testing date arithmetic: '$DATE_CMD +%m-%d-%Y\ %H:%M:%S -d \"-1 hour\"'"
|
||||||
|
if $DATE_CMD -d "-1 hour" >/dev/null 2>&1; then
|
||||||
|
RESULT=$($DATE_CMD +%m-%d-%Y\ %H:%M:%S -d '-1 hour')
|
||||||
|
echo "SUCCESS: Date arithmetic works"
|
||||||
|
echo "Result: $RESULT"
|
||||||
|
else
|
||||||
|
echo "ERROR: Date arithmetic (-d option) not supported"
|
||||||
|
echo "This system may need GNU date (gdate) installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test perl-based date arithmetic as fallback
|
||||||
|
if [ $PERL_AVAILABLE -eq 1 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Testing perl-based date arithmetic fallback:"
|
||||||
|
echo "Command: perl -e 'use POSIX qw(strftime); \$time = time() - 3600; print strftime(\"%m-%d-%Y %H:%M:%S\", localtime(\$time))'"
|
||||||
|
PERL_RESULT=$(perl -e 'use POSIX qw(strftime); $time = time() - 3600; print strftime("%m-%d-%Y %H:%M:%S", localtime($time))')
|
||||||
|
echo "SUCCESS: Perl date arithmetic works"
|
||||||
|
echo "Result: $PERL_RESULT"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "WARNING: Perl not available - no fallback for date arithmetic"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Test complete."
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# ID and Key for RSC Service Account (starts with client|) (use single quotes)
|
|
||||||
ID='client|xxxxxxxxxxxxxxxxxxx'
|
|
||||||
SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
|
|
||||||
|
|
||||||
# DNS name of Rubrik CDM
|
|
||||||
RUBRIK_IP=<CDM address>
|
|
||||||
|
|
||||||
# Oracle Settings
|
|
||||||
MOUNTPOINT_PREFIX=/rubrik_
|
|
||||||
# How many hours of archivelog to keep on host. 0 means do not purge logs
|
|
||||||
HOSTLOGRET=2
|
|
||||||
|
|
||||||
# Percentage threshold to warn if an MV filesystem is getting full
|
|
||||||
MV_SPACE_WARN=75
|
|
||||||
|
|
||||||
# Logging directories
|
|
||||||
|
|
||||||
# API calls
|
|
||||||
API_LOG_DIR=/tmp/rubrik
|
|
||||||
# RMAN sessions
|
|
||||||
RMAN_LOG_DIR=/tmp/rubrik/rman
|
|
||||||
|
|
||||||
# List of email addresses to send failure alerts to
|
|
||||||
ALERT_EMAILS=root,oracle
|
|
||||||
# Set to 1 to enable email alert on success also
|
|
||||||
EMAIL_SUCCESS=1
|
|
||||||
50
test.ksh
Executable file
50
test.ksh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/ksh
|
||||||
|
echo "Testing HP-UX compatibility for Rubrik scripts..."
|
||||||
|
|
||||||
|
# Check for required commands
|
||||||
|
for cmd in ksh awk readlink egrep date dfsdf expr mkdir; do
|
||||||
|
if ! command -v $cmd >/dev/null 2>&1; then
|
||||||
|
echo "ERROR: $cmd not found in PATH"
|
||||||
|
else
|
||||||
|
echo "OK: $cmd found"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Test awk JSON extraction for numChannels
|
||||||
|
echo '{"numChannels": 4, "foo": "bar"}' > /tmp/testjson.$$
|
||||||
|
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/testjson.$$)
|
||||||
|
if [ "$numChannels" = "4" ]; then
|
||||||
|
echo "OK: awk numChannels extraction works"
|
||||||
|
else
|
||||||
|
echo "ERROR: awk numChannels extraction failed (got '$numChannels')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test awk JSON extraction for ManagedVolume
|
||||||
|
echo '{"id":"ManagedVolume:::abc-123-xyz"}' > /tmp/testjson.$$
|
||||||
|
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/testjson.$$)
|
||||||
|
if [ "$mvId" = "ManagedVolume:::abc-123-xyz" ]; then
|
||||||
|
echo "OK: awk ManagedVolume extraction works"
|
||||||
|
else
|
||||||
|
echo "ERROR: awk ManagedVolume extraction failed (got '$mvId')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test readlink
|
||||||
|
ln -s /tmp/testjson.$$ /tmp/testlink.$$
|
||||||
|
linkres=$(readlink /tmp/testlink.$$ 2>/dev/null)
|
||||||
|
if [ "$linkres" = "/tmp/testjson.$$" ]; then
|
||||||
|
echo "OK: readlink works"
|
||||||
|
else
|
||||||
|
echo "WARNING: readlink did not return expected result (got '$linkres')"
|
||||||
|
fi
|
||||||
|
rm -f /tmp/testjson.$$ /tmp/testlink.$$
|
||||||
|
|
||||||
|
# Test expr arithmetic
|
||||||
|
i=0
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
if [ "$i" = "1" ]; then
|
||||||
|
echo "OK: expr arithmetic works"
|
||||||
|
else
|
||||||
|
echo "ERROR: expr arithmetic failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Testing complete."
|
||||||
Reference in New Issue
Block a user