Commit e012bfb7 authored by Joanne Hugé's avatar Joanne Hugé

log files

parent 1b662c1e
......@@ -60,7 +60,7 @@ md5sum = 52da9fe3a569199e35ad89ae1a44c30e
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = b5fafebe6d28fba36f7bdc4d5439a2f3
md5sum = 492b50aad5bd9be834091eca1dfb0149
[template-ors-enb]
_update_hash_filename_ = instance-ors-enb.jinja2.cfg
......
......@@ -134,7 +134,6 @@ xlog-fluentbit = ${:var}/xlog-fluentbit
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
enb-info-log = ${directory:log}/enb-info.log
enb-info-archive-log = ${directory:log}/enb-info.log
enb-radio-log = ${directory:log}/enb.log
enb-start-date = ${directory:run}/enb-start.date
inline =
......@@ -149,21 +148,35 @@ inline =
echo "System info: $(uname -a)" >> ${:enb-info-log}
({{ amarisoft['sdr_dir'] }}/sdr_util version && echo) >> ${:enb-info-log}
# Remove obsolete logs
rm -f ${directory:log}/enb-2024*
rm -f ${directory:log}/enb-2*
rm -f ${directory:log}/gnb*
rm -f ${directory:log}/enb-output.log
# Keep the 50 latest enb radio log
stat ${:enb-start-date} && mv ${:enb-radio-log} ${directory:log}/enb.log.$(cat ${:enb-start-date})
rm -f $(ls -1t ${directory:log}/enb-2* | tail -n+50)
rm -f $(ls -1t ${directory:log}/enb-info-2* | tail -n+50)
date +"%Y%m%d.%T" > ${:enb-start-date}
# Trim enb info log to 500k and keep a 100M archive of enb info log
head -c -500k ${:enb-info-log} >> ${:enb-info-archive-log}
tail -c 500k ${:enb-info-log} > ${:enb-info-log}.tmp
mv ${:enb-info-log}.tmp ${:enb-info-log}
tail -c 100M ${:enb-info-archive-log} > ${:enb-info-archive-log}.tmp
mv ${:enb-info-archive-log}.tmp ${:enb-info-archive-log}
# Archive current log
stat ${:enb-start-date} && mv ${:enb-radio-log} ${:enb-radio-log}.$(cat ${:enb-start-date})
# Split enb info log into 500k chunks
if test $(du ${:enb-info-log} | cut -f1) -ge 100000 ; then
stat ${:enb-start-date} || date +"%Y%m%d.%T" > ${:enb-start-date}
head -c -500k ${:enb-info-log} > ${:enb-info-log}.$(cat ${:enb-start-date})
tail -c 500k ${:enb-info-log} > ${:enb-info-log}.tmp
mv ${:enb-info-log}.tmp ${:enb-info-log}
fi
# Keep only 5Gb for radio logs and 1Gb for eNB info log
trim() {
i=-1
N=$(ls -1t $2* | wc -l)
TOTAL=$1
while test $TOTAL -ge $1 ; do
i=$((i+1))
TOTAL=$(du -c $(ls -1t $2* | head -n$((N-i))) | tail -n1 | cut -f1)
done
rm -f $(ls -1t $2* | tail -n$i)
}
trim 5000000 ${:enb-radio-log}.
trim 1000000 ${:enb-info-log}.
# Remove almost empty enb radio archive log files
rm -f $(find $(dirname ${:enb-radio-log}) -name "$(basename ${:enb-radio-log}).*" -size -5k)
# Launch lteenb
date +"%Y%m%d.%T" > ${:enb-start-date}
{{ amarisoft['enb_dir'] }}/lteenb ${directory:etc}/enb.cfg >> ${:enb-info-log} 2>> ${:enb-info-log}
[enb-service]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment