Skip to content

Instantly share code, notes, and snippets.

@canoedf
Created December 12, 2014 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canoedf/e137bd11f2acf828e261 to your computer and use it in GitHub Desktop.
Save canoedf/e137bd11f2acf828e261 to your computer and use it in GitHub Desktop.
<?php
# Get parameters from caller and generate results
$data1 = $_POST['data1'];
$data2 = $_POST['data2'];
$data3 = $_POST['data3'];
# Log some details
$tracefile=fopen("/tmp/D3A.log","a");
echo fputs($tracefile,"D3A = : " . $data1 . "\n");
echo fputs($tracefile,"D3A = : " . $data2 . "\n");
echo fputs($tracefile,"D3A = : " . $data3 . "\n");
echo fputs($tracefile,"D3A ===============RECORD SEPERATOR================================= \n");
fclose($tracefile);
$username = "username";
$password = "password";
$host = "host";
$database="sitescope";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$myquery = "SELECT tm,metric FROM `SiteScopeLogmetricJournal` WHERE groupName='".$data1."' and monitor='Ping' and tm >= '".$data2."' AND tm < '".$data3."'ORDER BY tm";
$query = mysql_query($myquery);
if ( !$query ) {
echo mysql_error();
die;
}
$data = array();
for ($x = 0; $x < mysql_num_rows($query); $x++) {
$data[] = mysql_fetch_assoc($query);
}
echo json_encode($data);
mysql_close($server);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment