Fix for writing to DECS, beautifying output

This commit is contained in:
2026-04-27 12:27:46 -04:00
parent ec5f9be8ee
commit 18011e8865
2 changed files with 42 additions and 33 deletions
+18 -14
View File
@@ -19,21 +19,21 @@ done
loginput() {
echo "$*" >&3;
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
}
logresponse() {
echo "[RESPONSE] $(date '+%H:%M:%S') $*" >> "$log";
echo "[RESPONSE] $(date '+%H:%M:%S') $*" >> "$log";
}
loginfo() {
echo "$*" >&3;
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
}
logwarn() {
echo "$*" >&3;
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
}
logerror() {
@@ -103,18 +103,18 @@ mount_remote () {
mkdir -p /mnt/decs
if mount -t cifs -o user="$netid",sec=krb5i "//decs/decs/support/dban_logs" /mnt/decs
then
if [ ! -w "//decs/decs/support/dban_logs" ]; then
logwarning "Insufficient permissions to write in //decs/decs/support/dban_logs"
if ! mkdir -p /mnt/decs/UNKNWN; then
logerror "Insufficient permissions to write in //decs/decs/support/dban_logs"
exit
else
logdir=/mnt/decs/UNKNWN
cp "$log" "$logdir"/log_UNKNWN_"$start_time".log
cp "$log_x" "$logdir"/log_x_UNKNWN_"$start_time".log
log="$logdir"/log_UNKNWN_"$start_time".log
log_x="$logdir"/log_x_UNKNWN_"$start_time".log
exec 1>>"$log_x" 2>&1
set -x
fi
logdir=/mnt/decs/UNKNWN-"$start_time"
mkdir -p "$logdir"
cp "$log" "$logdir"/log_UNKNWN_"$start_time".log
cp "$log_x" "$logdir"/log_x_UNKNWN_"$start_time".log
log="$logdir"/log_UNKNWN_"$start_time".log
log_x="$logdir"/log_x_UNKNWN_"$start_time".log
exec 1>>"$log_x" 2>&1
set -x
else
logerror "Failed to mount remote DECS drive. Stopping"
exit
@@ -424,12 +424,16 @@ main (){
then
get_netid
mount_remote
loginfo ""
fi
get_devicetype #sets $devicetype to HDD_SATA/SSD_SATA/SSD_NVME
loginfo ""
get_device #sets $device to one of the /dev/xyz devices.
loginfo ""
make_infolog #Logs a bunch of details to a info log file from the system.
loginfo ""
loginfo "Finished gathering logs of $devicetype : $device."