Cool Solutions

Automate deletions of messages within a ZCM Zone


October 17, 2008 9:59 pm





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

Option Explicit

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 "zman md -b " & startDate & " -e " & endDate

WScript.Sleep 15000 'wait 15 seconds to allow zman md to finish

oShell.Run "zman acc"

3 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 53 votes, average: 2.67 out of 5 (3 votes, average: 2.67 out of 5)
You need to be a registered member to rate this post.

Categories: Uncategorized


Disclaimer: This content is not supported by Micro Focus. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.


  1. By:AndyDeck

    Configuration | Event and Messaging | Centralized Message Logging has settings to auto-ack and auto-delete by message age and severity (info, warn, error). True, your method can in theory delete arbitrary date ranges, but you’re using it to delete by age only – so why not use the built-in method?

  2. By:Anonymous

    Sleeping a script should only be used as a very last resort. Instead, the Run method has a built-in optional argument to wait until the program has finished executing before continuing on.

    In your example, you would use:

    oShell.Run “zman asc ” & adminUser & ” -P ” & adminPWD,1,True

    See MSDN at