Hi~ I’d like to ask if there’s any way to export the detailed information of the hard drives in the TR-004, especially the “model” and “serial number,” all at once to a file?
Ideally, I’d like to save it directly as a text file so I don’t have to copy each one manually.
May I ask if the TR-004 is connected to Windows or to a NAS?
It’s on the NAS. The company uses other endpoint management software to centrally manage the disks of related devices. If the hard drives in the TR equipment connected to the NAS can also be easily exported as CSV files, it would be much more convenient to import them into the endpoint software. It would be great if this feature could be supported.
At the moment, there doesn’t seem to be a direct interface available, but if you can operate via SSH, it should be easier. I don’t have a TR-004 on hand, but if it’s convenient for you, you can try the following commands first:
[qnap@NAS ~]$ qcli_storage -d
Enclosure Port Sys_Name Type Size Alias Signature Partitions Model
NAS_HOST 3 /dev/sdd HDD:data 7.28 TB 3.5" SATA HDD 1 -- 5 Seagate ST8000VX010-2ZR188
NAS_HOST 4 /dev/sdc HDD:data 7.28 TB 3.5" SATA HDD 2 -- 5 Seagate ST8000VX010-2ZR188
NAS_HOST 5 /dev/sdb HDD:data 7.28 TB 3.5" SATA HDD 3 -- 5 Seagate ST8000VX010-2ZR188
NAS_HOST 6 /dev/sda HDD:data 7.28 TB 3.5" SATA HDD 4 -- 5 Seagate ST8000VX010-2ZR188
In theory, you should be able to see the hard drives belonging to the TR-004 enclosure.
Then you can see information like this:
sudo hdparm -i /dev/sdX |grep Model
Model=ST8000VX010-2ZR188 , FwRev=CV10 , SerialNo= WPVXXXX4
Replace /dev/sdX with the hard drive from the TR-004.
If you need to organize the data into CSV, you can use bash or python to create a script.
If you don’t need to organize it and just want to make a text file for easy copying, you can do this:
sudo hdparm -i /dev/sdX |grep Model >> /share/Public/hdd.txt
If you need to make it into a script, I would need to see the output from the above commands on a NAS with a TR-004 to figure out how to convert it.
Actually, I managed to borrow a TR-004. After reviewing the output, I organized it into the following script. You need to place this script on your NAS and execute it via the SSH interface. You can also modify it as needed.
Usage
Adding --csv means the output will be in CSV format and will be saved in the same folder.
If you do not add the enc number parameter, all disks on the NAS will be listed.
Copy the following content, save it as hdd_id.sh, and remember to chmod +x before executing.
#!/bin/sh
# Usage:
# ./hdd_id.sh # all enclosures, tab-separated (to stdout)
# ./hdd_id.sh --csv # all enclosures, write to <HOST>-<YYYYMMDD>-DiskList.csv
# ./hdd_id.sh 1 # only enc_id=1, tab-separated
# ./hdd_id.sh --csv 1 # only enc_id=1, write to <HOST>-<YYYYMMDD>-DiskList.csv
# Parse options
CSV=0
if [ "$1" = "--csv" ]; then
CSV=1
shift
fi
# Build enclosure list
if [ -n "$1" ]; then
ENC_LIST="$1"
else
ENC_LIST=$(hal_app --se_enum 2>/dev/null | awk '
/^=/{next}
NF==0{next}
/(^|[[:space:]])enc_id($|[[:space:]])/ { hdr=1; next }
hdr && $1 ~ /^[0-9]+$/ { print $1 }
' | sort -n | uniq)
fi
[ -z "$ENC_LIST" ] && { echo "No enclosure enc_id found."; exit 1; }
# Prepare output file name in CSV mode using uname -n and date
OUTFILE=""
DELIM="\t"
if [ $CSV -eq 1 ]; then
HOSTNAME=$(uname -n 2>/dev/null)
[ -z "$HOSTNAME" ] && HOSTNAME="NAS"
DATESTR=$(date +%Y%m%d)
OUTFILE="${HOSTNAME}-${DATESTR}-DiskList.csv"
DELIM=","
echo "Enclosure,Slot,Brand,Model,Serial" > "$OUTFILE"
fi
for ENC in $ENC_LIST; do
NAME=$(hal_app --se_get_jbod_display_name enc_id=$ENC 2>/dev/null)
[ -z "$NAME" ] && NAME="ENC_${ENC}"
# Enumerate disks for this enclosure and print Brand, Model, Serial per slot
hal_app --pd_enum enc_id=$ENC 2>/dev/null | awk -v name="$NAME" -v D="$DELIM" -v csv="$CSV" -v out="$OUTFILE" '
/^=/{next}
NF==0{next}
# Capture header indexes once
!hdr && /(^|[[:space:]])port_id($|[[:space:]])/ && /vendor/ && /model/ && /serial_no/ {
for(i=1;i<=NF;i++){
if($i=="port_id") pid=i
if($i=="vendor") bid=i # Brand
if($i=="model") mid=i
if($i=="serial_no") sid=i
}
hdr=1; next
}
# Data rows: first field is numeric (port_id)
hdr && $1 ~ /^[0-9]+$/ && pid>0 && bid>0 && mid>0 && sid>0 {
line = name D $(pid) D $(bid) D $(mid) D $(sid)
if (csv==1) {
print line >> out
} else {
print line
}
}
'
done