Permalink
Browse files

variable/include path cleanup. added .gitignore. allow config.overide…

….php.
  • Loading branch information...
draco2003 committed Nov 5, 2011
1 parent 8198c12 commit 64168cd4a087a03d64e62efa30a449ae43dd8b9f
Showing with 244 additions and 247 deletions.
  1. +3 −0 .gitignore
  2. +16 −0 README.md
  3. +1 −1 ajax/alerts_json.php
  4. +16 −11 ajax/autocomplete.php
  5. +11 −7 ajax/get_rawdata.php
  6. +2 −4 check.php
  7. +3 −6 dashboard.php
  8. +1 −0 graphite_tattle_schema_alpha.sql
  9. +4 −7 graphs.php
  10. +48 −23 inc/classes/Check.php
  11. +0 −2 inc/classes/Graph.php
  12. +77 −38 inc/config.php
  13. +4 −16 inc/functions.php
  14. +4 −2 inc/includes.php
  15. +15 −14 inc/init.php
  16. +4 −4 inc/views/header.php
  17. +0 −53 inc/views/result.php
  18. +2 −2 index.php
  19. +4 −9 lines.php
  20. +22 −37 login.php
  21. +1 −1 processor.php
  22. +3 −5 result.php
  23. +1 −1 subscription.php
  24. +2 −4 user.php
