Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL Monitoring Script

In this script is very usefull to monitoring the postgreSQL sserver example for how many query is running more than one minutes ,checking the disk space,checking the RAM usage and how many table having more than 5000 dead tubles for particular database.
echo " "
echo " "
HOSTNAME=`hostname`
PSQL="/opt/PostgreSQL/9.3/bin/psql"
PORT=5432
HOST="localhost"
DB="template1"
USER="postgres"
echo "------***WHAT ARE THE QUERY IS RUNING MORE THAN 1 MINUTES***------"
$PSQL -d $DB -U $USER -p $PORT <<EOF
\pset format wrapped
SELECT pid, now() - query_start as "runtime", usename, datname, state, query
  FROM  pg_stat_activity
  WHERE now() - query_start > '1 minutes'::interval
 ORDER BY runtime DESC;

EOF

echo " "
echo " "
echo " "

echo "------***CHECKING dISK SPACE***------"
        df -h

echo " "
echo " "
echo " "

echo "------***CHECKING RAM USAGE***------"
       free -h

echo " "
echo " "
echo " "

echo "------***HOW MANY TABLES HAVING MORE THAN 5000 DEAD TUBLES FOR PARTICULAR DATABASE***------"


$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhrorpar
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF

echo " "

$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhroraur
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF

echo " "

$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhroryav
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF

echo " "

$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhrorlat
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF

echo " "

$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhrornan
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF

echo " "

$PSQL -d $DB -U $USER -p $PORT <<EOF
\c mhrornad
select count(*) from pg_stat_all_tables where n_dead_tup > 5000;
EOF         

Comments

Popular posts from this blog

VMWARE WORKSTATION 3,4,5,6,7,8,9,10,11,12,14,15...etc LICENSE KEYS COLLECTION

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

Oracle to Postgresql migration

PostgreSQL Enterprise Manager - PEM Monitoring Tools

7 Steps to configure BDR replication in postgresql