BB Unix Network Monitor - Message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

{bb} autoaligning DF status page




Some of the output for the DF command on some systems is rather hideous - HP-UX
in particular.... attached is some code that you can insert into your
bb-local.sh to help align the columns so the resulting web status page will be a
little easier to read. The header line being placed at the top of the page (in
the END block) is assuming that the standard header is being consumed previous
to the AWK operation. The header line is being aligned per the data content.
This additional filter works with  BB 1.3A and older versions.

line_up_df()
{
    ${AWK} '
        BEGIN { D = 0; T = 0 ; U = 0 ; F = 0 }
        {
            AD[NR] = $1 ; LD = length($1) ; if ( D < LD ) D = LD
            AT[NR] = $2 ; LT = length($2) ; if ( T < LT ) T = LT
            AU[NR] = $3 ; LU = length($3) ; if ( U < LU ) U = LU
            AF[NR] = $4 ; LF = length($4) ; if ( F < LF ) F = LF
            AP[NR] = $5 
            AM[NR] = $6 
        }
        END {
            # if you want a header on the table, labels aligned to data format
            printf("%-" D "s %" T "s %" U "s %" F "s %5s %s\n", \
                "Filesystem", "kbytes", "used", "avail", "%used", "Mounted")
            for ( r = 1; r <= NR ; r++ ) {
                printf("%-" D "s %" T "s %" U "s %" F "s %5s %s\n", \
                    AD[r], AT[r], AU[r], AF[r], AP[r], AM[r])
            }
        }' 
}

# replace the DFCMD line with modified version envoking function as part of the
pipeline 
#eval "$DFCMD | $EGREP \"$DFUSE\" | $EGREP -v \"$DFEXCLUDE\" | $SORT
\"+${DFSORT}\" > $BBTMP/DFOUT"

eval "$DFCMD | $EGREP \"$DFUSE\" | $EGREP -v \"$DFEXCLUDE\" | \
    $SORT \"+${DFSORT}\"  -r | line_up_df > $BBTMP/DFOUT"

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list, or to subscribe to the bb-digest list
send e-mail to mailto:majordomo@bb4.com with unsubscribe bb -and/or-
subscribe bb-digest in the BODY of the message.


Home | Main Index | Thread Index