#!/bin/bash

nodeNr=1
group=$2
testName="DB"
echo -n "Test $testName for $group on node $nodeNr "
out=$(timeout 10 bash -c "ssh root@se0${nodeNr}${group} /usr/sap/hostctrl/exe/saphostctrl -function ListInstances | grep \"sapna${group#group}db\"") 2>/dev/null; rc=$?

#echo "out: $out"
echo "rc:  $rc"
case $rc in 
    124 | 255 ) # test timeout - set N/A
         rm -f ./.status/${group}_${testName}_OK
         rm -f ./.status/${group}_${testName}_FAIL
         res="NA";
         ;;
    0  )
         touch ./.status/${group}_${testName}_OK
         rm -f ./.status/${group}_${testName}_FAIL
          ;;
    1 )  rm -f ./.status/${group}_${testName}_OK
         touch ./.status/${group}_${testName}_FAIL
         ;;
esac
