-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
…ck_name', generate report with this filename, add 'check_name' into json report
echo >&2 | ||
} | ||
|
||
####################################### | ||
# Cleanup function: close ssh sockets, etc. | ||
# Globals: | ||
# None | ||
# HOST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOSTS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see -- HOST
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to check only one host per single script run.
done | ||
if [[ ! -z ${HOST+x} ]]; then | ||
dbg "closing ssh conenction to host '$HOST' (if exists)" | ||
ssh -O exit ${HOST} 2>/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this for closing persistent ssh connection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
check
Outdated
# Generate json report | ||
# Globals: | ||
# CURRENT_CHECK, SCRIPT_DIR, PROJECT, | ||
# HOST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra ,
|
||
local epoch=null | ||
|
||
[[ -z ${3+x} ]] && err "function needs 3 arguments" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool way to check it!
#dbg "PSQL_CONN_OPTIONS: ${PSQL_CONN_OPTIONS}" | ||
pgver=$(psql ${PSQL_CONN_OPTIONS} -c "SHOW server_version" -t -A) | ||
|
||
pgver=$(ssh ${HOST} "${_PSQL} -c \"SHOW server_version\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit easer to get show server_version_num
here and the make interger comparison, w/o any regexp-replacement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's refactor checks separate from script logic?
@@ -127,7 +129,7 @@ EOF | |||
|
|||
fi | |||
|
|||
psql ${PSQL_CONN_OPTIONS} <<SQL | |||
ssh ${HOST} "${_PSQL} -f - " <<SQL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's great that it works!
@@ -10,7 +10,10 @@ | |||
Connection options|p|port|PORT|number|optional|PostgreSQL database server port (default: "5432") | |||
Connection options|d|dbname|DBNAME|word|optional|database name to connect to (default: "postgres") | |||
Connection options|U|username|USERNAME|word|optional|database user name (default: current) | |||
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket") | |||
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host | |||
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is light inconsistency in naming here -- various prefixes (DB...
, PG...
, and no prefix as in HOST
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I changed PORT
to PGPORT
. DBNAME
: I've got from man psql
.
HOST
: I decided to keep "as is" 'cause it is slightly not the same as PGHOST
- we use it for a ssh
connection.
resources/cli.conf
Outdated
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket") | ||
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host | ||
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default) | ||
Connection options|None|psql-binary|PGBINARY|text|optional|psql utility path (default: from $PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSQLBINARY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, fixed. Thanks.
@@ -0,0 +1,12 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any risk that we, working with some particular DB replicaset, will override this file and commit/push by mistake?
it is kind of config, right? it will be individual for every project? where can we keep it (may we keep it outside the repo?)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... ./resources/templates
directory conceived as a place where we keep templates to generate another files.
It is a part of ./check
. We don't write artifacts into ./resources
dirs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Only a few of minor comments. Let's merge it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replied and will push fixes.
echo >&2 | ||
} | ||
|
||
####################################### | ||
# Cleanup function: close ssh sockets, etc. | ||
# Globals: | ||
# None | ||
# HOST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to check only one host per single script run.
done | ||
if [[ ! -z ${HOST+x} ]]; then | ||
dbg "closing ssh conenction to host '$HOST' (if exists)" | ||
ssh -O exit ${HOST} 2>/dev/null || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
#dbg "PSQL_CONN_OPTIONS: ${PSQL_CONN_OPTIONS}" | ||
pgver=$(psql ${PSQL_CONN_OPTIONS} -c "SHOW server_version" -t -A) | ||
|
||
pgver=$(ssh ${HOST} "${_PSQL} -c \"SHOW server_version\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's refactor checks separate from script logic?
@@ -10,7 +10,10 @@ | |||
Connection options|p|port|PORT|number|optional|PostgreSQL database server port (default: "5432") | |||
Connection options|d|dbname|DBNAME|word|optional|database name to connect to (default: "postgres") | |||
Connection options|U|username|USERNAME|word|optional|database user name (default: current) | |||
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket") | |||
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host | |||
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I changed PORT
to PGPORT
. DBNAME
: I've got from man psql
.
HOST
: I decided to keep "as is" 'cause it is slightly not the same as PGHOST
- we use it for a ssh
connection.
resources/cli.conf
Outdated
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket") | ||
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host | ||
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default) | ||
Connection options|None|psql-binary|PGBINARY|text|optional|psql utility path (default: from $PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, fixed. Thanks.
@@ -0,0 +1,12 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... ./resources/templates
directory conceived as a place where we keep templates to generate another files.
It is a part of ./check
. We don't write artifacts into ./resources
dirs.
…tgres-health-check into 64-multiple-host-support
No description provided.