Update logging and README for other project usage
Updates:
* [rocm-smi] Logging now can update files on
per-project-basis for install/remove
* [rocm-smi] README now has latest build
instructions, including test builds
* [rocm-smi] Updated README to include
revision dates
Change-Id: Ifb19a6f32ccf6938f47225db53fef88021909264
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
Этот коммит содержится в:
@@ -15,3 +15,6 @@ build/
|
||||
|
||||
# CMake cache
|
||||
.cache/
|
||||
|
||||
# Simulated SYSFS - for early development or debug
|
||||
device/
|
||||
+24
-19
@@ -1,32 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
do_addLogFolder() {
|
||||
sudo mkdir -p /var/log/rocm_smi_lib
|
||||
sudo touch /var/log/rocm_smi_lib/ROCm-SMI-lib.log
|
||||
sudo chmod -R a+rw /var/log/rocm_smi_lib
|
||||
sudo chmod a+rw /var/log/rocm_smi_lib/ROCm-SMI-lib.log
|
||||
sudo mkdir -p "${logPath}"
|
||||
sudo touch "${logFile}"
|
||||
sudo chmod -R a+rw "${logPath}"
|
||||
sudo chmod a+rw "${logFile}"
|
||||
}
|
||||
|
||||
do_configureLogrotate() {
|
||||
logrotate --version &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Detected logrotate is not installed."\
|
||||
"ROCm-smi logs (when turned on) will not rotate properly."
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/logrotate.d/rocm_smi.conf ]; then
|
||||
sudo touch /etc/logrotate.d/rocm_smi.conf
|
||||
sudo chmod 644 /etc/logrotate.d/rocm_smi.conf # root r/w, all others read
|
||||
if [ ! -f $logrotateConfFile ]; then
|
||||
sudo touch "${logrotateConfFile}"
|
||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
# ROCm SMI logging rotation, rotates files using root user/group
|
||||
# Hourly logrotation check
|
||||
# Only rotates if size grew larger than 1MB
|
||||
# Max of 4 rotation files, oldest will be removed
|
||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||
cat <<'EOF' | sudo tee /etc/logrotate.d/rocm_smi.conf >/dev/null
|
||||
/var/log/rocm_smi_lib/ROCm-SMI-lib.log {
|
||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
||||
${logFile} {
|
||||
su root root
|
||||
hourly
|
||||
missingok
|
||||
@@ -42,12 +47,12 @@ EOF
|
||||
# issue was RPM build thought we were using macros
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||
sudo sed -i s/%%/%/g /etc/logrotate.d/rocm_smi.conf
|
||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
# workaround: remove extra 'OURCE' text
|
||||
# from rocm_smi.conf. Unsure if CMAKE,
|
||||
# bash, or here document
|
||||
# issue (only seen on RHEL 8.7)
|
||||
sudo sed -i s/OURCE//g /etc/logrotate.d/rocm_smi.conf
|
||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
fi
|
||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||
@@ -60,16 +65,16 @@ EOF
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
else
|
||||
echo "[WARNING] Could find and configure hourly cron for ROCm-smi's"\
|
||||
" logrotate. ROCm-smi logs (when turned on) will not rotate properly."
|
||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
||||
return
|
||||
fi
|
||||
else
|
||||
# confirm that it's already been moved to hourly
|
||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not configure an hourly cron for ROCm-smi's logrotate."\
|
||||
"ROCm-smi logs (when turned on) may not rotate properly."
|
||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) may not rotate properly."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@@ -94,8 +99,8 @@ WantedBy=timers.target
|
||||
EOF
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
else
|
||||
echo "[WARNING] Could not configure systemd timer for ROCm's logrotate."\
|
||||
"ROCm-smi logs (when turned on) will not rotate properly."
|
||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,14 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
rm_logFolder() {
|
||||
sudo rm -rf /var/log/rocm_smi_lib
|
||||
sudo rm -rf "$logPath"
|
||||
}
|
||||
|
||||
return_logrotateToOrigConfig() {
|
||||
if [ -f /etc/logrotate.d/rocm_smi.conf ]; then
|
||||
sudo rm -rf /etc/logrotate.d/rocm_smi.conf
|
||||
if [ -f $logrotateConfFile ]; then
|
||||
sudo rm -rf "${logrotateConfFile}"
|
||||
fi
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
@@ -33,6 +38,7 @@ rm_pyc() {
|
||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
( remove | upgrade)
|
||||
rm_ldconfig
|
||||
|
||||
+7
-8
@@ -8,7 +8,7 @@ The ROCm System Management Interface Library, or ROCm SMI library, is part of th
|
||||
|
||||
The information contained herein is for informational purposes only, and is subject to change without notice. In addition, any stated support is planned and is also subject to change. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein.
|
||||
|
||||
© 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
© 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
|
||||
# Building ROCm SMI
|
||||
@@ -28,8 +28,8 @@ After the ROCm SMI library git repository has been cloned to a local Linux machi
|
||||
```shell
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake <location of root of ROCm SMI library CMakeLists.txt>
|
||||
make
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
# Install library file and header; default location is /opt/rocm
|
||||
$ make install
|
||||
```
|
||||
@@ -57,11 +57,10 @@ In order to verify the build and capability of ROCm SMI on your system and to se
|
||||
|
||||
```shell
|
||||
# Set environment variables used in CMakeLists.txt file
|
||||
ROCM_DIR=<parent dir. to lib/ and inc/, containing RSMI library and header>
|
||||
mkdir <location for test build>
|
||||
cd <location for test build>
|
||||
cmake -DROCM_DIR=$ROCM_DIR <ROCm SMI source root>/tests/rocm_smi_test
|
||||
make
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_TESTS=ON ..
|
||||
make -j $(nproc)
|
||||
```
|
||||
|
||||
To run the test, execute the program `rsmitst` that is built from the steps above.
|
||||
|
||||
+32
-18
@@ -1,31 +1,37 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
do_addLogFolder() {
|
||||
sudo mkdir -p /var/log/rocm_smi_lib
|
||||
sudo touch /var/log/rocm_smi_lib/ROCm-SMI-lib.log
|
||||
sudo chmod -R a+rw /var/log/rocm_smi_lib
|
||||
sudo chmod a+rw /var/log/rocm_smi_lib/ROCm-SMI-lib.log
|
||||
sudo mkdir -p "${logPath}"
|
||||
sudo touch "${logFile}"
|
||||
sudo chmod -R a+rw "${logPath}"
|
||||
sudo chmod a+rw "${logFile}"
|
||||
}
|
||||
|
||||
do_configureLogrotate() {
|
||||
logrotate --version &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Detected logrotate is not installed."\
|
||||
"ROCm-smi logs (when turned on) will not rotate properly."
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/logrotate.d/rocm_smi.conf ]; then
|
||||
sudo touch /etc/logrotate.d/rocm_smi.conf
|
||||
sudo chmod 644 /etc/logrotate.d/rocm_smi.conf # root r/w, all others read
|
||||
if [ ! -f $logrotateConfFile ]; then
|
||||
sudo touch "${logrotateConfFile}"
|
||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
# ROCm SMI logging rotation, rotates files using root user/group
|
||||
# Hourly logrotation check
|
||||
# Only rotates if size grew larger than 1MB
|
||||
# Max of 4 rotation files, oldest will be removed
|
||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||
cat <<'EOF' | sudo tee /etc/logrotate.d/rocm_smi.conf >/dev/null
|
||||
/var/log/rocm_smi_lib/ROCm-SMI-lib.log {
|
||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
||||
${logFile} {
|
||||
su root root
|
||||
hourly
|
||||
missingok
|
||||
@@ -41,12 +47,12 @@ EOF
|
||||
# issue was RPM build thought we were using macros
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||
sudo sed -i s/%%/%/g /etc/logrotate.d/rocm_smi.conf
|
||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
# workaround: remove extra 'OURCE' text
|
||||
# from rocm_smi.conf. Unsure if CMAKE,
|
||||
# bash, or here document
|
||||
# issue (only seen on RHEL 8.7)
|
||||
sudo sed -i s/OURCE//g /etc/logrotate.d/rocm_smi.conf
|
||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
fi
|
||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||
@@ -59,16 +65,16 @@ EOF
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
else
|
||||
echo "[WARNING] Could find and configure hourly cron for ROCm-smi's"\
|
||||
" logrotate. ROCm-smi logs (when turned on) will not rotate properly."
|
||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
||||
return
|
||||
fi
|
||||
else
|
||||
# confirm that it's already been moved to hourly
|
||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not configure an hourly cron for ROCm-smi's logrotate."\
|
||||
"ROCm-smi logs (when turned on) may not rotate properly."
|
||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) may not rotate properly."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@@ -93,12 +99,20 @@ WantedBy=timers.target
|
||||
EOF
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
else
|
||||
echo "[WARNING] Could not configure systemd timer for ROCm's logrotate."\
|
||||
"ROCm-smi logs (when turned on) will not rotate properly."
|
||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_ldconfig() {
|
||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||
echo @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
||||
ldconfig
|
||||
fi
|
||||
}
|
||||
|
||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||
echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
||||
|
||||
+9
-3
@@ -1,13 +1,19 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
rm_logFolder() {
|
||||
sudo rm -rf /var/log/rocm_smi_lib
|
||||
sudo rm -rf "$logPath"
|
||||
}
|
||||
|
||||
return_logrotateToOrigConfig() {
|
||||
if [ -f /etc/logrotate.d/rocm_smi.conf ]; then
|
||||
sudo rm -rf /etc/logrotate.d/rocm_smi.conf
|
||||
if [ -f $logrotateConfFile ]; then
|
||||
sudo rm -rf "${logrotateConfFile}"
|
||||
fi
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
|
||||
Ссылка в новой задаче
Block a user