Files Monitor
Control Panel
 
 

[home]

(If you are looking only for information related to setting up automated scanning on a specified schedule, scroll down to the last section of the manual on this page.)

User Manual

First, set up the preferences with the Preferences menu item. Then, use the Initialize Database menu item.

From that point on, files can be monitored for changes with the Compare Files menu item or by using cron to monitor files on a regular schedule (see the last section of the manual on this page).

How It Works

In the Preferences menu item, you specify which directories and individual files to monitor.

The Initialize Database menu item initializes (scans and records) the database. This is the information future scans of the directories and files will be compared with.

Each time Files Monitor scans directories and files on your server, it:

  1. Compares existing files against the data recorded for those same files in the initialization database. When a file doesn't match, the file is noted as an anomaly.

  2. If files are found in a directory that aren't recorded in the initialization database, the files are noted as an anomaly.

  3. If the initialization database has files recorded that are now missing from a directory, the files are noted as an anomaly.

When the scan is done, an email listing the anomalies is sent to the address specified in the Reporting Email section of the Preferences menu item.

If the relevant checkbox is checked at the Changes Log section of the Preferences menu item, the anomalies are also logged.

The Preferences Menu Item

Directories and Files
Specifying directories and individual files for monitoring

The Directories and Files section is used to both specify which directories/files to monitor and to specify which directories/files to omit from the scan. The omit specifications can be used to omit directories containing often-updated files, like logs.

The Preferences page itself has directions. In essence, simply specify the location of directories and files to scan.

