diff --git a/nextcloud/manifests/cron-count-users.yml b/nextcloud/manifests/cron-count-users.yml new file mode 100644 index 0000000000000000000000000000000000000000..fabf1fac72b9b2bd876ba1e7a466488510ada91d --- /dev/null +++ b/nextcloud/manifests/cron-count-users.yml @@ -0,0 +1,43 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + labels: + app: nextcloud + component: count-active-users + name: ${FQDN}-count + namespace: ${NS} +spec: + concurrencyPolicy: Forbid + failedJobsHistoryLimit: 1 + schedule: '15 15 * * *' + jobTemplate: + spec: + template: + metadata: + labels: + app: nextcloud + component: count-active-users + spec: + restartPolicy: Never + containers: + - name: psql + image: postgres:12-alpine + command: + - sh + - -c + - > + echo {\"30days\":`psql -t -c "select count(*) from preferences where configkey = 'lastLogin' and to_timestamp("configvalue"::integer) > ('now'::timestamp - '1 month'::interval);" | xargs`,\"90days\":`psql -t -c "select count(*) from preferences where configkey = 'lastLogin' and to_timestamp("configvalue"::integer) > ('now'::timestamp - '3 month'::interval);" | xargs`} + env: + - name: PGHOST + value: pg-${NS} + - name: PGDATABASE + value: nextcloud + - name: PGUSER + value: postgres + - name: PGPASSWORD + valueFrom: + secretKeyRef: + key: password + name: postgres.pg-${PG_DOMAIN}.credentials +#psql -h pg-desami-es -U postgres nextcloud -t -c "select count(*) from preferences where configkey = 'lastLogin' and to_timestamp("configvalue"::integer) > ('now'::timestamp - '1 month'::interval);" +#psql -t -c "select count(*) from preferences where configkey = 'lastLogin' and to_timestamp("configvalue"::integer) > ('now'::timestamp - '1 month'::interval);" diff --git a/rocketchat/manifests/cron-count-users.yml b/rocketchat/manifests/cron-count-users.yml new file mode 100644 index 0000000000000000000000000000000000000000..a88746f788562e44922f67ef5dab5e9b9143d6ef --- /dev/null +++ b/rocketchat/manifests/cron-count-users.yml @@ -0,0 +1,47 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + labels: + app: Rocketchat + component: count-active-users + name: ${FQDN}-count + namespace: ${NS} +spec: + concurrencyPolicy: Forbid + failedJobsHistoryLimit: 1 + schedule: '10 15 * * *' + jobTemplate: + spec: + template: + metadata: + labels: + app: Rocketchat + component: count-active-users + spec: + restartPolicy: Never + containers: + - name: wrench + image: libresh/wrench + args: + - rc + - user + - count + - --mongo-url=$(MONGO_URL) + - --active + - --last-login=30 + env: + - name: MONGO_URL + valueFrom: + secretKeyRef: + key: MONGO_URL + name: ${FQDN}-app + - name: ADMIN_USER + valueFrom: + configMapKeyRef: + key: ADMIN_USERNAME + name: ${FQDN}-config + - name: ADMIN_PASS + valueFrom: + secretKeyRef: + key: ADMIN_PASS + name: ${FQDN}-app