Make sure downtime_depth is always at least 1 when starting
[nagios-reports-module.git] / dt_verify.php
blobdf7d154ae19a3ca3adbd7f8a350d97dd236300e5
1 <?php
3 if (empty($argv[1]))
4 die("Usage: $argv[0] host1 host2 host3...\n");
7 if (!mysql_connect('localhost', 'monitor', 'monitor'))
8 die("Failed to connect to mysql: " . mysql_error());
9 mysql_select_db('monitor_reports');
11 function dt_verify($host) {
12 echo "\n$host:\n";
13 $query = "SELECT * FROM report_data " .
14 "WHERE host_name = '$host' AND " .
15 "(event_type = 1103 OR event_type = 1104) ORDER BY id";
17 $result = mysql_query($query);
19 if (!$result)
20 die("mysql_query() failed: " . mysql_error());
22 while ($row = mysql_fetch_array($result)) {
23 switch ($row['event_type']) {
24 case 1103:
25 $start = $row['timestamp'];
26 echo " START: ($start) " . date("Y-m-d H:i:s", $start) . "\n";
27 break;
28 case 1104:
29 $stop = $row['timestamp'];
30 $duration = $stop - $start;
31 echo " STOP: ($stop) " . date("Y-m-d H:i:s", $stop) . " duration=$duration\n";
32 break;
33 default:
34 echo "laelaelae\n";
39 for ($i = 1; $i < $argc; $i++) {
40 dt_verify($argv[$i]);