agent-sizes-mta.awk
Generated on Tue Dec 05 17:39:06 Eastern Standard Time 2006 from agent-sizes-mta.awk
# Program : MTA-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 MTAs
BEGIN { Mebi = 1024*1024
Gibi = Mebi*1024 ;
IGNORECASE = 1 ;
print("Agent,MTA Size (GiB),MTA Files,GiBytes Free,WPGATE Files,WPGATE Size (MiB),MSHOLD Files,MSHOLD Size (MiB),Message Log Files,Message Log 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 ;
}
/\\wpgate/ { folderinfo("wpgate")
}
/\\problem/ { folderinfo("problem")
}
/\\MSHOLD/ { folderinfo("mshold")
}
/\\MSGLOG/ { folderinfo("msglog")
}
/\\MSLOCAL$/ { folderinfo("mslocal") # Match "MSLOCAL" at the end of a line
}
/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["wpgatefiles"], folderdata["wpgatesize"] / Mebi ) | "sort /r" ;
printf("%i,%6.1f,", folderdata["msholdfiles"], folderdata["msholdsize"] / Mebi ) | "sort /r" ;
printf("%i,%6.1f,", folderdata["msglogfiles"], folderdata["msglogsize"] / Mebi ) | "sort /r" ;
printf("%i,%6.1f,", folderdata["problemfiles"], folderdata["problemsize"] / Mebi ) | "sort /r" ;
printf("%i,%6.1f,", folderdata["mslocalfiles"], folderdata["mslocalsize"] / 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["wpgatefiles"], foldertotal["wpgatesize"] / Mebi )
printf("%i,%6.1f,", foldertotal["msholdfiles"], foldertotal["msholdsize"] / Mebi )
printf("%i,%6.1f,", foldertotal["msglogfiles"], foldertotal["msglogsize"] / Mebi )
printf("%i,%6.1f,", foldertotal["problemfiles"], foldertotal["problemsize"] / Mebi )
printf("%i,%6.1f,", foldertotal["mslocalfiles"], foldertotal["mslocalsize"] / Mebi )
printf("Totals\n")
}
# EOF: MTA-SIZES.AWK
1 files processed.