5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 19:06:23 +00:00

volcar y eliminar los logs del día anterior

This commit is contained in:
f 2022-04-23 16:28:32 -03:00
parent cd1263a672
commit f96c7aff7d
2 changed files with 17 additions and 0 deletions

12
bin/access_logs Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
set -e
# Volcar y eliminar todos los access logs del día anterior
date=`date +%F`
psql -h postgresql "${DATABASE:-sutty}" sutty <<SQL | gzip > "/srv/http/_storage/${date}.psql.gz"
begin;
copy (select * from access_logs where created_at < '${date}') to stdout;
delete from access_logs where created_at < '${date}';
commit;
SQL

View file

@ -29,3 +29,8 @@ check program blazer
as uid "app" and gid "www-data" as uid "app" and gid "www-data"
every 61 cycles every 61 cycles
if status != 0 then alert if status != 0 then alert
check program access_logs
with path "/srv/http/bin/access_logs" as uid "app" and gid "www-data"
every "0 0 * * *"
if status != 0 then alert