Code Files

agent-sizes-gate.awk

Generated on Tue Dec 05 17:39:06 Eastern Standard Time 2006 from agent-sizes-gate.awk


# Program	: GATE-SIZES.AWK
# Purpose	: Extract space information from directory listing
# Author	: Bob Jonkman <bjonkman@sobac.com>

# Copyright 2008 Bob Jonkman and/or SOBAC Microcomputer Services

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Date		: 24 June 2005

# Note      : Patterns have been selected for GroupWise Gateways

BEGIN   {   Mebi = 1024*1024
            Gibi = Mebi*1024 ;
            IGNORECASE = 1 ;

		    print("Agent,Gateway Size (GiB),Gateway Files,GiBytes Free,GWPROB Files,GWPROB Size (MiB),PROBLEM Files,PROBLEM Size (MiB),Log Files,Log Size (MiB),Agent Folder") ;
        }

function folderinfo(folder,   geterr) {
                    while ($0 !~ "File\\(s") 
                    {   geterr = getline 
                        if ((geterr == 0) || (geterr == -1))
                            return(ERRNO) ;
                    }
                    folderdata[folder "files"] += $1 ;
                    folderdata[folder "size"]  += $3 ;
                    return("OK") ;
}

            


(FNR==1)		{	agent = $NF ;

                    delete folderdata ;

                    while ($0 !~ "Directory of")
                    {
                        getline ;
                    }

                    link = $3 ;
}

/\\gwprob/      {   folderinfo("gwprob")
}

/\\problem/     {   folderinfo("problem")
}

/\\000.prc$/    {   folderinfo("000.prc")
}


/Total Files Listed/    {   getline ;
                            Agentfiles = $1 ;
                            Agentsize  = $3/Gibi ;
                            getline ;
                            Volfree  = $3/Gibi ;
                            
                            printf("%s," , agent) | "sort /r" ;
                            printf("%6.1f,%i,%6.1f,", Agentsize, Agentfiles, Volfree)                          | "sort /r" ;
                            printf("%i,%6.1f,", folderdata["gwprobfiles"],  folderdata["gwprobsize"]  / Mebi ) | "sort /r" ;
                            printf("%i,%6.1f,", folderdata["problemfiles"], folderdata["problemsize"] / Mebi ) | "sort /r" ;
                            printf("%i,%6.1f,", folderdata["000.prcfiles"], folderdata["000.prcsize"] / Mebi ) | "sort /r" ;
                            printf("%s\n" ,link) | "sort /r" ;

                            for (i in folderdata)
                                foldertotal[i] += folderdata[i]

                            Agentfilestotal += Agentfiles ;
                            Agentsizetotal  += Agentsize ;
                            Agentcount++ ;
}   

END                     {   print("=====")
                            printf("%i,", Agentcount)  ;
                            printf("%6.1f,%i,,", Agentsizetotal, Agentfilestotal)                                           
                            printf("%i,%6.1f,", foldertotal["gwprobfiles"],  foldertotal["gwprobsize"]  / Mebi )  
                            printf("%i,%6.1f,", foldertotal["problemfiles"], foldertotal["problemsize"] / Mebi )  
                            printf("%i,%6.1f,", foldertotal["000.prcfiles"], foldertotal["000.prcsize"] / Mebi )  
                            printf("Totals\n")  ;
                
}



# EOF: GATE-SIZES.AWK
   

1 files processed.