12 count
=$(psql -h $host -p $port -A -q -c '\t' -c 'select count(datname) from pg_catalog.pg_database
' postgres 2>&1)
15 if [[ $exit_code -ne 0 ]]; then
16 echo "UNKNOWN - Impossible to run psql command: $count"
18 elif [[ -z "$count" ]]; then
19 echo "UNKNOWN - No database found"
22 output="Database count is $count"
23 LC_ALL=C count=$(printf "%.*f" 0 $count)
25 if [[ $count -gt $min ]]; then
26 echo "OK - $output | count=${count};$min;$min;0;"
29 echo "CRITICAL - $output | count=${count};$min;$min;0;"