Saturday, April 19, 2008

Monitor Your Niche Store Server


As promised, I will show you how to monitor your Build A Niche Store server changes. Let me first say that this tutorial is based on you hosting your BANS stores on Hostgator. The script can be cgi script can be modified for any server, but I will cover the installation for Hostgator.

First you will need to create a directory in your top level of your server named "scripts". Not in your public_html directory, but in your root of your server. Next in the directory of scripts create another directory named "custom".

You will next need to download these 2 files. directories.txt and PWSmonitorchanges.txt to your hard drive.

Open up directories.txt and change the word username to whatever your Hostgator username is. Save the file back to your harddrive.

Next open up the file PWSmonitorchanges.txt and look for the 3 entries below:

$sendto_email = 'You ';

$sender_email = 'You ';

$path = "/home/username/scripts/custom";

The first 2 entries are your email address where you want the emails sent when changes are made on your server.

The last entry is the path, change the word username to your Hostgator username.

After these edits have been made save the file back to your harddrive as PWSmonitorchanges.cgi not PWSmonitorchanges.txt

Next you want to upload both of these files
directories.txt and PWSmonitorchanges.cgi to your custom folder which is in the scripts folder you created. Next you want to chmod the PWSmonitorchanges.cgi file to 700. The script and directories.txt should now be installed.

Next you need to create a cron job that will run this script at whatever interval you choose. I suggest every 6 hours. Log into your cPanel of your Hostgator account and click on Cron jobs and then click on Standard. Copy the below string into the command box, but change the word username to your Hostgator username.

/usr/bin/perl /home/username/scripts/custom/PWSmonitorchanges.cgi

underneath that you can select how often to run it. Like I said I would click Every Six Hours, Every Day, Every Weekday, Every Month. When done, click Save Crontab.

That is it, now every time you are anyone or an error happens it will email you any changes to any files made on any sites on your server. It will be normal to see some error logs pop up in the report, but you are looking for any unauthorized file changes or file uploads that YOU did not make. This will also track all of the changes you make as well. I hope I have explained this well enough for you and it should be simple to uninstall should you feel you do not need it.

The script comes courtesy of Premier Website Solutions.

EDIT

One of the blog readers left a great comment I will add here:

Thanks Mike!


The cron job can be set for every 6 hours as stated, or any frequency you want, BUT make sure you also change the variable:
$minutes = 15;
in the script to the same.

If minutes is left at 15 and cron is set to run every 6 hours, it means every 6 hours the script will look for files altered within the last 15 minutes, so it would miss anything altered more than 15 minutes and less than 6 hours ago. Miss pretty much everything. ;-)

Related Posts by Categories



3 comments:

Anonymous said...

The cron job can be set for every 6 hours as stated, or any frequency you want, BUT make sure you also change the variable:
$minutes = 15;
in the script to the same.

If minutes is left at 15 and cron is set to run every 6 hours, it means every 6 hours the script will look for files altered within the last 15 minutes, so it would miss anything altered more than 15 minutes and less than 6 hours ago. Miss pretty much everything. ;-)

Neeznoodle on June 28, 2008 at 5:32 PM said...

Thank you so much for sharing this!

I have a few questions:

- Regarding the PWSmonitorchanges file, should it be saved as PWSmonitorchanges.txt or PWSmonitorchanges.cgi (the extension is what I'm asking about)

- Regarding the files that this script watches, should we add .htaccess to the watched files list? And would we use the period in front of the file name?

Thank you,
Rochelle

soggy on June 28, 2008 at 6:53 PM said...

Rochelle thanks for visiting. Love your work. To answer your question it should be saved as cgi when ready to upload. I have it in .txt form to view and edit changes first. As far as the .htaccess i see no reason why you cant add it. I would start without the . and then make a minor change to an htaccess file and see if it alerts you. if not, try it with the . included. have a great day.

Followers

Twitter Updates

    follow me on Twitter
     

    Build A Niche Store Blog. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted by Bloganol dot com Privacy Policy