import: Don't enable indexes unless we've disabled them
[nagios-reports-module.git] / dt_verify.php
blob77505242643d9442da58aa49da7e03dbfdfa041a
1 #!/usr/bin/php
2 <?php
4 if (empty($argv[1]))
5 die("Usage: $argv[0] host1 host2 host3...\n");
6 $table = getenv('DB_TABLE');
7 if (!$table)
8 $table = 'report_data';
10 if (!mysql_connect('localhost', 'monitor', 'monitor'))
11 die("Failed to connect to mysql: " . mysql_error());
12 mysql_select_db('monitor_reports');
14 function dt_verify($host, $table) {
15 echo "\n$host:\n";
16 $query = "SELECT * FROM $table " .
17 "WHERE host_name = '$host' AND " .
18 "(event_type = 1103 OR event_type = 1104) ORDER BY id";
20 $result = mysql_query($query);
22 if (!$result)
23 die("mysql_query() failed: " . mysql_error());
25 while ($row = mysql_fetch_array($result)) {
26 switch ($row['event_type']) {
27 case 1103:
28 $start = $row['timestamp'];
29 echo " START: ($start) " . date("Y-m-d H:i:s", $start) . "\n";
30 break;
31 case 1104:
32 $stop = $row['timestamp'];
33 $duration = $stop - $start;
34 echo " STOP: ($stop) " . date("Y-m-d H:i:s", $stop) . " duration=$duration\n";
35 break;
36 default:
37 echo "laelaelae\n";
42 for ($i = 1; $i < $argc; $i++) {
43 dt_verify($argv[$i], $table);