473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HostWatch * Monitoring

Hi All,

how I can make a simply HostWatch - system which use a mysql DB and send me
an e-Mail if the Server goes off and again on?
I began to programm this last night, but the MySQL inquiry is too hard for
me! =(

Thats my code:

----
<?php
$dbhost = "*****";
$dbuser = "*****";
$dbpass = "*****";
$dbname = "*****";

$db = mysql_connect($dbhost,$dbuser,$dbpass);
$res = mysql_db_query($dbname, "select * from adressen");
$num = mysql_num_rows($res);

for ($i=0; $i<$num; $i++)
{
$ID = mysql_result($res, $i, "ID");
$IP = mysql_result($res, $i, "IP");
$PO = mysql_result($res, $i, "PORT");
/////////////////////////////////////////////////////////////////////
$s = explode(" ",microtime());
$Starttime = $s[1]+$s[0];

// AUSWERTUNG HIER ANFANG PING & PORT KONTROLLE ==> ANFANG <==
$socket = @fsockopen($IP, $PO, &$errno, &$errstr, 2);
// AUSWERTUNG HIER ENDE PING & PORT KONTROLLE ==> ENDE <==

$t = explode( " ", microtime() );
$Endtime= $t[1] + $t[0];
$finalzeit = number_format( $Endtime-$Starttime, 3);
/////////////////////////////////////////////////////////////////////

if ($socket) {
mysql_select_db($dbname);
$query2 = "INSERT INTO monitoring (AID,STATUS,PING) values
('$ID','1','$finalzeit')" or die(mysql_error());
mysql_query($query2);
//$res2 = mysql_db_query($dbname, "select t.* from monitoring t left join
monitoring u on u.AID=t.AID and u.ZEIT>t.ZEIT where t.STATUS=0 and u.ID is
null");
//$num2 = mysql_num_rows($res2);
//if($num2 == 1){
// mail("***","Server wieder ON","Der Server ($ID) geht wieda","FROM:
alert@***.com");
//}else{
}else{
$query3 = "INSERT INTO monitoring (AID,STATUS,PING) values
('$ID','0','$finalzeit')" or die(mysql_error());
mysql_query($query3);

$res3 = mysql_db_query($dbname,".... ????");
$num3 = mysql_num_rows($res3);
if($num3 <= 1){

}else{
mail("****","Server offline","Der Server mit der ID $ID ist
offline","FROM: alert@***.com");
}
}
}
mysql_close($db);

?>
-----
This script is in a cronjob! Every minute the server execute this script.
That is, that I get every Minute an e-Mail Message. If the Server goes for 2
hours off I was received 60 messages.
My aim is to get a message one time for offline and if the server goes
online again one for online.

I hope for your help!

Gretting!
Jul 17 '05 #1
0 1993

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
0
by: Jay Blanchard | last post by:
-----Original Message----- From: Moritz Steiner =20 Sent: Wednesday, July 16, 2003 10:46 AM To: Jay Blanchard Subject: AW: monitoring I want to see: Number of queries =20
4
by: johnm | last post by:
Hello, We currently are running a CRM application that uses DB/2 7.2 for the data repository. We will be upgrading to 8.2 later this year....maybe....time and resources permitting. The...
3
by: JSheble | last post by:
I have a windows service that in the OnStart it creates a thread and runs a loop forever and ever, assuming the service is running. The loop stops during the OnStop event, and everything works...
0
by: Jeff Reed | last post by:
I am experiencing the the problem outlined the below. Unfortunately, I am using WinXP and I not sure if I can apply the solution due to lack of security control Any feed back would be apreciated ...
0
by: Ron Simpson | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
4
by: Bob | last post by:
I've got dot net Winform apps that are running in a backroom server with no user interaction. They are supposed to run unattended 24 7 365. They are IVR apps taking orders via telephony. Problem is...
4
by: natG | last post by:
Well folks, I didn't heed the warnings (that excessive monitoring, statistics, etc. can cause a performance hit) and I have been playing around with all kinds of monitors, snapshots, especially...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.