Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit f4150cb

Browse files
committed
Do not fail if log_directory does not exist
1 parent cf7be4a commit f4150cb

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

resources/checks/A008_disk_usage_fstype.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
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'
55
EOF
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
1010
EOF
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
1515
EOF
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
2020
EOF
2121
)
@@ -28,7 +28,7 @@ if ! [[ "${PG_STATS_TEMP_DIR}" =~ ^/ ]]; then
2828
PG_STATS_TEMP_DIR="${PG_DATA_DIR}/${PG_STATS_TEMP_DIR}"
2929
fi
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
#######################################
7878
print_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
@@ -104,8 +104,11 @@ echo "\"stats_temp_directory\":"
104104
print_df "$PG_STATS_TEMP_DIR"
105105
echo ","
106106

107-
echo "\"log_directory\":"
108-
print_df "$PG_LOG_DIR"
107+
# do not fail if log_directory does not exist
108+
if $(${CHECK_HOST_CMD} "sudo stat \"$PG_LOG_DIR\" >/dev/null 2>&1"); then
109+
echo "\"log_directory\":"
110+
print_df "$PG_LOG_DIR"
111+
fi
109112

110113
echo "}"
111-
114+

0 commit comments

Comments
 (0)