-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew J Cronk
committed
Feb 8, 2012
1 parent
b2eb186
commit 348a2f0
Showing
4 changed files
with
101 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
require('./tempodb.php'); | ||
date_default_timezone_set("America/Chicago"); | ||
|
||
$tdb = new TempoDB("your-api-key", "your-api-secret"); | ||
|
||
$series_key = "custom-series-key"; | ||
$start = new DateTime("2011-01-03"); | ||
$end = new DateTime("2011-01-06"); | ||
|
||
/* http://tempo-db.com/api/read-series/#read-series-by-key */ | ||
|
||
|
||
/* read query with no rollup interval or function specified */ | ||
/* rollup interval will be auto-calculated based on start-end date read */ | ||
/* rollup function defaults to avg */ | ||
$result = $tdb->read_key($series_key, $start, $end); | ||
|
||
/* read query with no rollup interval specified */ | ||
/* rollup function defaults to avg */ | ||
//$result = $tdb->read_key($series_key, $start, $end, $interval="1month"); | ||
|
||
/* read query with a rollup interval specified */ | ||
//$result = $tdb->read_key($series_key, $start, $end, $interval="1month", $function="min"); | ||
|
||
var_dump($result); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require('./tempodb.php'); | ||
date_default_timezone_set("America/Chicago"); | ||
|
||
$tdb = new TempoDB("your-api-key", "your-api-secret"); | ||
|
||
$series_key = "custom-series-key"; | ||
|
||
/* http://tempo-db.com/api/write-series/#write-series-by-key */ | ||
|
||
|
||
$date = new DateTime("2012-01-01"); | ||
|
||
// insert random data for testing | ||
// write in ten days worth of data, starting on midnight of $date | ||
for ($day = 0; $day < 10; $day++) | ||
{ | ||
$data = array(); | ||
|
||
// build up array of timestamp/value pairs for one day | ||
for ($min=0; $min < 1440; $min++) | ||
{ | ||
$data[] = array('t' => $date->format("c"), 'v' => rand()/17); | ||
// increment by 1 min | ||
$date->modify("+1 minute"); | ||
} | ||
|
||
// send the days worth of data | ||
$result = $tdb->write_key($series_key, $data); | ||
var_dump($result); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters