mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-18 10:43:40 +00:00
feat: rotate csp_reports
This commit is contained in:
parent
d95ba3f4c0
commit
8ddfa0b065
4 changed files with 28 additions and 13 deletions
|
@ -1,15 +1,4 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Volcar y eliminar todos los access logs de dos días atrás
|
||||
date="`dateadd today -1d`"
|
||||
file="/srv/http/_storage/${date}.psql.gz"
|
||||
test -n "${date}"
|
||||
test ! -f "${file}"
|
||||
|
||||
psql -h postgresql "${DATABASE:-sutty}" sutty <<SQL | gzip > "${file}"
|
||||
begin;
|
||||
copy (select * from access_logs where created_at < '${date}') to stdout;
|
||||
delete from access_logs where created_at < '${date}';
|
||||
commit;
|
||||
SQL
|
||||
`realpath $0 | xargs dirname`/rotate_table access_logs
|
||||
|
|
4
bin/csp_reports
Executable file
4
bin/csp_reports
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
`realpath $0 | xargs dirname`/rotate_table csp_reports
|
17
bin/rotate_table
Executable file
17
bin/rotate_table
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
test -n "$1"
|
||||
|
||||
# Volcar y eliminar todos los access logs de dos días atrás
|
||||
date="`dateadd today -1d`"
|
||||
file="/srv/_storage/$1-${date}.psql.gz"
|
||||
test -n "${date}"
|
||||
test ! -s "${file}"
|
||||
|
||||
psql -h postgresql "${DATABASE:-sutty}" sutty <<SQL | gzip > "${file}"
|
||||
begin;
|
||||
copy (select * from $1 where created_at < '${date}') to stdout;
|
||||
delete from $1 where created_at < '${date}';
|
||||
commit;
|
||||
SQL
|
|
@ -16,7 +16,12 @@ check program fediblocks
|
|||
|
||||
check program access_logs
|
||||
with path "/srv/http/bin/access_logs" as uid "app" and gid "www-data"
|
||||
every "0 0 * * *"
|
||||
every "0 3 * * *"
|
||||
if status != 0 then alert
|
||||
|
||||
check program csp_reports
|
||||
with path "/srv/bin/csp_reports" as uid "rails" and gid "www-data"
|
||||
every "0 7 * * *"
|
||||
if status != 0 then alert
|
||||
|
||||
check program stats
|
||||
|
|
Loading…
Reference in a new issue