This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Populating custom stats with a script

The daily stats e-mail includes a custom statistics section which contains the values of the statistics scripting variables .VarStats01-.VarStats16.  These variables can only be populated by a Kiwi Syslog Server RunScript.

The current field values can be viewed from the Statistics view window under the Counters tab. The names and initial values of the Statistics fields can be set from the Scripting options (Setup > Scripting).

There are 16 custom statistics fields available. Values from 1 to 9 are zero padded (VarStats01 not VarStats1).

You should be able to modify your existing rule to include a RunScript action that will increment one of these statistic variables to keep count of the number of messages logged. 
ie.

[Existing Rule]
+Filters
- {existing filter criteria}
+Actions
> RunScript "Update_CustomStats.txt" (VBScript, full read/write permission)
- {existing log to file action(s)}

The following is a sample 'Update custom stats' script that will increment the VarStats01 variable each time a message is recieved.

'RunScript "Update_CustomStats.txt"
Function Main()
'Increment VarStats01 counter
Fields.VarStats01 = Fields.VarStats01 + 1
'Indicate script ran successfully
Main="OK"
End Function

If you want to track the number of messages received per day, then you need a second script that will reset the .VarStats01 counter at midnight.
Easiest way to do this would be with a scheduled run-script task - a task which runs a simple script every day at midnight, and resets the .VarStats01 count.

eg.
Schedules > New Schedule
Task Type: Run Script
Task Trigger: On a schedule
Schedule > Run at 00:00 every 1 day.
Run Script Options:  "Reset_CustomStats.txt", VBScript, full read/write

'RunScript "Reset_CustomStats.txt"
Function Main()
Fields.VarStats01 = 0
'Indicate script ran successfully
Main="OK"
End Function

Note:  You will have to be careful about when this task runs.  This is because the daily statistics e-mail is also sent at midnight - so, if the Reset_CustomStats script runs just before the daily_stats e-mail gets sent, then the e-mail will say that zero message were received that day.  It would probably pay to change the Schedule time from 00:00 to something just after the daily_stats email has been sent - say, 00:05.

If this is a problem for you, ie. if having an *exact* daily messages count is imperative then you would be best to send your own custom e-mail report from the "Reset_CustomStats" script, just before the stat is reset - as follows:

'RunScript "Reset_CustomStats.txt"
Function Main()
'Send mail
MailTo = "joe@company.com"
MailFrom = "server@company.com"
MailSubject = "This is the custom daily stats email"
MailMessage = Fields.GetDailyStatistics()
Call Fields.ActionSendEmail(MailTo, MailFrom, MailSubject, MailMessage)
'Reset stats counter(s)
Fields.VarStats01 = 0
'Indicate script ran successfully
Main="OK"
End Function