Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   General IT Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=19)
-   -   Free website monitoring agent? (https://www.cableforum.uk/board/showthread.php?t=33667026)

Xaccers 07-07-2010 20:29

Free website monitoring agent?
 
I used to use sitescope (way before HP got their hands on it) and they released a version which was free for non-commercial use, but it appears to be no more.

Can anyone suggest a free website monitoring agent?
It just needs to check for a specific word and fire off an email if it doesn't find it.

Richard M 09-07-2010 23:13

Re: Free website monitoring agent?
 
Nagios is pretty much the industry standard, but it's a behemoth and you can easily lose a day just configuring it.

But actually, if you can run PHP (on command line) then a script like this will work:

PHP Code:

<?php

$url 
'http://www.example.com/'// This can be a full URL if you like
$word 'hello'// Word to search for

// If we have a URL passed on the command line then use it
if (count($argc) > 1) {
    
$url $argv[1];
}

// Email variables
$mailTo 'your@email.com';
$mailSubject 'Website Monitoring for ' $url;
$mailMessage "Epic fail\n\nThe site is not working properly!";

// Grab the page
$page file_get_contents(urlencode($url));

// Search for the word in the page
if (!stristr($page$word)) {
    if (!
mail($mailTo$mailSubject$mailMessage)) {
        echo 
"Could not send the email, make sure Postfix or Sendmail is installed and running!\n";
        exit(
1);
    }
} else {
   exit(
0); // Do nothing and exit with a Posix success code
}

Save the above as whatever.php and run it like:

Code:

php whatever.php '<URL>'
The URL is optional and defaults to whatever is set inside the script.

You can set this via CRON, Google it or use whatever control panel you have on your webhost if applicable.
If you need a version modified that you can use on a webpage, let me know.

Kymmy 10-07-2010 10:23

Re: Free website monitoring agent?
 
Something missing??

Code:

?>
?????

Xaccers 10-07-2010 21:46

Re: Free website monitoring agent?
 
Quote:

Originally Posted by Richard M (Post 35053590)
Nagios is pretty much the industry standard, but it's a behemoth and you can easily lose a day just configuring it.

But actually, if you can run PHP (on command line) then a script like this will work:
If you need a version modified that you can use on a webpage, let me know.


I'm getting:

PHP Warning: file_get_contents(webaddress): failed to open stream: No such file or directory in monitor.php on line 17

Running this on a W2K3 server.


Line 17 is:
$page = file_get_contents(urlencode($url));

Richard M 10-07-2010 22:14

Re: Free website monitoring agent?
 
Quote:

Originally Posted by Kymmy (Post 35053682)
Something missing??

Code:

?>
?????

No, Zend recommend that you don't use the closing ?> to stop newlines from messing with debugging.

Quote:

For files containing only PHP code, the closing tag must always be omitted (See General standards).
http://framework.zend.com/manual/en/...ing-style.html

---------- Post added at 21:14 ---------- Previous post was at 21:13 ----------

Quote:

Originally Posted by Xaccers (Post 35053874)
I'm getting:

PHP Warning: file_get_contents(webaddress): failed to open stream: No such file or directory in monitor.php on line 17

Running this on a W2K3 server.


Line 17 is:
$page = file_get_contents(urlencode($url));

Your $url must be incorrect.
I haven't tested this code, but it should work with a correct URL.

You're not using "webaddress" (literal) as the URL, right?

Xaccers 10-07-2010 22:22

Re: Free website monitoring agent?
 
No I'm using http://www.frenchcarforum.co.uk/forum/viewforum.php?f=3

Richard M 10-07-2010 22:39

Re: Free website monitoring agent?
 
Ok, going to test it.

EDIT: Actually I can't test atm because I need to use Windows - can you try using this line:

PHP Code:

// Grab the page
$page file_get_contents('http://www.frenchcarforum.co.uk/forum/viewforum.php?f=3'); 


Xaccers 10-07-2010 23:21

Re: Free website monitoring agent?
 
That's done the trick!
Thanks Richard you're a star!


All times are GMT +1. The time now is 01:21.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum