From a8f727ad40aae0c359d91c8304954d3bd027de38 Mon Sep 17 00:00:00 2001 From: weslambert Date: Tue, 25 Aug 2020 11:19:36 -0400 Subject: [PATCH 1/2] Don't write to log if not past CRIT_DISK_USAGE --- salt/common/tools/sbin/so-sensor-clean | 2 -- 1 file changed, 2 deletions(-) diff --git a/salt/common/tools/sbin/so-sensor-clean b/salt/common/tools/sbin/so-sensor-clean index 886b16fcd..9f295ced5 100755 --- a/salt/common/tools/sbin/so-sensor-clean +++ b/salt/common/tools/sbin/so-sensor-clean @@ -115,7 +115,5 @@ if [ "$CUR_USAGE" -gt "$CRIT_DISK_USAGE" ]; then clean CUR_USAGE=$(df -P $SENSOR_DIR | tail -1 | awk '{print $5}' | tr -d %) done -else - echo "$(date) - Current usage value of $CUR_USAGE not greater than CRIT_DISK_USAGE value of $CRIT_DISK_USAGE..." >> $LOG fi From c03812f7abfaabffb5ca390cb88f625ed2bf4da4 Mon Sep 17 00:00:00 2001 From: Wes Lambert Date: Tue, 25 Aug 2020 15:34:30 +0000 Subject: [PATCH 2/2] Add rotation for sensor_clean log --- salt/common/cron/sensor-rotate | 2 ++ salt/common/files/sensor-rotate.conf | 10 ++++++++++ salt/common/init.sls | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 salt/common/cron/sensor-rotate create mode 100644 salt/common/files/sensor-rotate.conf diff --git a/salt/common/cron/sensor-rotate b/salt/common/cron/sensor-rotate new file mode 100644 index 000000000..94cebf75d --- /dev/null +++ b/salt/common/cron/sensor-rotate @@ -0,0 +1,2 @@ +#!/bin/bash +/usr/sbin/logrotate -f /opt/so/conf/sensor-rotate.conf > /dev/null 2>&1 diff --git a/salt/common/files/sensor-rotate.conf b/salt/common/files/sensor-rotate.conf new file mode 100644 index 000000000..a7e4cb303 --- /dev/null +++ b/salt/common/files/sensor-rotate.conf @@ -0,0 +1,10 @@ +/opt/so/log/sensor_clean.log +{ + daily + rotate 2 + missingok + nocompress + create + sharedscripts + endscript +} diff --git a/salt/common/init.sls b/salt/common/init.sls index 967c74c42..1a51fdb44 100644 --- a/salt/common/init.sls +++ b/salt/common/init.sls @@ -163,4 +163,26 @@ utilsyncscripts: - daymonth: '*' - month: '*' - dayweek: '*' + +sensorrotatescript: + file.managed: + - name: /usr/local/bin/sensor-rotate + - source: salt://common/cron/sensor-rotate + - mode: 755 + +sensorrotateconf: + file.managed: + - name: /opt/so/conf/sensor-rotate.conf + - source: salt://common/files/sensor-rotate.conf + - mode: 644 + +/usr/local/bin/sensor-rotate: + cron.present: + - user: root + - minute: '*' + - hour: '*' + - daymonth: '*' + - month: '*' + - dayweek: '*' + {% endif %}