Two things to be aware of (with solutions):

  1. Huge files may cause memory issues. During initialization (see the Initialize Database menu item further below), Files Monitor reads entire files and creates a hash signature of their contents. To create a hash signature, the entire file needs to be in memory.

    The largest file size that can be processed depends on the server's resources, especially available memory. Probably most servers can process files several megabytes in size. Some perhaps even over 10 megabytes.

    If Files Monitor stops running in the middle of initializing the database, check your server error logs to see if the reason is an out of memory condition or, as addressed in the next item on the list, a time out condition.

    Solution: Omit the too-large file from the scan. (To omit, specify the file location in the "Directories and files to omit from the scan" text box.)

  2. Important: About using /*

    If there are thousands of subdirectories or files on your server and directory location /* is specified, Files Monitor may time out. If Files Monitor stops running in the middle of initializing the database, check your server error logs to confirm it is a timeout.

    Some hosting companies impose a time limit within which scripts may run. Most PHP configuration files also impose a limit.

    Solution #1:

    Specify only the directories and files that must be monitored. For example, a slash by itself to monitor the files in the document root (if they must be monitored), then specify individual subdirectory locations that must be monitored, like

    /
    /wp/*
    /services/*
    /otherstuff/*

    If needed, subdirectories can be broken down even further, like

    /
    /wp/*
    /services/books/
    /services/consultation/
    /services/training/*
    /otherstuff/*

    If a directory that must be monitored contains a subdirectory that doesn't need to be monitored, the subdirectory can be specified in the "Directories and files to omit from the scan" text box.

    If the /otherstuff/ directory, for example, has a subdirectory "logs" that doesn't need to be monitored, the logs subdirectory can be omitted with this line:

    /otherstuff/logs/

    Solution #2:

    If timeout issues are consistently encountered, install more than one instance of Files Monitor.

    Put each installation in a different subdirectory. Give each installation a different table name prefix (see installation manual) so they don't corrupt each other.

    Each installation, then, monitors its own assigned part of your domain's directories and files.

When the control panel's Initialize Database menu item is clicked, the specified directories and files (except those specifically omitted) will be scanned and the data stored against which to compare later scans.

Changed, New, and Removed Files
Automatically updating database for changed, added, and deleted files

As directories and files are scanned, the software may detect anomalies, things that could indicate something is amiss. Anomalies may be files that were changed, files that were added, or files that were deleted.

When anomalies are encountered, an email may be sent to you (see Reporting Email further below).

In addition, and this is optional, the initialization database can automatically be updated for any changed, added, or deleted files encountered during the scan. Doing so would mean the next scan wouldn't detect those anomalies — unless the files had additional changes since the most recent scan.

Something to consider:

(The Reporting Email contains a one-click link to manually initialize the database. The control panel's Compare Files menu item can also be used.)

If in doubt, don't use automatic database initialization. The checkboxes to do the automatic database initialization can be checked later on, if so desired.

Comparing Method
The two file comparison methods

Files Monitor can compare files by size or by content.

During initialization (see the Initialize Database menu item further below), each file's size is recorded as well as a hash signature of their content. This data is stored in the initialization database.

During scanning, the data in the initialization file is used to determine if the files currently on the server have changed.

Specify whether the comparison shall be by file size or by file content.

Comparing file sizes during a scan is faster because only size needs to be determined. To compare hash signatures, entire files need to be read to compute hash signatures.

Whether compared by size or by content, a difference is considered an anomaly to be reported.

Changes Log
Keeping a log of changes

Check the checkbox to log anomalies encountered during directory and file scans.

The log can be downloaded as a CSV file. The log can also be emptied.

If you download a CSV file of the log entries and end up with over 50,000–100,000 lines, it is prudent to empty the log. A very large changes log may slow down the scans.

Reporting Email
The scan results reporting email

Verify the email address you specify here by noting whether or not you receive the results reporting email. If you receive the email, the address is verified. Otherwise, see below for suggestions about email delivery issues.

Verification needs to be done after the database has been initialized (see the Initialize Database menu item further below). When the database has been initialized, verify you receive email from Files Monitor with these steps:

  1. Check the "Also send an email when no file changes have been encountered ..." checkbox and update the preferences.

  2. Click the Compare Files menu item.

    If you receive the email, then things are working as they should. If no email is received, check your spam/junk folders in case the email was filtered there.

    Email delivery can lag. On a busy server, email sending is typically delayed until the server is less busy.

    If no email is received, try using a different email address at a different ISP. If still no email is received, the hosting company may be blocking email sending from your account. Contact them to see if that is the case and to have the block removed.

  3. (Optional) Uncheck the "Also send an email when no file changes have been encountered ..." checkbox. Uncheck if you want to receive the email only when an anomaly is encountered. Otherwise, leave it checked.

    When a "no changes" email is sent, "(no changes)" is appended to the email subject for easy identification.

    It's recommended that the checkbox be checked to receive email even when no changes are encountered. It's a way to verify the scans are continuing to be done as scheduled.

The Initialize Database Menu Item

To initialize the file comparison database, click the Initialize Database menu item.

Initialization means every specified file and every file in specified directories is scanned and both its file size and it's content hash signature are computed. The computation results are stored in the initialization database to be consulted when comparing files later on.

If initialization requires scanning thousands of files, the script might time out under certain conditions.

Files Monitor is coded to run for 300 seconds (5 minutes) before timing out. However, the hosting company may have instituted a shorter maximum run time. If so, the hosting company's run time setting will prevail. When a hosting company imposes a maximum run time, it generally is 15 seconds or 30 seconds.

If Files Monitor runs for 300 seconds or the hosting company-imposed maximum run time, and then there is either an error message or no message at all below the "Database Initialization" heading, the script probably timed out. See the Preferences menu item section, above, for information about resolving the issue.

If Files Monitor stops running before the maximum run time has elapsed and with either an error message or no message at all below the "Database Initialization" heading, it may be a memory issue because of a too large file. See the Preferences menu item section, above, for information about resolving the issue.

The Compare Files Menu Item

The Compare Files menu item can be used only after monitor preferences have been specified and the database initialized.

When comparing files, Files Monitor scans each file recorded in the initialization index to compare either its current file size or its content. Which comparison is made (size or content) depends on which is specified at the Preferences menu.

Whenever a file size or content change is encountered, an anomaly is noted.

An anomaly is also noted when a file recorded in the initialization index is missing from the server or when a file has been added to directories being monitored.

When one or more anomalies are noted during a file comparisons run, an email is sent to the address provided at the Preferences menu item. See the Preferences menu item for instructions if you do not receive the email.

To automate file comparison on a set schedule, see Comparing Files at Scheduled Intervals, immediately below.

Comparing Files at Scheduled Intervals

The Unix/Linux cron command may be used to set up automated file comparison runs at scheduled intervals. This is the URL of the script to use:

http://localhost:8888/DEV/PHP/FilesMonitor/FilesMonitor_scheduled.php

Some hosting companies make it easy to set up cron to run the URL of a script (URL being the script's absolute http://... URL.) Others don't.

As a WebSite's Secret member, you have Scheduled Hourly URL Launch available as an alternative if your hosting company does not allow URLs when setting up cron.

If you are not a WebSite's Secret member but obtained Files Monitor as a purchase bonus or other promotion from Willmaster.com, see the Willmaster Library article, PHP Scripts and Cron for information and a solution.

[home]

Files Monitor version 2.0
Copyright 2011,2014 Will Bontrager Software LLC