Networker

Re: [Networker] reporting volumes on retention

2008-05-18 13:11:54
Subject: Re: [Networker] reporting volumes on retention
From: Tim Mooney <Tim.Mooney AT NDSU DOT EDU>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Sun, 18 May 2008 12:06:31 -0500
In regard to: Re: [Networker] reporting volumes on retention, Frank Swasey...:

On Fri, 16 May 2008 at 11:18am, Tim Mooney wrote:

$ mminfo -ot -q 'client=dogbert.cc.ndsu.nodak.edu' \
        -r 'totalsize(22)' | add-column.awk
# of lines not matching: 0
# of lines matching    : 2568
# of lines total       : 2568
Total of the lines     : 5.73645e+11

Perhaps everyone else knows this, but since I'm more comfortable with perl than awk,

Me too, but I needed it on a box where I didn't have perl, and since it
works for the stuff I've used it for so far I haven't bothered to write
the perl version.


#! /bin/sh

#
# Author: Tim Mooney <enchanter AT users.sourceforge DOT net>
#
# Purpose: Add a column of numbers.
#
#

/usr/bin/awk '

BEGIN {

        # FS, Field Separator, is whitespace.
        FS = " ";
        # RS, Record Separator, is a newline -- each line is a single
        # record.
        RS = "\n";

        total=0;
        good_lines=0;
        bad_lines=0;
}

# Uncomment the next line for some debugging info.
# { print NR , ":", $0 }

/[0-9][0-9]*\.*[0-9]*/ {
        #print NR , ":", $1;
        total = total + $1
        good_lines = good_lines + 1
        next;
}

/.*/ {
        bad_lines = bad_lines + 1;
        next;
}


# End processing: before exiting, spit out our statistics.
END {
        printf("# of lines not matching: %d\n", bad_lines);
        printf("# of lines matching    : %d\n", good_lines);
        printf("# of lines total       : %d\n", bad_lines + good_lines);
        printf("Total of the lines     : %d\n", total);
}
'


Tim
--
Tim Mooney                                        Tim.Mooney AT ndsu DOT edu
Information Technology Services                   (701) 231-1076 (Voice)
Room 242-J6, IACC Building                        (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

To sign off this list, send email to listserv AT listserv.temple DOT edu and type 
"signoff networker" in the body of the email. Please write to networker-request 
AT listserv.temple DOT edu if you have any problems with this list. You can access the 
archives at http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER