I collect email stats each day and store them in the database. At the
end of each month I run a report for each domain summarising their daily
mail usage by count and by bandwidth. If this is of use to anyone I have
attached the script that collects the stats. (Can I post attachments?)
hth
Brett
B)
Howie Hamlin wrote:
> All the daily stats are written to standard INI files - all you need is
> a program to read the INI files and calculate the bandwidth.
>
> HTH,
>
> Howie
>
> ----- Original Message -----
> From: Jose Gosende <mailto:[EMAIL PROTECTED]>
> To: inFusion Support List <mailto:[EMAIL PROTECTED]>
> Sent: Wednesday, September 11, 2002 11:10 AM
> Subject: RE: [iMS] Stats
>
> There's no way to get the bandwidth used by iMS over a period of
> time (daily and monthly), is there?
>
> Jose
>
> This list server is Powered by iMS
> "The Swiss Army Knife of Mail Servers"
> ------------------------------------------------------------------------
> To leave this list please complete the form at
> http://www.coolfusion.com/iMSSupport.cfm
> Need an iMS Developer license? Sign up for a free license here:
> http://www.coolfusion.com/iMSDevelopers.cfm
> List archives: http://www.mail-archive.com/infusion-email%40eoscape.com/
> Note: You are subscribed as [EMAIL PROTECTED]
>
==^=======================================================
This list server is Powered by iMS
"The Swiss Army Knife of Mail Servers"
--------------------------------------
To leave this list please complete the form at
http://www.coolfusion.com/iMSSupport.cfm
Need an iMS Developer license? Sign up for a free license here:
http://www.coolfusion.com/iMSDevelopers.cfm
List archives: http://www.mail-archive.com/infusion-email%40eoscape.com/
Note: You are subscribed as [email protected]
==^=======================================================
<!---
Filename: collectEmailStats.cfm
Function: Read the iMS email statistics files. Record the summary volume
information for
each domain. Move the statistics files to the archive
directory.
--->
<cfset statsDir="c:\Utils\iMS\Stats">
<cfset archiveDir="#statsDir#\Archive">
<cfset CountMode="Tallies">
<cfset volumeMode="Bandwidth">
<cfset totalsMode="Totals">
<cfset currentMode="">
<cfif directoryExists(statsDir) and directoryExists(archiveDir)>
<!--- Get the hosted email domains --->
<cfquery name="domainList" datasource="iMS" dbtype="ODBC">
SELECT * FROM domainAliases
</cfquery>
<!--- <cfset lstDomainIds=valueList(domainList.domainId)>
<cfset lstDomainAliases=valueList(domainList.domain)> --->
<cfset Domains=StructNew()>
<cfloop query=domainList>
<cfset thisDomain=structNew()>
<cfset thisDomain.name=domainList.domain>
<cfset thisDomain.id=domainList.domainId>
<cfset thisDomain.postCount=0>
<cfset thisDomain.postVolume=0>
<cfset thisDomain.smtpCount=0>
<cfset thisDomain.postVolume=0>
<CFSET Domains["#domainList.domain#"] = thisDomain>
</cfloop>
<!--- Get the POST statistics files --->
<CFDIRECTORY NAME="postQuery" action="LIST" DIRECTORY="#statsDir#"
filter="POST2*.ctr">
<!--- Extract the statistics from each POST file --->
<cfloop QUERY="postQuery">
<cfif compareNoCase(postQuery.type, "file") eq 0>
<cfloop query=domainList>
<cfif StructKeyExists(Domains, domainList.domain)>
<CFSET
Domains["#domainList.domain#"].postCount = 0>
<CFSET
Domains["#domainList.domain#"].postVolume = 0>
</cfif>
</cfloop>
<!--- Get the date from the file name... --->
<cfset fileName=listfirst(postQuery.Name, ".")>
<cfset fileDate=right(fileName, len(fileName)-4)>
<cfset tranDate=createDate(left(fileDate, 4), Mid(fileDate, 5,
2), right(fileDate, 2))>
<cfoutput>#left(dayOfWeekAsString(DayOfWeek(tranDate)), 3)#
#dateFormat(tranDate, "DD MMM")#</cfoutput><br>
<!--- process POST file... --->
<cfset currentMode="">
<cffile action="READ" file="#statsDir#\#postQuery.Name#"
variable="statsFileContent">
<cfset statsFileContent = replace(statsFileContent,
chr(13),"|","ALL")>
<cfloop index="statRecord" list="#statsFileContent#"
delimiters="|">
<cfset statRecord = trim(statRecord)>
<!--- <cfoutput>#statRecord#</cfoutput><br> --->
<cfif left(statRecord, 1) is "[">
<!--- Set the operational "mode" --->
<cfset currentMode=mid(statRecord, 2,
len(statRecord)-2)>
<!--- Mode:
<cfoutput>#currentMode#</cfoutput><br> --->
<cfelse>
<cfset domainName=trim(listFirst(statRecord,
"="))>
<cfif StructKeyExists(Domains, domainName)>
<!--- <cfoutput>Found #domainName# in
array of structures...</cfoutput><br> --->
<cfif currentMode is CountMode>
<!--- Count...<br> --->
<cfset
domainCount=listLast(statRecord, "=")>
<CFSET
Domains["#domainName#"].postCount = domainCount>
<cfelseif currentMode is volumeMode>
<!--- Volume...<br> --->
<cfset
domainVolume=listLast(statRecord, "=")>
<CFSET
Domains["#domainName#"].postVolume = domainVolume>
</cfif>
</cfif>
</cfif>
</cfloop>
<!--- Put the POST stats into the database --->
<cfloop query=domainList>
<cfif StructKeyExists(Domains, domainList.domain) and
(Domains["#domainList.domain#"].postCount gt 0)>
<cfoutput>#Domains["#domainList.domain#"].name#
#Domains["#domainList.domain#"].postCount#
#Domains["#domainList.domain#"].postVolume#</cfoutput><br>
<cfquery name="deleteMailStatRecord"
datasource="iMS" dbtype="ODBC">
Delete from MailStats
Where domainId=#domainList.domainId#
And domain='#domainList.domain#'
And
TranDate=#CreateODBCDateTime(tranDate)#
</cfquery>
<cfquery name="insertMailStatRecord"
datasource="iMS" dbtype="ODBC">
Insert into MailStats
(domainId, domain,
tranDate, postCount, postVolume)
Values (#domainList.domainId#,
'#domainList.domain#', #CreateODBCDateTime(tranDate)#,
#Domains["#domainList.domain#"].postCount#,
#Domains["#domainList.domain#"].postVolume#)
</cfquery>
</cfif>
</cfloop>
<!--- Now move the file to the archive so we don't process it
again tomorrow --->
<CFFILE ACTION="Move"
SOURCE="#statsDir#\#postQuery.Name#"
DESTINATION="#archiveDir#\#postQuery.Name#">
</cfif>
</cfloop>
<!--- Get the SMTP statistics files --->
<CFDIRECTORY NAME="smtpQuery" action="LIST" DIRECTORY="#statsDir#"
filter="SMTP2*.ctr">
<!--- Extract the statistics from each SMTP file --->
<cfloop QUERY="smtpQuery">
<cfif compareNoCase(smtpQuery.type, "file") eq 0>
<cfloop query=domainList>
<cfif StructKeyExists(Domains, domainList.domain)>
<CFSET
Domains["#domainList.domain#"].smtpCount = 0>
<CFSET
Domains["#domainList.domain#"].smtpVolume = 0>
</cfif>
</cfloop>
<!--- Get the date from the file name... --->
<cfset fileName=listfirst(smtpQuery.Name, ".")>
<cfset fileDate=right(fileName, len(fileName)-4)>
<cfset tranDate=createDate(left(fileDate, 4), Mid(fileDate, 5,
2), right(fileDate, 2))>
<cfoutput>#left(dayOfWeekAsString(DayOfWeek(tranDate)), 3)#
#dateFormat(tranDate, "DD MMM")#</cfoutput><br>
<!--- process SMTP file... --->
<cfset currentMode="">
<cffile action="READ" file="#statsDir#\#smtpQuery.Name#"
variable="statsFileContent">
<cfset statsFileContent = replace(statsFileContent,
chr(13),"|","ALL")>
<cfloop index="statRecord" list="#statsFileContent#"
delimiters="|">
<cfset statRecord = trim(statRecord)>
<!--- <cfoutput>#statRecord#</cfoutput><br> --->
<cfif left(statRecord, 1) is "[">
<!--- Set the operational "mode" --->
<cfset currentMode=mid(statRecord, 2,
len(statRecord)-2)>
<!--- Mode:
<cfoutput>#currentMode#</cfoutput><br> --->
<cfelse>
<cfset domainName=trim(listFirst(statRecord,
"="))>
<cfif StructKeyExists(Domains, domainName)>
<!--- <cfoutput>Found #domainName# in
array of structures...</cfoutput><br> --->
<cfif currentMode is CountMode>
<!--- Count...<br> --->
<cfset
domainCount=listLast(statRecord, "=")>
<CFSET
Domains["#domainName#"].smtpCount = domainCount>
<cfelseif currentMode is volumeMode>
<!--- Volume...<br> --->
<cfset
domainVolume=listLast(statRecord, "=")>
<CFSET
Domains["#domainName#"].smtpVolume = domainVolume>
</cfif>
</cfif>
</cfif>
</cfloop>
<!--- Put the SMTP stats into the database --->
<cfloop query=domainList>
<cfif StructKeyExists(Domains, domainList.domain) and
(Domains["#domainList.domain#"].smtpCount gt 0)>
<cfoutput>#Domains["#domainList.domain#"].name#
#Domains["#domainList.domain#"].smtpCount#
#Domains["#domainList.domain#"].smtpVolume#</cfoutput><br>
<cfquery name="getMailStatRecord"
datasource="iMS" dbtype="ODBC">
Select domainId from MailStats
Where domainId=#domainList.domainId#
And domain='#domainList.domain#'
And
TranDate=#CreateODBCDateTime(tranDate)#
</cfquery>
<cfif getMailStatRecord.recordCount gt 0>
<cfquery name="updateMailStatRecord"
datasource="iMS" dbtype="ODBC">
Update MailStats
Set
smtpCount=#Domains["#domainList.domain#"].smtpCount#,
smtpVolume=#Domains["#domainList.domain#"].smtpVolume#
Where
domainId=#domainList.domainId#
And
domain='#domainList.domain#'
And
TranDate=#CreateODBCDateTime(tranDate)#
</cfquery>
<cfelse>
<cfquery name="insertMailStatRecord"
datasource="iMS" dbtype="ODBC">
Insert into MailStats
(domainId,
domain, tranDate, smtpCount, smtpVolume)
Values
(#domainList.domainId#, '#domainList.domain#', #CreateODBCDateTime(tranDate)#,
#Domains["#domainList.domain#"].smtpCount#,
#Domains["#domainList.domain#"].smtpVolume#)
</cfquery>
</cfif>
</cfif>
</cfloop>
<!--- Now move the file to the archive so we don't process it
again tomorrow --->
<CFFILE ACTION="Move"
SOURCE="#statsDir#\#smtpQuery.Name#"
DESTINATION="#archiveDir#\#smtpQuery.Name#">
</cfif>
</cfloop>
<cfelse>
<!--- TODO: Send a message to tell someone the fax server is down or the drive
mapping has gone... --->
<cfquery datasource="Settlement" dbtype="ODBC">
insert into test (f1)
values ('email statistics directory: #statsDir# or archive directory:
#archiveDir# not found!!!');
</cfquery>
</cfif>
==^=======================================================
This list server is Powered by iMS
"The Swiss Army Knife of Mail Servers"
--------------------------------------
To leave this list please complete the form at
http://www.coolfusion.com/iMSSupport.cfm
Need an iMS Developer license? Sign up for a free license here:
http://www.coolfusion.com/iMSDevelopers.cfm
List archives: http://www.mail-archive.com/infusion-email%40eoscape.com/
Note: You are subscribed as [email protected]
==^=======================================================