Ti posto una funzione che avevo fatto io che inizializza un array e poi lo scorre.
Codice PHP:
# Show information about partitions (SHOW 0.2rc2)
disk () {
DEV=`df | grep /dev | awk {'print $1'}` # devices presents on df
NUM_DEVICES=`df | grep /dev | wc -l` # number of devices presents on df
HDDTEMP=`which hddtemp` # path of hddtemp binary
#Show partitions
echo -e "---- Mounted Partitions ----"
for d in $DEV;
do
device=( "${device[@]}" $DEV ) # create array with devices presents on df
done
for (( x=0; x<$NUM_DEVICES; x++ ))
do
for i in ${device[$x]};
do
if [ -b "$i" ]; then
echo -e "|_ Partitions: `basename $i`"
echo -e " \\_"
echo -e " |_ Size: `df -h | grep $i | awk {'print $2'}`"
echo -e " |_ Used: `df -h | grep $i | awk {'print $3'}` (`df | grep $i | awk {'print $5'}`)"
echo -e " |_ Available: `df -h | grep $i | awk {'print $4'}`"
echo -e " |_ Mount Point: `df | grep $i | awk {'print $6'}`"
echo -e " |_ Filesystem: `mount | grep $i | awk {'print $5'}`"
echo -e " |_ Options: `mount | grep $i | awk {'print $6'} | sed {s/\(//g} | sed {s/\)//g}`"
if [[ -f $HDDTEMP ]]; then # if hddtemp is installed
SENSOR=`${HDDTEMP} $i | awk {'print $5$6$7'}`
if [ "$SENSOR" = "S.M.A.R.T.notavailable" ]; then
echo -e " |_ Temperature: not available"
else
echo -e " |_ Temperature: `${HDDTEMP} ${device[$x]} | grep /dev | awk {'print $5'}` "
fi;
else
echo -e " |_ Info: install hddtemp for temperature monitoring"
fi;
echo ""
fi;
done
done
}