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
Post a Comment