The sysinfo script in Konvesation in Feisty does not display the diskspace anymore

Bug #108497 reported by hyper_ch
6
Affects Status Importance Assigned to Milestone
konversation (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The sysinfo script in Konversation (running it within Konvi with /sysinfo) does not show the the diskspace (used and total) anymore.

The script, located at /usr/share/apps/konversation/scripts/sysinfo can be fixed with various ways:

(1) install gawk

or better

(2)

Changing the part from:

HDD=$(df -l| awk '($1~/dev/){
  use+=$3/1024**2;
  tot+=$2/1024**2;
 }
 END{print "HD: " int(use) "/" int(tot) "GB"}')

to

HDD=$(df -l| awk '($1~/dev/){
  use+=$3/1024^2;
  tot+=$2/1024^2;
 }
 END{print "HD: " int(use) "/" int(tot) "GB"}')

The upstream of konversation has already applied the second option by using POSIX power of '^' instead of "**".

Revision history for this message
Sarah Kowalik (hobbsee-deactivatedaccount) wrote :

marking as fix committed, as it appears to have been fixed upstream

Changed in konversation:
status: Unconfirmed → Fix Committed
Revision history for this message
Lydia Pintscher (lydia-pintscher) wrote :

Marking as fix released as it shows it again in hardy for me.

Changed in konversation:
status: Fix Committed → Fix Released
Revision history for this message
gnomon (bzanin) wrote :

There are actually two problems this awk script: one is the obvious problem of using the gawk-specific '**' to perform exponentiation rather than the awk standard '^', and the other is an assumption that every line of df output corresponds to a single record. Unfortunately this is not the case: when device names are very line, df will helpfully break records across multiple lines, like so:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/sda4_crypt
                     450180024 395426136 32066144 93% /
varrun 517168 192 516976 1% /var/run
varlock 517168 0 517168 0% /var/lock
udev 517168 96 517072 1% /dev
devshm 517168 0 517168 0% /dev/shm
lrm 517168 38176 478992 8% /lib/modules/2.6.24-17-generic/volatile
/dev/sdc2 972180 54892 868292 6% /boot
/dev/mapper/sdb1_crypt
                     307663284 218735800 73299080 75% /media/sdb1
/dev/mapper/sdc1_crypt
                     153834336 49176656 96843292 34% /media/sdc1
/dev/mapper/sdd1_crypt
                     484534988 269085988 191029828 59% /media/sdd1

In this case, we need slightly more sophisticated processing:

HDD=$(df -l | awk 'BEGIN {
 # In the output of df -l, the first field is the device name...
 TOT = 2 # ...the second field is the total size...
 USE = 3 # ...and the third field is the amount used.
 BLK = 1024^2
 # It is a small thing, but why recalculate the value of a block
 # on every line rather than just doing it once? Keeping this
 # definition up front makes it easier to modify in the future,
 # too: the script currently assumes 1-kilobyte blocks, but
 # that need not always be the case.
}
($1 ~ /^\/dev\// && NF == 1) {
# we handle the case of lines produced by df which feature only
# the device name, which is too long to fit into its column display,
# by grabbing the device name, forcing a new line to be read,
# then prepending the saved device name onto the new line.
# Then every line that we care about is in the same format. The
# next rule will then work in all cases.
 dev = $1
 getline
 $0 = dev " " $0
}
($1 ~ /^\/dev\//) {
 use += $USE / BLK
 tot += $TOT / BLK
}
END {
 printf "HD: %s / %s GB\n", use, tot
}')

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.