Add pgBadger

master
Jeff Moe 6 years ago
parent c9e8c4cf55
commit c87cc5ff22

@ -11,12 +11,12 @@ cd /root/borg
# Note, get real string with correct host/user/pass:
sed -i -e 's/user@host/1234@host.com/g' forksand-borg-*
# If repo is moved, run:
sed -i -e 's/BORG_RELOCATED_REPO_ACCESS_IS_OK=no/BORG_RELOCATED_REPO_ACCESS_IS_OK=yes/g' forksand-borg-*
# sed -i -e 's/BORG_RELOCATED_REPO_ACCESS_IS_OK=no/BORG_RELOCATED_REPO_ACCESS_IS_OK=yes/g' forksand-borg-*
# No password:
ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519-borg-`hostname`
# Create borg key:
# Create borg key (needs rsync.net password):
./forksand-borg-add-key
# Initalize new repo, no passphrase:

@ -0,0 +1,70 @@
# pgBadger for PostgreSQL
##############################################################################
# Install on PostgreSQL Servers
# Using upstream postresql's repos, not Debian's repos.
#apt install
# Configure postgres:
vim /etc/postgresql/10/main/postgresql.conf
# Change:
log_min_duration_statement = 1000
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
log_error_verbosity = default
lc_messages='C'
# Add user to pull logs on pg1 pg2 pg3 pg4
adduser pgbadger
adduser pgbadger adm
# Set up key on pgbadger node to enable it to ssh to pg1 pg2 pg3 pg4
##############################################################################
# Install on Web Node
# Set up Debian Stretch node
# Install postgres repos:
echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt update
apt install postgresql-client-10
apt install pgbadger libtext-csv-xs-perl libjson-xs-perl
adduser pgbadger
sudo su - pgbadger
ssh-keygen -t ed25519
# copy that key to user pgbadger@pg1 pg2 pg3 pg4
# Set up apache2
apt install apache2
rm /var/www/html/index.html
chown pgbadger:pgbadger /var/www/html
mkdir /var/www/html/pg1 /var/www/html/pg2 /var/www/html/pg3 /var/www/html/pg4
# Set up script for user pgbadger to run:
# See script: forksand-pgbadger-gen
# Run that script in cron as user pgbadger:
crontab -e
# m h dom mon dow command
*/5 * * * * /home/pgbadger/forksand-pgbadger-gen
##############################################################################
# Admin Web Client
# On workstation create tunnel:
ssh -N -C -L 55432:localhost:80 pgbadger
# On workstation, in browser:
http://localhost:55432/
##############################################################################

@ -0,0 +1,46 @@
#!/bin/bash
# forksand-pgbadger-gen
pgbadger \
--remote-host pg1 \
--incremental \
--jobs 4 \
--outdir /var/www/html/pg1 \
--retention 8 \
--extra-files \
--ssh-user pgbadger \
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
/var/log/postgresql/postgresql-10-main.log
pgbadger \
--remote-host pg2 \
--incremental \
--jobs 4 \
--outdir /var/www/html/pg2 \
--retention 8 \
--extra-files \
--ssh-user pgbadger \
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
/var/log/postgresql/postgresql-10-main.log
pgbadger \
--remote-host pg3 \
--incremental \
--jobs 4 \
--outdir /var/www/html/pg3 \
--retention 8 \
--extra-files \
--ssh-user pgbadger \
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
/var/log/postgresql/postgresql-10-main.log
pgbadger \
--remote-host pg4 \
--incremental \
--jobs 4 \
--outdir /var/www/html/pg4 \
--retention 8 \
--extra-files \
--ssh-user pgbadger \
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
/var/log/postgresql/postgresql-10-main.log

@ -42,3 +42,6 @@ pg_top
# pgcli -- command line
##############################################################################
# XXX
log_timezone = 'Navajo'
##############################################################################

@ -27,10 +27,10 @@ apt install -t stretch-backports prometheus-node-exporter
apt install prometheus-node-exporter
# To enable various collectors on a node, edit:
vim /etc/default/prometheus-node-exporter
#vim /etc/default/prometheus-node-exporter
# Ones of note:
-collector.netstat.fields=(.*) --collector.vmstat.fields=(.*) --collector.interrupts
#-collector.netstat.fields=(.*) --collector.vmstat.fields=(.*) --collector.interrupts
# Add to all: XXX not done
################

Loading…
Cancel
Save