How I may be sure monitoring database gets backed up?

How can I get notified if monitoring database automated backup gets too old?

Q: IPHost creates automated backup file (such as nms.gbak) for monitoring database. How can I get alerted if it stops updating it?

A: You can check backup file(s) age by means offered below. However, you should also do your own monitoring database backups if possible. Note that automated backup is created only as additional precaution against losing data and saves backups to the same database directory. If you do not copy backup file(s) elsewhere on regular basis, and do not keep several copies of it, there are chances you lose the entire monitoring database if a hardware failure happens to computer running IPHost Network Monitor.

Configure script (IPHost v5.0 build 11530 or newer)

Please download check-db-backup-age.zip script archive; unpack check-db-backup-age.txt from it, rename to check-db-backup-age.vbs and place into a directory of your choice (in the instructions below we assume it’s unpacked into C:\Scripts folder). The directory must be readable by account used by monitoring service (SYSTEM, by default).

Create “Script or Program” monitor and set its parameters like below:

DB backup age checking script

“Arguments” field should contain full path name of the folder where IPHost creates its backups. If the path contains white space, wrap it in double quotes. By default, it’s the same folder used to keep DB file, i.e. “C:\ProgramData\IPHost Network Monitor\data”. Note: it’s extremely unsafe to store DB backups in the default folder, you are advised to choose a different folder, preferably on another disk (otherwise, if disk C: drive fails, you risk losing both DB and its backups).

The script returns the age of most recent backup file in seconds. If this value is above 86400 (more than a day ago), you should check whether your monitoring service is healthy.

Configure script (IPHost versions prior to v5.0 build 11530)

IMPORTANT: starting from version v5.0 build 11530, IPHost contains built-in database maintenance tools. Using older versions is not recommended (for security and stability reasons), the instructions below are kept for archive reasons.

You can use simple VBScript below to check relative age of monitoring database backup. Select its text below, copy and paste into simple text editor such as Notepad. Alternately, download dtstamp_diff.zip script archive and unpack it to a directory of your choice.

dbName = "C:\ProgramData\IPHost Network Monitor\data\nms.fdb"
bkName = "C:\ProgramData\IPHost Network Monitor\data\nms.gbak"

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(dbName) Then
    dbModified = objFSO.GetFile(dbName).DateLastModified
Else
    Wscript.Echo "Database file not found"
    Wscript.Quit 1
End If

If objFSO.FileExists(bkName) Then
    bkModified = objFSO.GetFile(bkName).DateLastModified
Else
    Wscript.Echo "Database backup file not found"
    Wscript.Quit 2
End If

Wscript.Echo DateDiff("s", bkModified, dbModified)
Wscript.Quit 0

The example below assumes the script has been unpacked to C:\Scripts (use any directory of your choice and adjust monitor settings appropriately).

You might need to adjust paths to database and its backup, in case you have relocated it from default locations, or if you are using Windows XP or Windows Server 2003 family OS. Pay attention to following lines:

Line 1,2

dbName = "C:\ProgramData\IPHost Network Monitor\data\nms.fdb"
bkName = "C:\ProgramData\IPHost Network Monitor\data\nms.gbak"

Both monitoring database (nms.fdb) and its automated backup (nms.gbak) are located in the same directory (folder).

To test the script, open cmd.exe window and run command like this:

cscript //nologo C:\Scripts\dtstamp_diff.vbs

(use actual script location if different from C:\Scripts). If everything is fine, an integer number (difference of file ages in seconds) is printed. Normally, the number should be positive (since monitoring database is often updated as monitoring goes on).

Create monitor to watch backup age

After the script has been tested, create Script or Program monitor as specified below. At step 3, enter Main parameters similar to these:

Check monitoring DB backup age - main

Set reasonable polling time (from an hour to 1 day).

Click on State conditions tab and enter criteria to enter Warning or Down state:

Check monitoring DB backup age - state conditions

In the sample above, if database backup is more than 1 day (86400 seconds) older than monitoring database, Warning state is entered. If it’s older than 2 days, Down condition is entered.

Change actual state condition parameters as you like. Note that when monitoring service is running, backup copy is updated at approx. 4am every day.

Related topics