Skip to content

Commit

Permalink
variable/include path cleanup. added .gitignore. allow config.overide…
Browse files Browse the repository at this point in the history
….php.
  • Loading branch information
draco2003 committed Nov 5, 2011
1 parent 8198c12 commit 64168cd
Show file tree
Hide file tree
Showing 24 changed files with 244 additions and 247 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
inc/config.override.php
*~
js_cache
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ajax/alerts_json.php
@@ -1,5 +1,5 @@
<?php
include dirname(__FILE__) . '/../inc/init.php';
include '../inc/init.php';

fAuthorization::requireLoggedIn();
header('Cache-Control: no-cache, must-revalidate');
Expand Down
27 changes: 16 additions & 11 deletions ajax/autocomplete.php
@@ -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);
18 changes: 11 additions & 7 deletions ajax/get_rawdata.php
@@ -1,5 +1,5 @@
<?php
include dirname(__FILE__) . '/../inc/init.php';
include '../inc/init.php';

fAuthorization::requireLoggedIn();
header('Cache-Control: no-cache, must-revalidate');
Expand All @@ -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;
6 changes: 2 additions & 4 deletions check.php
@@ -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');
Expand Down
9 changes: 3 additions & 6 deletions dashboard.php
@@ -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');
Expand All @@ -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'));
Expand All @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions graphite_tattle_schema_alpha.sql
Expand Up @@ -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',
Expand Down
11 changes: 4 additions & 7 deletions graphs.php
@@ -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'];

// --------------------------------- //
Expand All @@ -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,
Expand Down
71 changes: 48 additions & 23 deletions inc/classes/Check.php
Expand Up @@ -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();
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions inc/classes/Graph.php
Expand Up @@ -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) {
Expand Down

0 comments on commit 64168cd

Please sign in to comment.