403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.74
Web Server : LiteSpeed
System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
User : azfilmst ( 1070)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/nagios/plugins/a2_postgresql-monitor.shared
#!/bin/bash

# Script to monitor PostGresSQL service and verify that postgres user can authenticate and connect to PostgreSQL
# SYSENG-25206

#Checking if PostgreSQL is running
if systemctl is-active --quiet postgresql; then

pgpass_file="/var/lib/pgsql/.pgpass"
root_pgpass_file="/root/.pgpass"

#Fix .pgpass
 _fix_pgpass_file() {
   if [[ -f "$root_pgpass_file" ]]; then
     /usr/bin/cp -f ${root_pgpass_file} ${pgpass_file}
     /usr/bin/chmod 600 ${pgpass_file}
     /usr/bin/chown postgres.postgres ${pgpass_file}
   else
     echo "PostgreSQL is missing /root/.pgpass file. Please check."
     exit 2
   fi
 }

#Function to check if postgres user can authenticate
 _check_auth_postgresql() {
    pg_voutput=$(su - postgres -c 'psql -wc "SELECT version();"' 2>&1)

    if echo "${pg_voutput}" | grep -q PostgreSQL; then
      pg_Ver=$(echo "${pg_voutput}"| awk '/PostgreSQL/ {print $2}')
      echo "PostgreSQL ${pg_Ver} is up and postgres user can authenticate."
      exit 0
    else
      echo "postgres user cannot authenticate to PostgreSQL."
      exit 0
    fi
  }

  if ! cmp -s "$root_pgpass_file" "$pgpass_file"; then
     _fix_pgpass_file
  fi

  _check_auth_postgresql

else
  echo "PostgreSQL is not running. Please check."
  exit 2
fi

Youez - 2016 - github.com/yon3zu
LinuXploit