diff --git a/datastore_server/dist/datastore_server.sh b/datastore_server/dist/datastore_server.sh index 650a61eb98e9d8658bc800acd0a2cf707827c12e..64efcec4ba40e8287b78f31df469234c2d467235 100755 --- a/datastore_server/dist/datastore_server.sh +++ b/datastore_server/dist/datastore_server.sh @@ -262,9 +262,8 @@ case "$command" in echo " $0 show-command-queue - show the queue of commands from openBIS AS waiting to be executed" echo " $0 log-db-connections - log the currently active database connections to log/startup_log.txt" echo " $0 log-thread-dump - log the current thread dump to log/startup_log.txt" - echo " $0 debug-db-connections - switch on database connection debug logging" - echo " $0 no-debug-db-connections - switch off database connection debug logging" - echo " $0 record-stacktrace-db-connections - switch on database connection stacktrace recording" + echo " $0 debug-db-connections on / off - switch on / off database connection debug logging" + echo " $0 record-stacktrace-db-connections on / off - switch on / off database connection stacktrace recording" echo " $0 no-record-stacktrace-db-connections - switch off database connection stacktrace recording" ;; version) @@ -303,8 +302,8 @@ case "$command" in exit 100 fi mkdir -p .control - if [ "$1" != "" ]; then - touch .control/db-connections-print-active.$1 + if [ "$2" != "" ]; then + touch .control/db-connections-print-active.$2 else touch .control/db-connections-print-active fi @@ -318,19 +317,13 @@ case "$command" in exit 100 fi mkdir -p .control - touch .control/db-connections-debug-on - echo "Switched on debug logging for database connections." - ;; - no-debug-db-connections) - getStatus - EXIT_STATUS=$? - if [ $EXIT_STATUS -ne 0 ]; then - echo "Error: Data Store Server not running." - exit 100 - fi - mkdir -p .control - touch .control/db-connections-debug-off - echo "Switched off debug logging for database connections." + if [ "$2" == "off" ]; then + touch .control/db-connections-debug-off + echo "Switched off debug logging for database connections." + else + touch .control/db-connections-debug-on + echo "Switched on debug logging for database connections." + fi ;; record-stacktrace-db-connections) getStatus @@ -340,17 +333,13 @@ case "$command" in exit 100 fi mkdir -p .control - touch .control/db-connections-stacktrace-on - ;; - no-record-stacktrace-db-connections) - getStatus - EXIT_STATUS=$? - if [ $EXIT_STATUS -ne 0 ]; then - echo "Error: Data Store Server not running." - exit 100 - fi - mkdir -p .control - touch .control/db-connections-stacktrace-off + if [ "$2" == "off" ]; then + touch .control/db-connections-stacktrace-off + echo "Switched off stacktrace recording for database connections." + else + touch .control/db-connections-stacktrace-on + echo "Switched on stacktrace recording for database connections." + fi ;; *) echo "Usage: $0 {start|stop|restart|status|help|version}" diff --git a/openbis/dist/admin/list-postgres-queries.sh b/openbis/dist/admin/list-postgres-queries.sh index 1bf6da09a8312ba334a9db630d72f3c83f59f504..42d6ec6004bfb16b61d5bde4ab5643153ea96008 100755 --- a/openbis/dist/admin/list-postgres-queries.sh +++ b/openbis/dist/admin/list-postgres-queries.sh @@ -8,4 +8,4 @@ fi source $BASE/env -psql -U $DB_USER_NAME -d $OPENBIS_DB -c "select datname,procpid,usename,current_query,waiting,xact_start FROM pg_catalog.pg_stat_activity" \ No newline at end of file +psql -U $DB_USER_NAME -d $OPENBIS_DB -c "select datname,pid,usename,query,state FROM pg_catalog.pg_stat_activity" \ No newline at end of file diff --git a/openbis/dist/server/debug-db-connections.sh b/openbis/dist/server/debug-db-connections.sh new file mode 100755 index 0000000000000000000000000000000000000000..4789b4a36d65578db85ea1a502120e21b3590723 --- /dev/null +++ b/openbis/dist/server/debug-db-connections.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +# Script for CISD openBIS Application Server to switch on / off debugging of database connections on Unix / Linux systems +# ----------------------------------------------------------------------------------------------------------------------- + +source `dirname "$0"`/setup-env + +printStatus -q "$1" + EXIT_STATUS=$? +if [ $EXIT_STATUS -ne 0 ]; then + echo "Error: Application Server not running." + exit 100 +fi + +mkdir -p .control +if [ "$1" == "off" ]; then + touch .control/db-connections-debug-off + echo "Switched off debug logging for database connections." +else + touch .control/db-connections-debug-on + echo "Switched on debug logging for database connections." +fi diff --git a/openbis/dist/server/log-db-connections.sh b/openbis/dist/server/log-db-connections.sh new file mode 100755 index 0000000000000000000000000000000000000000..f2b0b2f8a76892cd0bb12f58993b01d8f31f6285 --- /dev/null +++ b/openbis/dist/server/log-db-connections.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +# Script for CISD openBIS Application Server to log open database connections on Unix / Linux systems +# --------------------------------------------------------------------------------------------------- + +source `dirname "$0"`/setup-env + +printStatus -q "$1" + EXIT_STATUS=$? +if [ $EXIT_STATUS -ne 0 ]; then + echo "Error: Application Server not running." + exit 100 +fi + +mkdir -p .control +if [ "$1" != "" ]; then + touch .control/db-connections-print-active.$1 +else + touch .control/db-connections-print-active +fi +echo "Active database connections logged to logs/jetty.out" diff --git a/openbis/dist/server/log-thread-dump.sh b/openbis/dist/server/log-thread-dump.sh new file mode 100755 index 0000000000000000000000000000000000000000..1f175d172c0772a49c233d2f74c5a922c2ebb3f5 --- /dev/null +++ b/openbis/dist/server/log-thread-dump.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +# Script for CISD openBIS Application Server to log thread dump on Unix / Linux systems +# ------------------------------------------------------------------------------------- + +source `dirname "$0"`/setup-env + +if [ -f $JETTY_PID_FILE ]; then + PID=`cat $JETTY_PID_FILE 2> /dev/null` + isPIDRunning $PID + if [ $? -eq 0 ]; then + kill -3 $PID + echo "Thread dump logged to logs/jetty.out" + else + echo "Error: Application Server not running." + exit 100 + fi +else + echo "Error: Application Server not running." + exit 100 +fi diff --git a/openbis/dist/server/record-stacktrace-db-connections.sh b/openbis/dist/server/record-stacktrace-db-connections.sh new file mode 100755 index 0000000000000000000000000000000000000000..32ed6b76396d8c5a43c9e6c12dda7124eb4dbe5a --- /dev/null +++ b/openbis/dist/server/record-stacktrace-db-connections.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +# Script for CISD openBIS Application Server to switch on / off recording of stacktraces of database connections on Unix / Linux systems +# -------------------------------------------------------------------------------------------------------------------------------------- + +source `dirname "$0"`/setup-env + +printStatus -q "$1" + EXIT_STATUS=$? +if [ $EXIT_STATUS -ne 0 ]; then + echo "Error: Application Server not running." + exit 100 +fi + +mkdir -p .control +if [ "$1" == "off" ]; then + touch .control/db-connections-stacktrace-off + echo "Switched off stacktrace recording for database connections." +else + touch .control/db-connections-stacktrace-on + echo "Switched on stacktrace recording for database connections." +fi diff --git a/openbis/dist/server/setup-env b/openbis/dist/server/setup-env index 275c4116a52640b87267ac53d4055b212b48318b..c488c62ea8549bb7d9d0e6319c33f23806e14dd8 100644 --- a/openbis/dist/server/setup-env +++ b/openbis/dist/server/setup-env @@ -66,3 +66,24 @@ checkNotRoot() exit 1 fi } + +printStatus() +{ + if [ "$1" == "-q" ]; then + QUIET=1 + fi + if [ -f $JETTY_PID_FILE ]; then + PID=`cat $JETTY_PID_FILE` + isPIDRunning $PID + if [ $? -eq 0 ]; then + test -z "$QUIET" && echo "openBIS Application Server is running (pid $PID)" + return 0 + else + test -z "$QUIET" && echo "openBIS Application is dead (stale pid $PID)" + return 1 + fi + else + test -z "$QUIET" && echo "openBIS Application is not running." + return 2 + fi +} diff --git a/openbis/dist/server/status.sh b/openbis/dist/server/status.sh index 3aa6070657b2f81306a98f09c96e679c784b4877..729294fcdf404a1f9e53bcd3ac57520b916ff888 100755 --- a/openbis/dist/server/status.sh +++ b/openbis/dist/server/status.sh @@ -5,25 +5,4 @@ source `dirname "$0"`/setup-env -printStatus() -{ - if [ "$1" == "-q" ]; then - QUIET=1 - fi - if [ -f $JETTY_PID_FILE ]; then - PID=`cat $JETTY_PID_FILE` - isPIDRunning $PID - if [ $? -eq 0 ]; then - test -z "$QUIET" && echo "openBIS Application Server is running (pid $PID)" - return 0 - else - test -z "$QUIET" && echo "openBIS Application is dead (stale pid $PID)" - return 1 - fi - else - test -z "$QUIET" && echo "openBIS Application is not running." - return 2 - fi -} - printStatus "$1" \ No newline at end of file