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

Commit 23b5833

Browse files
committed
fixed comma issue with log_directory
1 parent 971b877 commit 23b5833

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

resources/checks/A008_disk_usage_fstype.sh

Lines changed: 13 additions & 10 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
@@ -102,10 +102,13 @@ echo ","
102102

103103
echo "\"stats_temp_directory\":"
104104
print_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

110113
echo "}"
111-
114+

0 commit comments

Comments
 (0)