Question
· Aug 8, 2019

Notified about database changes

Just wondering if anyone knows if there is a way to get daily emails or alerts about changes to a cache database.  I know that all of that information is contained within the journal files, just wondering if there is a way to bundle it up each day and send it off for auditing, etc.

Any solution where a plain-text/readable format of changes to the cache database could be sent or stored for review would solve the issue.

 

Thanks!

Discussion (3)0
Log in or sign up to continue

As far as I know, there is no built-in solution for this, but maybe someone else on here has built something.

If you want to build your own solution, the journal files are accessible via API's (See the %SYS.Journal.Record class, as well as %SYS.Journal.File). The Management Portal has a page with a journal 'Profile' that uses some of the methods in the Record class. It is viewable at <IP>:<port>/csp/sys/op/UtilSysJournals.csp -> Profile. That page simply prints the total number of updates to each global within one journal file, but you could easily do much more with the API's and the files (say, loop through all the journals for a specific date and keep track of the final values of each global throughout the day, and write that into a human-readable CSV  or text file).

In namespace %SYS you have the utility  ^JRNDUMP  which displays the content of journal files in "readable" text format.
You may need to adapt it to your requirements.

Journal: c:\intersystems\cache\mgr\journal\20190808.004
   Address   Proc ID Op Directory        Global & Value
===============================================================================
    131088      6600 S  c:\intersystems+ %SYS("SERVICE","ECPCluster") = 0
    131152      6600 S  c:\intersystems+ %SYS("LASTSESSIONGUID") = "5ª"_$c(9)_"+
    131224      6600 BT
    131240      6600 ST c:\intersystems+ %SYS("SERVICE","ECPSessionVersion") = 2
    131316      6600 CT
    131644     10960 S  c:\intersystems+ SYS("LastLicenseKey") = "LicenseCapaci+
    132620      2600 S  c:\intersystems+ SYS("Security","UsersD","unknownuser")     132692     10960 K  c:\intersystems+ SYS("CLMANAGER")
    132740     10960 S  c:\intersystems+ SYS("CLMANAGER") = 1
    132792     10960 S  c:\intersystems+ SYS("CLMANAGER",1) = $c(127,0,0,1,15)_+
    132848     10960 S  c:\intersystems+ SYS("CLMANAGER",1,"started") = 1

Depending on your activities in the DB  this may take many many GB !
I'd suggest examining the content first from Mgmt Portal to see if this is what you expect. 

Hi Robert,

take a look at the %SYS.Journal.File , %SYS.Journal.Record and %SYS.Journal.SetKillRecord classes.

It contains methods & properties to loop through the journalfiles, and get the information of all changes. You could then write this info in a (summarized) file and email it.

ClassMethod ShowJrn(file = "C:\InterSystems\Cache\mgr\journal\20190804.001")
{
  Set jrnforef = ##class(%SYS.Journal.File).%OpenId(file)
  set record = jrnforef.FirstRecordGet()
  While record'="" {
      If record.%ClassName()="SetKillRecord" {
        Write record.Type,! ;6 = SET, 7 = KILL
        Write record.GlobalReference,!
        Write record.OldValue,!
        Write record.NewValue,!
    }
    Set record = jrnforef.GetRecordAt(record.NextAddress)
  }
}