11# Check disk space and file system type for important Postgres-related disk partitions
22
3- PG_MAJOR_VER=$( ssh " $HOST " " ${_PSQL} -f -" << EOF
3+ PG_MAJOR_VER=$( ${CHECK_HOST_CMD} " ${_PSQL} -f -" << EOF
44 select setting::integer / 10000 from pg_settings where name = 'server_version_num'
55EOF
66)
77
8- PG_DATA_DIR=$( ssh " $HOST " " ${_PSQL} -f -" << EOF
8+ PG_DATA_DIR=$( ${CHECK_HOST_CMD} " ${_PSQL} -f -" << EOF
99 show data_directory
1010EOF
1111)
1212
13- PG_STATS_TEMP_DIR=$( ssh " $HOST " " ${_PSQL} -f -" << EOF
13+ PG_STATS_TEMP_DIR=$( ${CHECK_HOST_CMD} " ${_PSQL} -f -" << EOF
1414 show stats_temp_directory
1515EOF
1616)
1717
18- PG_LOG_DIR=$( ssh " $HOST " " ${_PSQL} -f -" << EOF
18+ PG_LOG_DIR=$( ${CHECK_HOST_CMD} " ${_PSQL} -f -" << EOF
1919 show log_directory
2020EOF
2121)
@@ -28,7 +28,7 @@ if ! [[ "${PG_STATS_TEMP_DIR}" =~ ^/ ]]; then
2828 PG_STATS_TEMP_DIR=" ${PG_DATA_DIR} /${PG_STATS_TEMP_DIR} "
2929fi
3030
31- PG_TABLESPSACES_DIRS=$( ssh " $HOST " " ${_PSQL} -f -" << EOF
31+ PG_TABLESPSACES_DIRS=$( ${CHECK_HOST_CMD} " ${_PSQL} -f -" << EOF
3232 SELECT pg_catalog.pg_tablespace_location(oid)
3333 FROM pg_catalog.pg_tablespace
3434 WHERE pg_tablespace_location(oid) ~ '/'
@@ -77,7 +77,7 @@ df_to_json() {
7777# ######################################
7878print_df () {
7979 local path=" $1 "
80- df_to_json " ${path} " $( ssh ${HOST } " sudo df -TPh \" ${path} \" | tail -n +2" )
80+ df_to_json " ${path} " $( ${CHECK_HOST_CMD } " sudo df -TPh \" ${path} \" | tail -n +2" )
8181}
8282
8383# json output starts here
@@ -102,10 +102,13 @@ echo ","
102102
103103echo " \" stats_temp_directory\" :"
104104print_df " $PG_STATS_TEMP_DIR "
105- echo " ,"
106105
107- echo " \" log_directory\" :"
108- print_df " $PG_LOG_DIR "
106+ # do not fail if log_directory does not exist
107+ if $( ${CHECK_HOST_CMD} " sudo stat \" $PG_LOG_DIR \" >/dev/null 2>&1" ) ; then
108+ echo " ,"
109+ echo " \" log_directory\" :"
110+ print_df " $PG_LOG_DIR "
111+ fi
109112
110113echo " }"
111-
114+
0 commit comments