@@ -0,0 +1,3 @@
inc/config.override.php
*~
js_cache
@@ -44,6 +44,22 @@ Installation and Configuration
* Create a session storage folder for flourishlib
* Create JS/CSS minification directory and allow Apache to write to it. By default this is
/js_cache e.g.
install -o www-data /var/www/js_cache/images
* Create a file called inc/config.override.php so that upgrades don't blow away your config
Your config.override might look something like this:
--------------------------
<?
$GLOBALS['DATABASE_NAME'] = 'graphite_tattle';
$GLOBALS['DATABASE_USER'] = 'tattle';
$GLOBALS['DATABASE_PASS'] = 'yoyoyo';
$GLOBALS['GRAPHITE_URL'] = 'http://graph';
--------------------------
* Edit inc/config.php with the correct settings (Examples db password)
* Setup cronjob to to run processor.php. This file can be run either as a cli or through the web server. (cli maybe required depending on your plugins and their required permissions)
@@ -1,5 +1,5 @@
<?php
include dirname(__FILE__) . '/../inc/init.php';
include '../inc/init.php';
fAuthorization::requireLoggedIn();
header('Cache-Control: no-cache, must-revalidate');
@@ -1,15 +1,20 @@
<?php
include dirname(__FILE__) . '/../inc/init.php');
$dir = new fDirectory(WHISPER_DIR);
include '../inc/init.php';
$path = str_replace('.', '/' ,fRequest::get('term','string'));
$term = fRequest::get('term','string');
//echo "Path is : $path";
$directories = $dir->scanRecursive($path. '*');
$return_arr = array();
foreach ($directories as $directory) {
$return_arr[] = array('value' => str_replace('.wsp','',str_replace('/','.',str_replace(WHISPER_DIR,'',$directory->getPath()))));
if ($GLOBALS['PRIMARY_SOURCE'] == 'GANGLIA') {
if ($GLOBALS['GANGLIA_URL'] != '') {
$json = file_get_contents($GLOBALS['GANGLIA_URL'] . '/tattle_autocomplete.php?term=' . $term);
print $json;
}
} else {
$dir = new fDirectory($GLOBALS['WHISPER_DIR']);
$path = str_replace('.', '/' ,fRequest::get('term','string'));
$directories = $dir->scanRecursive($path. '*');
$return_arr = array();
foreach ($directories as $directory) {
$return_arr[] = array('value' => str_replace('.wsp','',str_replace('/','.',str_replace($GLOBALS['WHISPER_DIR'],'',$directory->getPath()))));
}
print json_encode($return_arr);
}
/* Toss back results as json encoded array. */
echo json_encode($return_arr);
@@ -1,5 +1,5 @@
<?php
include dirname(__FILE__) . '/../inc/init.php';
include '../inc/init.php';
fAuthorization::requireLoggedIn();
header('Cache-Control: no-cache, must-revalidate');
@@ -10,12 +10,16 @@
header('Content-type: application/json');
}
$check_id = fRequest::get('check_id', 'integer');
$check = new Check($check_id);
$url = GRAPHITE_URL . '/graphlot/rawdata?&from=-24hour&until=-0hour' .
'&target=' . $check->prepareTarget() .
'&target=keepLastValue(threshold(' . $check->prepareWarn() .'))' ;
// '&target=threshold(' . $check->prepareError() . ')';
if ( $GLOBALS['PRIMARY_SOURCE'] == "GANGLIA" ) {
$parts = explode("_|_", $check->prepareTarget());
$url = $GLOBALS['GANGLIA_URL'] . "/graph.php?graphlot=1&cs=-1day&ce=now&c=" .
$parts[0] . "&h=" . $parts[1] . "&m=" . $parts[2];
} else {
$url = $GLOBALS['GRAPHITE_URL'] . '/graphlot/rawdata?&from=-24hour&until=-0hour' .
'&target=' . $check->prepareTarget() .
'&target=keepLastValue(threshold(' . $check->prepareWarn() .'))' ;
}
$contents = file_get_contents($url);
//$contents = file_get_contents(GRAPHITE_URL . '/graphlot/rawdata?&from=-24hour&until=-0hour&target=' . $check->prepareTarget() . '&target=' . $check->prepareWarn() . '&target=' . $check->prepareError());
print $contents;
@@ -1,14 +1,12 @@
<?php
include dirname(__FILE__) . '/inc/init.php';
include 'inc/init.php';
fAuthorization::requireLoggedIn();
fRequest::overrideAction();
$breadcrumbs[] = array('name' => 'Checks', 'url' => Check::makeUrl('list'), 'active'=> false);
$action = fRequest::getValid('action',
array('list', 'add', 'edit', 'delete')
);
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete'));
$sort = fCRUD::getSortColumn(array('name','target','warn','error','status','timestamp','count'));
$sort_dir = fCRUD::getSortDirection('asc');
@@ -1,13 +1,11 @@
<?php
include dirname(__FILE__) . '/inc/init.php';
include 'inc/init.php';
fAuthorization::requireLoggedIn();
fRequest::overrideAction();
$breadcrumbs[] = array('name' => 'Dashboards', 'url' => Dashboard::makeUrl('list'),'active' => false);
$action = fRequest::getValid('action',
array('list', 'add', 'edit', 'delete', 'view')
);
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete', 'view'));
$full_screen = fRequest::get('full_screen','boolean',false);
$dashboard_id = fRequest::get('dashboard_id','integer');
@@ -19,7 +17,7 @@
try {
$dashboard = new Dashboard($dashboard_id);
$graphs = $dashboard->buildGraphs();
//$graphs = Graph::findAll($dashboard_id);
if (fRequest::isPost()) {
$dashboard->populate();
fRequest::validateCSRFToken(fRequest::get('token'));
@@ -28,7 +26,6 @@
fMessaging::create('affected', fURL::get(), $dashboard->getName());
fMessaging::create('success', fURL::get(),
'The Dashboard ' . $dashboard->getName(). ' was successfully updated');
//fURL::redirect($manage_url);
}
} catch (fNotFoundException $e) {
fMessaging::create('error', Dashboard::makeUrl('list'),
@@ -12,6 +12,7 @@ CREATE TABLE `users` (
CREATE TABLE `settings` (
`setting_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`friendly_name` varchar(200) NOT NULL,
`value` varchar(500) NOT NULL,
`plugin` varchar(200) NOT NULL,
`type` varchar(100) NOT NULL DEFAULT 'string',
@@ -1,16 +1,14 @@
<?php
include dirname(__FILE__) . '/inc/init.php';
include 'inc/init.php';
fAuthorization::requireLoggedIn();
fRequest::overrideAction();
$action = fRequest::getValid('action',
array('list', 'add', 'edit', 'delete', 'view')
);
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete', 'view'));
$dashboard_id = fRequest::get('dashboard_id');
$graph_id = fRequest::get('graph_id');
$dashboard_id = fRequest::get('dashboard_id', 'integer');
$graph_id = fRequest::get('graph_id', 'integer');
$manage_url = $_SERVER['SCRIPT_NAME'];
// --------------------------------- //
@@ -27,7 +25,6 @@
fMessaging::create('affected', fURL::get(), $graph->getName());
fMessaging::create('success', fURL::getWithQueryString(),
'The Graph ' . $graph->getName(). ' was successfully updated');
//fURL::redirect($manage_url);
}
} catch (fNotFoundException $e) {
fMessaging::create('error', $manage_url,
@@ -81,7 +81,6 @@ static public function acknowledgeCheck($check=NULL,$result=NULL,$ackAll=false)
$check_results = CheckResult::build($result->getResultId());
}
foreach ($check_results as $check_result) {
fCore::expose($check_result);
$check_result->setAcknowledged(1);
$check_result->store();
}
@@ -95,7 +94,17 @@ static public function acknowledgeCheck($check=NULL,$result=NULL,$ackAll=false)
*/
static public function getData($obj=NULL)
{
$check_url = GRAPHITE_URL . '/render/?target=' . $obj->prepareTarget() . '&from='. $obj->prepareSample() . '&format=json';
if ( $GLOBALS['PRIMARY_SOURCE'] == "GANGLIA" ) {
$check_url = $GLOBALS['GANGLIA_URL'] . '/graph.php/?' .
'target=' . $obj->prepareTarget() .
'&cs='. $obj->prepareSample() .
'&ce=now&format=json';
} else {
$check_url = $GLOBALS['GRAPHITE_URL'] . '/render/?' .
'target=' . $obj->prepareTarget() .
'&from='. $obj->prepareSample() .
'&format=json';
}
$json_data = @file_get_contents($check_url);
if ($json_data) {
$data = json_decode($json_data);
@@ -175,31 +184,47 @@ static public function showGraph($obj=NULL,$img=true,$sample=false,$width=false,
} else {
$link = '<a href="';
}
$link .= GRAPHITE_URL . '/render/?';
$link .= 'target=legendValue(alias(' . $obj->prepareTarget() . '%2C%22Check : ' . $obj->prepareName() .'%22),%22last%22)';
//$link .= 'target=legendValue(' . $obj->prepareTarget() .',%22last%22)';
if ($sample !== False) {
$link .= '&from=' . $sample;
} else {
$link .= '&from=' . $obj->prepareSample();
}
if ($width !== false) {
$link .= '&width=' .$width;
} else {
$link .= '&width=' .GRAPH_WIDTH;
if ( $GLOBALS['PRIMARY_SOURCE'] == "GANGLIA" ) {
$parts = explode("_|_", $obj->prepareTarget());
$link .= $GLOBALS['GANGLIA_URL'] . "/graph.php?json=1&ce=now&c=" .
$parts[0] . "&h=" . $parts[1] . "&m=" . $parts[2];
if ($sample !== False) {
$link .= '&cs=' . $sample;
} else {
$link .= '&cs=' . $obj->prepareSample();
}
} else {
$link .= $GLOBALS['GRAPHITE_URL'] . '/render/?';
$link .= 'target=legendValue(alias(' . $obj->prepareTarget() . '%2C%22Check : ' . $obj->prepareName() .'%22),%22last%22)';
if ($sample !== False) {
$link .= '&from=' . $sample;
} else {
$link .= '&from=' . $obj->prepareSample();
}
if ($width !== false) {
$link .= '&width=' .$width;
} else {
$link .= '&width=' .$GLOBALS['GRAPH_WIDTH'];
}
$link .= '&height=' .$GLOBALS['GRAPH_HEIGHT'];
$link .= '&target=color(alias(threshold('. $obj->getError() . ')%2C%22Error%20('. $obj->getError() . ')%22)%2C%22' . $GLOBALS['ERROR_COLOR'] . '%22)';
$link .= '&target=color(alias(threshold('. $obj->getWarn() . ')%2C%22Warning%20('. $obj->getWarn() . ')%22)%2C%22' . $GLOBALS['WARN_COLOR'] . '%22)';
if ($hideLegend !== false) {
$link .= '&hideLegend=true';
}
}
$link .= '&height=' .GRAPH_HEIGHT;
$link .= '&target=color(alias(threshold('. $obj->getError() . ')%2C%22Error%20('. $obj->getError() . ')%22)%2C%22' . ERROR_COLOR . '%22)';
$link .= '&target=color(alias(threshold('. $obj->getWarn() . ')%2C%22Warning%20('. $obj->getWarn() . ')%22)%2C%22' . WARN_COLOR . '%22)';
if ($hideLegend !== false) {
$link .= '&hideLegend=true';
}
if ($img) {
$link .= '" title="' . $obj->prepareName() . '" alt="' . $obj->prepareName();
$link .= '" />';
} else {
$link .= '"> ' . $obj->prepareTarget() .'</a>';
}
} else {
$link .= '"> ' . $obj->prepareTarget() .'</a>';
}
return $link;
}
@@ -41,8 +41,6 @@ static public function makeURL($type, $obj=NULL)
static function drawGraph($obj=NULL,$parent=NULL)
{
//fCore::expose($parent);
//fCore::expose($obj);
$link = 'http://graph/render/?';
$lines = Line::findAll($obj->getGraphId());
foreach($lines as $line) {
Oops, something went wrong.

0 comments on commit 64168cd

Please sign in to comment.