#!/bin/bash # Script should be run as root user OUTPUT_FILE=/tmp/rstudio-diagnostics/rsp_diagnostics-report.txt mkdir -p /tmp/rstudio-diagnostics [ -f $OUTPUT_FILE ] && cp /tmp/rstudio-diagnostics/rsp_diagnostics-report.txt /tmp/rstudio-diagnostics/rsp_diagnostics-report-$(date +"%y%m%d%H%M%S").txt add_label () { echo "" echo "-------------------------------" echo "$1" echo "-------------------------------" } gather_info () { date add_label "Detect OS" OS='cat /etc/*-release' DISTRO=$($OS | grep DISTRIB_ID | cut -f2 -d "=") [ -z $DISTRO ] && { DISTRO="RedHat"; echo "Distribution unable to be determined; RedHat set as default."; } $OS uname -a add_label "R Installation" echo "which R: $(which R)" echo "which gcc: $(which gcc)" R_HOME=$(R RHOME) echo "R_HOME: $R_HOME" R --version # TODO: do we need all files, or should we be grabbing just a subset? add_label "R config files" R_CONFIG_DIR="$(echo $R_HOME | cut -d '"' -f2)/etc" for f in $(ls $R_CONFIG_DIR) do echo "$R_CONFIG_DIR/$f" cat $R_CONFIG_DIR/$f echo "" done add_label "RStudio Server" echo "Status of rstudio-server package:" case $DISTRO in "RedHat" | "CentOS") yum info rstudio-server ;; "Ubuntu" | "Debian") dpkg -s rstudio-server ;; "SUSE") zypper info rstudio-server ;; esac echo "" echo "rstudio-server version, status, and verify-installation" rstudio-server version rstudio-server status rstudio-server verify-installation add_label "RStudio Server config files" RSP_CONFIG_DIR="/etc/rstudio" for f in $(ls $RSP_CONFIG_DIR) do echo "$f:" cat $RSP_CONFIG_DIR/$f echo "" done cat /etc/profile cat /etc/environment cat /etc/security/pam_env.conf add_label "License manager status" if ping -c 1 www.wyday.com &> /dev/null; then echo "ping to www.wyday.com successful" else echo "ping to www.wyday.com unsuccessful" fi echo "Online license status:" rstudio-server license-manager status echo "Offline license status:" rstudio-server license-manager status-offline # TODO enhance to check with --proxy flag, if need be add_label "Machine environment" env echo "" echo "ldd rserver" ldd /usr/lib/rstudio-server/bin/rserver echo "ldd rsession" ldd /usr/lib/rstudio-server/bin/rsession add_label "R environment outside RStudio (default R)" echo "Sys.info:" Rscript -e 'Sys.info()' echo "sessionInfo:" Rscript -e 'sessionInfo()' echo "Sys.getEnv:" Rscript -e 'Sys.getenv()' echo ".libPaths:" Rscript -e '.libPaths()' echo "R_HOME" echo $R_HOME # TODO: Is there a way to get the R environment from within RStudio? # Would have to log in as a particular user, and would need to check that RSP is up first add_label "RStudio messages in the system log" case $DISTRO in "RedHat" | "CentOS" | "SUSE") SYS_LOG_PATH="/var/log/messages" ;; "Ubuntu" | "Debian") SYS_LOG_PATH="/var/log/syslog" ;; esac [ -f $SYS_LOG_PATH ] && { cat $SYS_LOG_PATH | grep rstudio-server; cat $SYS_LOG_PATH | grep rstudio-session; } add_label "RStudio Server log" RSP_LOG_PATH="/var/lib/rstudio-server/monitor/log/rstudio-server.log" [ -f $RSP_LOG_PATH ] && cat $RSP_LOG_PATH add_label "Java environment" echo "whereis: $(whereis java)" echo "version: $(java -version)" echo "" echo "JAVA_HOME" echo $JAVA_HOME echo "" echo "PATH" echo $PATH echo "" echo "Get status of JVM" [ $(which jps) >/dev/null ] && jps -lvm || echo "jps is not available to get further information." echo "** Compare this data to the contents of the $R_CONFIG_DIR/javaconf file above." add_label "Network connections" echo "http_proxy env var: $http_proxy" echo "all_proxy env var: $all_proxy" # TODO: Check for ping, wget before trying? telnet to port 80 if ping doesn't work if ping -c 1 www.google.com &> /dev/null; then echo "ping to www.google.com successful" else echo "ping to www.google.com unsuccessful" fi echo "GET headers:" curl -vs www.google.com 1> /dev/null # TODO: test connection to RSP; may need to scrape host, port from rstudio-server.conf if defined echo "" echo "Check websocket handshake headers:" # TODO: adapt this to check for host, port in rstudio-server.conf curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: localhost:8787" -H "Origin: localhost:8787" http://localhost:8787 # TODO check file system for correct permissions for server user, ability to establish a file lock date } # TODO add function for script flag for project sharing checks - and add results to OUTPUT_FILE if those flags are set gather_info &> $OUTPUT_FILE echo "" echo "All done! Output file is here: $OUTPUT_FILE" echo "" echo "If you plan to send the output file to RStudio Support, you are welcome to sanitize any data that you feel is sensitive, but please let us know that you have done so." echo ""