|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# === This file is part of ALICE O² === |
| 4 | +# |
| 5 | +# Copyright 2021 CERN and copyright holders of ALICE O². |
| 6 | +# Author: Teo Mrnjavac <teo.mrnjavac@cern.ch> |
| 7 | +# |
| 8 | +# Partially derived from Torus Makefile <https://github.com/coreos/torus> |
| 9 | +# |
| 10 | +# This program is free software: you can redistribute it and/or modify |
| 11 | +# it under the terms of the GNU General Public License as published by |
| 12 | +# the Free Software Foundation, either version 3 of the License, or |
| 13 | +# (at your option) any later version. |
| 14 | +# |
| 15 | +# This program is distributed in the hope that it will be useful, |
| 16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +# GNU General Public License for more details. |
| 19 | +# |
| 20 | +# You should have received a copy of the GNU General Public License |
| 21 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | +# |
| 23 | +# In applying this license CERN does not waive the privileges and |
| 24 | +# immunities granted to it by virtue of its status as an |
| 25 | +# Intergovernmental Organization or submit itself to any jurisdiction. |
| 26 | + |
| 27 | +O2_INFOLOGGER_PATH=/opt/o2-InfoLogger |
| 28 | +export O2_SYSTEM=ECS |
| 29 | +export O2_FACILITY=core/shmcleaner |
| 30 | +export O2_PARTITION=${O2_PARTITION:-} |
| 31 | +export O2_ROLE=${O2_ROLE:-} |
| 32 | + |
| 33 | +ANY_FILES_CLEANED=false |
| 34 | + |
| 35 | +for SHM_FILE in /dev/shm/*; do |
| 36 | + if [ -f $SHM_FILE ] ; then |
| 37 | + SIZE=$(ls -lah $SHM_FILE | awk -F " " {'print $5'}) |
| 38 | + if ! fuser -s $SHM_FILE ; then |
| 39 | + rm -f $SHM_FILE |
| 40 | + echo "freed unused shared memory $SHM_FILE ($SIZE)" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY |
| 41 | + ANY_FILES_CLEANED=true |
| 42 | + else |
| 43 | + echo "could not free shared memory in use $SHM_FILE ($SIZE)" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Warning -o Facility=$O2_FACILITY |
| 44 | + fi |
| 45 | + fi |
| 46 | +done |
| 47 | + |
| 48 | +if [ "$ANY_FILES_CLEANED" = false ] ; then |
| 49 | + echo "no shared memory freed" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY |
| 50 | +fi |
0 commit comments