Scheduled deletions of Zone Messages
As your zone grows with more devices so will the volume of messages reported back from the device agent to the zone. Those messages can be critical, warning or info level. Depending on the amount of devices and activity from those devices many hundreds of messages can be produced per day. All those messages are stored in the Zone database permanently, or at least , until they are deleted. You are able to delete messages in the Zone using the ZCC; but this is a manual process and cannot be automated.
Currently I am working with Windows Primary Servers and have written a vbscript that can run via the Windows Scheduler Service, let’s say on the 1st of each month, to delete messages older than 90 days from the Zone.
The script relies on the zman md ( message-delete ) command. Just like its ZCC counterpart it will take a start date and end date argument.
zman md -b 2000-1-1 -e 2008-7-1
Here we will delete messages from 1 Jan 2000 to 1 July 2008. We don’t want to hard code the end date so this is where vbscript comes in to manipulate the current date. My script sets the end date to 90 days prior to today, or, will delete messages 90 days or older – which I would suggest to be reasonable. The code body is shown below. Save the code in notepad to a file with a .vbs extention.
Add your zone administrator name and password. The script needs to be run from the primary server so it can be protected in the filesystem and via physical security. For additional security you can encode the script to produce a .vbe file ( be aware the encoded files only offer limited security ) or create an executable using Visual Basic or similar program.
Code body below:
'delete messages from zcm older than 90 days
'start date hard coded at 1 Jan 2000
'end date 90 days prior to current Date
' so message 90 days and older will be deleted from ZONE
'wscript echo line is for testing uncomment the line and comment the oShell line
' the oShell lines runs the zman commands
Dim DateRaw,startDate,endDate,oShell, adminUser, adminPWD
Set oShell = CreateObject("WScript.Shell")
DateRaw = Dateadd("d",-90,Date())
endDate = Year(DateRaw) & "-" & Month(DateRaw) & "-" & Day(DateRaw)
startDate = "2000-01-01"
'WScript.Echo "zman md -b " & startDate & " -e " & endDate
oShell.Run "zman asc " & adminUser & " -P " & adminPWD
WScript.Sleep 15000 ' wait 15 seconds to allow zman asc to finish
oShell.run "zman md -b " & startDate & " -e " & endDate
WScript.Sleep 15000 'wait 15 seconds to allow zman md to finish
oShell.Run "zman acc"