How can I get notified if monitoring database automated backup gets too old?
Q: IPHost creates automated backup file (nms.gbak) for monitoring database. How can I get alerted if it stops updating it?
A: You can check age of backup file by means offered below. However, you should do your own monitoring database backups if possible. Note that automated backup is created only as additional precaution against losing data. If you do not copy that file 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.
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:
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:
Set reasonable polling time (from an hour to 1 day).
Click on State conditions tab and enter criteria to enter Warning or Down state:
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.