Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
112
Merge Requests
112
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
9d17f845
Commit
9d17f845
authored
Mar 14, 2025
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log
parent
70272d8b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
146 additions
and
60 deletions
+146
-60
software/simpleran/buildout.hash.cfg
software/simpleran/buildout.hash.cfg
+7
-3
software/simpleran/instance-core-network.jinja2.cfg
software/simpleran/instance-core-network.jinja2.cfg
+44
-12
software/simpleran/instance-enb.jinja2.cfg
software/simpleran/instance-enb.jinja2.cfg
+31
-45
software/simpleran/instance.cfg
software/simpleran/instance.cfg
+1
-0
software/simpleran/script/amarisoft-log-rotate.sh
software/simpleran/script/amarisoft-log-rotate.sh
+60
-0
software/simpleran/software.cfg
software/simpleran/software.cfg
+3
-0
No files found.
software/simpleran/buildout.hash.cfg
View file @
9d17f845
...
...
@@ -16,7 +16,7 @@
[template]
filename = instance.cfg
md5sum =
1bd4ed3240f81ce5ff5a55e79366a3f4
md5sum =
200958a846df2bc50eb862c18cee2b7f
[template-ors]
filename = instance-ors.cfg
...
...
@@ -60,7 +60,7 @@ md5sum = 52da9fe3a569199e35ad89ae1a44c30e
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum =
983b611616b393546e6975ce4caa1025
md5sum =
bd13b2b7e0ec252ab13b428d9d782294
[template-ors-enb]
_update_hash_filename_ = instance-ors-enb.jinja2.cfg
...
...
@@ -72,7 +72,7 @@ md5sum = 82449c34a4632191931ce8aa88ce72e6
[template-core-network]
_update_hash_filename_ = instance-core-network.jinja2.cfg
md5sum =
4e1cd22bb173baac27b1eefce49710d3
md5sum =
3a55385da76b7d2b808f8b3ddd4e20e6
[template-ue]
_update_hash_filename_ = instance-ue.jinja2.cfg
...
...
@@ -82,6 +82,10 @@ md5sum = 763fa11181527bf4c481fd2e6a2f7c59
_update_hash_filename_ = instance-obsolete.jinja2.cfg
md5sum = c5f581ba01654b2aec46000abf8d0e35
[amarisoft-log-rotate-sh]
_update_hash_filename_ = script/amarisoft-log-rotate.sh
md5sum = 563bdcd56648b48e6d90d3256fa8467e
[ue_db.jinja2.cfg]
filename = config/ue_db.jinja2.cfg
md5sum = 5b046b0bd0f4b9b604a8ba947ae86417
...
...
software/simpleran/instance-core-network.jinja2.cfg
View file @
9d17f845
...
...
@@ -187,13 +187,31 @@ log = ${:var}/log
[ims-sh-wrapper]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
ims-log = ${directory:log}/ims-output.log
ims-log = ${directory:log}/ims.log
info-log = ${directory:log}/ims-info.log
start-date = ${directory:run}/ims-start.date
inline =
#!/bin/sh
(echo && echo && date "+[%Y/%m/%d %T.%N %Z] Starting IMS software..." && echo) >> ${:ims-log};
tail -c 1M ${:ims-log} > ${:ims-log}.tmp;
mv ${:ims-log}.tmp ${:ims-log};
{{ amarisoft['ims_dir'] }}/lteims ${directory:etc}/ims.cfg >> ${:ims-log} 2>> ${:ims-log};
# Amarisoft init scripts
sudo -n {{ amarisoft['dir'] }}/init-mme;
rm -f ${directory:var}/lte_ue.db;
# Print hardware and software info in info-log
cat > ${:info-log} << EOF
$(date "+[%Y/%m/%d %T.%N %Z] Starting IMS...")
System info: $(uname -a)
EOF
# Remove obsolete logs
rm -f ${directory:log}/ims-output*
/bin/sh {{ amarisoft_log_rotate_sh }} \
${:start-date} \
${:ims-log} \
${:info-log} \
${:max-combined-ims-log-kb-size} \
${:max-combined-info-log-kb-size} \
${:max-info-log-kb-size}
{{ amarisoft['ims'] }}/lteims ${directory:etc}/ims.cfg >> ${:info-log} 2>> ${:info-log};
### IMS
[ims-service]
...
...
@@ -214,21 +232,35 @@ environment =
[mme-sh-wrapper]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
mme-log = ${directory:log}/mme-output.log
mme-log = ${directory:log}/mme.log
info-log = ${directory:log}/mme-info.log
start-date = ${directory:run}/mme-start.date
inline =
#!/bin/sh
# Amarisoft init scripts
sudo -n {{ amarisoft['dir'] }}/init-mme;
rm -f ${directory:var}/lte_ue.db;
(echo && echo && date "+[%Y/%m/%d %T.%N %Z] Starting MME software..." && echo) >> ${:mme-log};
tail -c 1M ${:mme-log} > ${:mme-log}.tmp;
mv ${:mme-log}.tmp ${:mme-log};
{{ amarisoft['mme_dir'] }}/ltemme ${directory:etc}/mme.cfg >> ${:mme-log} 2>> ${:mme-log};
# Print hardware and software info in info-log
cat > ${:info-log} << EOF
$(date "+[%Y/%m/%d %T.%N %Z] Starting MME...")
System info: $(uname -a)
EOF
# Remove obsolete logs
rm -f ${directory:log}/mme-output*
/bin/sh {{ amarisoft_log_rotate_sh }} \
${:start-date} \
${:mme-log} \
${:info-log} \
${:max-combined-mme-log-kb-size} \
${:max-combined-info-log-kb-size} \
${:max-info-log-kb-size}
{{ amarisoft['mme_dir'] }}/ltemme ${directory:etc}/mme.cfg >> ${:info-log} 2>> ${:info-log};
### MME
[mme-service]
recipe = slapos.cookbook:wrapper
# When the machine shutdowns abruptly, lte_ue is not cleaned up which causes
# amarisoft ltemme to fail. TODO: find a cleaner way to handle this
command-line = ${mme-sh-wrapper:output}
wrapper-path = ${directory:service}/mme
mode = 0775
...
...
software/simpleran/instance-enb.jinja2.cfg
View file @
9d17f845
...
...
@@ -133,55 +133,41 @@ xlog-fluentbit = ${:var}/xlog-fluentbit
[enb-sh-wrapper]
recipe = slapos.recipe.template
output = ${directory:bin}/${:_buildout_section_name_}
enb-
info-log = ${directory:log}/enb-info.log
enb-
radio-log = ${directory:log}/enb.log
enb-
start-date = ${directory:run}/enb-start.date
max-
enb-radio-log-combined
-size = 5000000
max-
enb-info-log-combined
-size = 1000000
max-
enb-info-log
-size = 100000
info-log = ${directory:log}/enb-info.log
radio-log = ${directory:log}/enb.log
start-date = ${directory:run}/enb-start.date
max-
combined-radio-log-kb
-size = 5000000
max-
combined-info-log-kb
-size = 1000000
max-
info-log-kb
-size = 100000
inline =
#!/bin/sh
# Amarisoft init scripts
sudo -n {{ amarisoft['dir'] }}/rm-tmp-lte
sudo -n {{ amarisoft['dir'] }}/init-sdr {{ amarisoft['dir'] }}/v{{ amarisoft['version'] }};
sudo -n {{ amarisoft['dir'] }}/init-enb
# Add useful information to enb-info log
(echo && echo && date "+[%Y/%m/%d %T.%N %Z] Starting eNB software...") >> ${:enb-info-log}
(echo -n "PCB: " ; for o in t b v s ; do sudo -n {{ sdr['dir'] }}/get-sdr-info -$o 2> /dev/null ; echo -n " " ; done ; echo) >> ${:enb-info-log}
echo "System info: $(uname -a)" >> ${:enb-info-log}
({{ amarisoft['sdr_dir'] }}/sdr_util version && echo) >> ${:enb-info-log}
AMARI_DIR={{ amarisoft['dir'] }}
sudo -n $AMARI_DIR/rm-tmp-lte
sudo -n $AMARI_DIR/init-sdr $AMARI_DIR/v{{ amarisoft['version'] }};
sudo -n $AMARI_DIR/init-enb
# Print hardware and software info in info-log
cat > ${:info-log} << EOF
$(date "+[%Y/%m/%d %T.%N %Z] Starting eNB software...")
PCB: $(for o in t b v s ; do
sudo -n {{ sdr['dir'] }}/get-sdr-info -$o 2> /dev/null ; printf " "
done)
System info: $(uname -a)
./sdr_util version:
$({{ amarisoft['sdr_dir'] }}/sdr_util version)
EOF
# Remove obsolete logs
rm -f ${directory:log}/enb-2*
rm -f ${directory:log}/gnb*
rm -f ${directory:log}/enb-output.log
# Archive current log
stat ${:enb-start-date} && mv ${:enb-radio-log} ${:enb-radio-log}.$(cat ${:enb-start-date})
# Split enb info log into smaller chunks
if test $(du ${:enb-info-log} | cut -f1) -ge ${:max-enb-info-log-kb-size} ; then
stat ${:enb-start-date} || date +"%Y%m%d.%T" > ${:enb-start-date}
head -c -$((${:max-enb-info-log-kb-size}/2))k ${:enb-info-log} > ${:enb-info-log}.$(cat ${:enb-start-date})
tail -c $((${:max-enb-info-log-kb-size}/2))k ${:enb-info-log} > ${:enb-info-log}.tmp
mv ${:enb-info-log}.tmp ${:enb-info-log}
fi
# Limit combined size for enb radio archive logs and enb info archive logs
trim() {
stat $2* || return
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 ${:max-enb-radio-log-combined-kb-size} ${:enb-radio-log}.
trim ${:max-enb-info-log-combined-kb-size} ${: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}
rm -f ${directory:log}/enb-2* ${directory:log}/gnb* ${directory:log}/enb-output.log
/bin/sh {{ amarisoft_log_rotate_sh }} \
${:start-date} \
${:radio-log} \
${:info-log} \
${:max-combined-radio-log-kb-size} \
${:max-combined-info-log-kb-size} \
${:max-info-log-kb-size}
{{ amarisoft['enb_dir'] }}/lteenb ${directory:etc}/enb.cfg >> ${:info-log} 2>> ${:info-log}
[enb-service]
recipe = slapos.cookbook:wrapper
...
...
software/simpleran/instance.cfg
View file @
9d17f845
...
...
@@ -43,6 +43,7 @@ context =
key mac lan:mac
key my_ipv4 slap-configuration:ipv4-random
key my_ipv6 slap-configuration:ipv6-random
raw amarisoft_log_rotate_sh ${amarisoft-log-rotate-sh:target}
raw nginx_template ${nginx_conf.in:target}
raw nginx_mime ${nginx-output:mime}
raw nginx_executable ${nginx-output:nginx}
...
...
software/simpleran/script/amarisoft-log-rotate.sh
0 → 100644
View file @
9d17f845
#!/bin/sh
# Rotate and limit combined and individual Amarisoft log sizes
# This program should be launched before starting Amarisoft program
usage
()
{
cat
<<
ENDUSAGE
Required parameters:
START_DATE Path of file containing Amarisoft program start date
LOG Amarisoft log path
STDOUT_LOG Path of log containing stdout of the Amarisoft program
MAX_COMBINED_LOG_KB_SIZE Max combined size of all Amarisoft logs, in kB
MAX_COMBINED_STDOUT_LOG_KB_SIZE Max combined size of all Amarisoft stdout logs, in kB
MAX_STDOUT_LOG_KB_SIZE Max individual size of Amarisoft stdout logs
ENDUSAGE
1>&2
;
}
START_DATE
=
$1
LOG
=
$2
STDOUT_LOG
=
$3
MAX_COMBINED_LOG_KB_SIZE
=
$4
MAX_COMBINED_STDOUT_LOG_KB_SIZE
=
$5
MAX_STDOUT_LOG_KB_SIZE
=
$6
if
[
$#
-ne
6
]
;
then
usage
;
exit
1
fi
# Archive current log
stat
$START_DATE
&&
mv
$LOG
$LOG
.
$(
cat
$START_DATE
)
# Split stdout log into smaller chunks
if
test
$(
du
$STDOUT_LOG
|
cut
-f1
)
-ge
$MAX_STDOUT_LOG_KB_SIZE
;
then
stat
$START_DATE
||
date
+
"%Y%m%d.%T"
>
$START_DATE
head
-c
-
$((
$MAX_STDOUT_LOG_KB_SIZE
/
2
))
k
$STDOUT_LOG
>
$STDOUT_LOG
.
$(
cat
$START_DATE
)
tail
-c
$((
$MAX_STDOUT_LOG_KB_SIZE
/
2
))
k
$STDOUT_LOG
>
$STDOUT_LOG
.tmp
mv
$STDOUT_LOG
.tmp
$STDOUT_LOG
fi
# Remove almost empty enb radio archive log files
rm
-f
$(
find
$(
dirname
$LOG
)
-name
"
$(
basename
$LOG
)
.*"
-size
-5k
)
# Limit combined size for archived logs
trim
()
{
stat
$2
*
||
return
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
$MAX_COMBINED_LOG_KB_SIZE
$LOG
.
trim
$MAX_COMBINED_STDOUT_LOG_KB_SIZE
$STDOUT_LOG
.
# Add start date
date
+
"%Y%m%d.%T"
>
$START_DATE
software/simpleran/software.cfg
View file @
9d17f845
...
...
@@ -76,6 +76,9 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_}
[template-obsolete]
<= download-base
[amarisoft-log-rotate-sh]
<= download-base
[copy-config-to-instance]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/config/${:_buildout_section_name_}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment