Hi,
I've written a perl script which is populating a MySQL database with the down times of Win32 server services.
The script is timed, and logs the hostname and the service name if a service is set to automatic and not running.
The perl script uses a TIMESTAMP field to record the time along with the two text fields.
The database is SERVICELOG, the table is SERVICESLOG
The fields are HOSTNAME(varchar 30), SERVICE(varchar 200) & DATE (timestamp 14)
I've hacked together a php script to list the database (code below) and it seems to filter the records if you supply a hostname or service name
What I'm struggling with is a way of displaying a list of down times between 2 dates. Any ideas ?
Maybe I'm logging the dates incorrectly ? - its no biggie to log them diffrently.
Thanks in advance
Jay
</body>
</html>
<html>
<body>
<form action=searchform.php method=GET>
Search For:
<p>
Hostame: <input type=text name=hostname size=25 maxlength=25>
<p>
Service Name: <input type=text name=service size=25 maxlength=25>
<br>
Between Date 1: <input type=text name=date1 size=25 maxlength=25>
<br>
Between Date 1: <input type=text name=date2 size=25 maxlength=25>
<p>
<input type=submit>
</form>
</body>
</html>
<?php
mysql_connect (localhost, services);
mysql_select_db (servicelog);
if ($hostname == "")
{$hostname = '%';}
if ($service == "")
{$service = '%';}
$result = mysql_query ("SELECT * FROM serviceslog
WHERE hostname LIKE '$hostname%'
AND service LIKE '$service%'
");
if ($row = mysql_fetch_array($result)) {
do {
print $row["hostname"];
print (" ");
print $row["service"];
print (" ");
print $row["date"];
print ("<br>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
?>