as.gentoo Guru


Joined: 07 Aug 2004 Posts: 319
|
Posted: Mon May 08, 2017 11:14 pm Post subject: How do I get metalog rotation + script execution work? |
|
|
Hello,
I'm using metalog for a long time now. It lately stuck that metalog removed old logs instead of keeping them.
I created a script that handles a rotated file but nothing happens. There is nothing like 'metalog <some error happened>' in the /var/log/everything/* log files.
Here is my setup
Code: | /etc/conf.d/metalog
METALOG_OPTS="-s"
CONSOLE="/dev/tty10"
FORMAT='$1 [$2] $3' |
Code: | /etc/metalog
maxsize = 268435456
maxtime = 2419200
maxfiles = 3
Everything important :
facility = "*"
minimum = 6
logdir = "/var/log/everything"
postrotate_cmd = "/sbin/metalog-postrotate-compress.sh"
Everything very important :
facility = "*"
minimum = 1
logdir = "/var/log/critical"
postrotate_cmd = "/sbin/metalog-postrotate-compress.sh"
break = 1
[…] |
Code: | $> ll /sbin/metalog-postrotate-compress.sh
-rwx------ 1 root root 4221 1. Mai 11:48 /sbin/metalog-postrotate-compress.sh |
Code: | /sbin/metalog-postrotate-compress.sh
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] ; then
echo -e "\nThere is a problem with calling this script.\nAt least one parameter is missing.\nThis script is intended to be called by metalog only!\n" ; exit 1
fi
s_date="$1" # from metalog(d)
s_caller="$2" # log source (smartd, openrc…), "facility" from metalog.conf ???
s_logfile="$3" # logfile full path name ### CHECK ###
s_target_file="${s_logfile}"
if [ -n "${s_logfile}" ] && [ -f "${s_logfile}" ] && [ -s "${s_logfile}" ] && [ -r "${s_logfile}" ] && [ -w "${s_logfile}" ] ; then
umask 0077
renice -n 19 -p $$ > /dev/null
ionice -c 3 -p $$ > /dev/null
echo -e "\n\nzpaq a \"${s_target_file}.zpaq\" \"${s_logfile}\" -method 5" >> /home/xxx/tmp/METALOG_calls_program.out
/usr/bin/time sh -c "zpaq a \"${s_target_file}.zpaq\" \"${s_logfile}\" -method 5" 1>>/home/xxx/tmp/METALOG_calls_program.out 2>>/home/xxx/tmp/METALOG_calls_program.out
if [ $? -ne 0 ] ; then echo "zpaq compression of '${s_logfile}' failed" && exit 10 ; fi
fi
echo -e "\n" $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 "\n" >> /home/xxx/tmp/METALOG_calls_program.out |
Code: | /var/log/everything/
-rw-r--r-- 1 root root 1800334 9. Mai 00:34 /var/log/everything/current
-rw-r--r-- 1 root root 2018117 6. Apr 01:59 /var/log/everything/log-2017-04-06-00:00:01
-rw-r--r-- 1 root root 4110283 13. Apr 01:59 /var/log/everything/log-2017-04-13-00:00:01
-rw-r--r-- 1 root root 1285154 20. Apr 01:59 /var/log/everything/log-2017-04-20-00:00:01
-rw-r--r-- 1 root root 1422020 27. Apr 01:59 /var/log/everything/log-2017-04-27-00:00:01 |
So there are four rotated log files, so the condition maxfiles=3 was met.
What's wrong here?
When I (re)start metalog I get Code: | […]
* Starting metalog ...
* start-stop-daemon: fopen `/run/metalog.pid': No such file or directory
* Detaching to start `/usr/sbin/metalog' ... | Is that relevant anyhow? |
|