mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 00:47:47 +00:00
Added to partition output, swap data, still not with percent of swap used, but that's for another day.
This commit is contained in:
parent
2b7a30b82b
commit
991d65fbee
39
inxi
39
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.4.23
|
||||
#### version: 0.4.24
|
||||
#### Date: November 8 2008
|
||||
########################################################################
|
||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||
|
@ -1218,7 +1218,7 @@ get_hdd_data_basic()
|
|||
get_hard_drive_data_advanced()
|
||||
{
|
||||
local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j=''
|
||||
local sd_ls_by_id=''
|
||||
local sd_ls_by_id='' ls_disk_by_id=''
|
||||
|
||||
## check for all ide type drives, non libata, only do it if hdx is in array
|
||||
if [[ -n $( egrep 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
|
||||
|
@ -1282,6 +1282,8 @@ get_hard_drive_data_advanced()
|
|||
## then we'll loop through that array looking for matches. Note, with identical drives this will fail, sigh..
|
||||
## for future use, that should be tightened up, but for now it's fine.
|
||||
if [[ -n $( egrep 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
|
||||
# first pack the main ls variable so we don't have to keep using ls /dev...
|
||||
ls_disk_by_id="$( ls -l /dev/disk/by-id )"
|
||||
for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
|
||||
do
|
||||
if [[ -n $( egrep '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then
|
||||
|
@ -1296,7 +1298,8 @@ get_hard_drive_data_advanced()
|
|||
# get rid of whitespace for some drive names and ids, and extra data after - in name
|
||||
temp_name=$( tr ' ' '_' <<< ${a_temp_scsi[$j]} | cut -d '-' -f 1 )
|
||||
|
||||
sd_ls_by_id=$( ls -l /dev/disk/by-id | egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" )
|
||||
sd_ls_by_id=$( egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" )
|
||||
# sd_ls_by_id=$( ls -l /dev/disk/by-id | egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" )
|
||||
|
||||
if [[ -n $sd_ls_by_id ]];then
|
||||
a_temp_working[2]=${a_temp_scsi[$j]}
|
||||
|
@ -1323,6 +1326,7 @@ get_hard_drive_data_advanced()
|
|||
done
|
||||
fi
|
||||
done
|
||||
unset ls_disk_by_id # and then let's dump the data we don't need
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -1409,6 +1413,12 @@ get_partition_data()
|
|||
A_PARTITION_DATA=( $( df -h -T | gawk '
|
||||
/\/$|\/boot$|\/var$|\/home$/ {
|
||||
print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1)
|
||||
}' )
|
||||
|
||||
$( swapon -s | gawk '
|
||||
/\dev\/[hs]d[a-z]/ {
|
||||
size = sprintf( "%.2f", $3*1024/1000**3 )
|
||||
print $1 "," size "GB,,,swap"
|
||||
}' ) )
|
||||
IFS="$ORIGINAL_IFS"
|
||||
}
|
||||
|
@ -1706,7 +1716,8 @@ print_gfx_data()
|
|||
print_hard_disk_data()
|
||||
{
|
||||
local hdd_data='' partition_data='' a_partition_working='' hdd_model='' a_hdd_working=''
|
||||
local dev_data='' size_data='' hdd_model_2='' hdd_data_2='' usb_data=''
|
||||
local dev_data='' size_data='' hdd_model_2='' hdd_data_2='' usb_data='' partition_data_2=''
|
||||
local partition_used='' swap=''
|
||||
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_FULL_HDD == 'true' ]];then
|
||||
## note: the output part of this should be in the print hdd data function, not here
|
||||
|
@ -1759,10 +1770,28 @@ print_hard_disk_data()
|
|||
IFS=","
|
||||
a_partition_working=(${A_PARTITION_DATA[i]})
|
||||
IFS="$ORIGINAL_IFS"
|
||||
partition_data="$partition_data ${C1}ID:${C2} ${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]} ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})"
|
||||
if [[ -n ${a_partition_working[2]} ]];then
|
||||
partition_used=" ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})"
|
||||
else
|
||||
partition_used='' # reset partition used to null
|
||||
fi
|
||||
if [[ ${a_partition_working[4]} == 'swap' ]];then
|
||||
swap=" ${C1}swap:${C2}"
|
||||
else
|
||||
swap=''
|
||||
fi
|
||||
if [[ $i < 2 ]];then
|
||||
partition_data="$partition_data ${C1}ID:${C2}$swap ${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used"
|
||||
else
|
||||
partition_data_2="$partition_data_2${C1}ID:${C2}$swap ${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
||||
fi
|
||||
done
|
||||
hdd_data=$( create_print_line " " "${C1}Partition${C2}${partition_data}" )
|
||||
print_screen_output "$hdd_data"
|
||||
if [[ -n $partition_data_2 ]];then
|
||||
hdd_data=$( create_print_line " " "${partition_data_2}" )
|
||||
print_screen_output "$hdd_data"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue