aboutsummaryrefslogtreecommitdiffstats
path: root/csv.php
diff options
context:
space:
mode:
authorMatt Rude <[email protected]>2011-06-26 03:47:58 -0500
committerMatt Rude <[email protected]>2011-06-26 03:47:58 -0500
commit61a6fa20f59f4befd7b1d6f426084e41eaa3c5bf (patch)
tree0283d23cd37d04e54b5cd3307c132298007134a8 /csv.php
parent611bee7dfb28ce68044ba062fa3e012ba1b19829 (diff)
downloadtime.mattrude.com-61a6fa20f59f4befd7b1d6f426084e41eaa3c5bf.tar.gz
time.mattrude.com-61a6fa20f59f4befd7b1d6f426084e41eaa3c5bf.tar.bz2
time.mattrude.com-61a6fa20f59f4befd7b1d6f426084e41eaa3c5bf.zip
rewrite for cgi config
Diffstat (limited to 'csv.php')
-rw-r--r--csv.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/csv.php b/csv.php
new file mode 100644
index 0000000..0b75627
--- /dev/null
+++ b/csv.php
@@ -0,0 +1,32 @@
+<?php
+
+if (!isset($_REQUEST['host']))
+ {
+ $_REQUEST['host'] = '%';
+ }
+$host = $_REQUEST['host'];
+
+try{
+$dbHandle = new PDO("sqlite:rrd/ntpstatus.sqlite");
+}catch( PDOException $exception ){
+ echo "Can NOT connect to sqlite3 database ntpstatus.sqlite";
+ die($exception->getMessage());
+}
+
+$sqlShowLog = "SELECT * FROM status WHERE host LIKE '${host}';";
+$result = $dbHandle->query($sqlShowLog);
+echo nl2br("date,host,offset,freq,sjit,cjit,wander,disp,jitter\n");
+while ($entry = $result->fetch()) {
+ $date = $entry['date'];
+ $host = $entry['host'];
+ $offset = $entry['offset'];
+ $freq = $entry['freq'];
+ $sjit = $entry['sjit'];
+ $cjit = $entry['cjit'];
+ $wander = $entry['wander'];
+ $disp = $entry['disp'];
+ $output = "$date, $host, $offset, $freq, $sjit, $cjit, $wander, $disp, 0\n";
+ echo nl2br($output);
+}
+
+?>