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 %} 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