Skip to content

Commit

Permalink
Added regression_type to Check in schema to prepare for Predictive An…
Browse files Browse the repository at this point in the history
…alytics based alerts. Moved javascript to header from add_edit. Added tooltips to add_edit
  • Loading branch information
jpatapoff committed May 15, 2012
1 parent 78aeda3 commit 870a356
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 35 deletions.
21 changes: 21 additions & 0 deletions assets/js/tattle.js
Expand Up @@ -24,3 +24,24 @@ function attachTooltips() {
});
}

function reloadGraphiteGraph() {
if(document.images['renderedGraphImage'] != null) {
var imageURL = document.images['renderedGraphImage'].src;
document.images['renderedGraphImage'].src = "";
if(imageURL.indexOf("?preventCaching=") === -1 && imageURL.indexOf("&preventCaching=") === -1) {
imageURL = imageURL + "&preventCaching=" + (new Date()).getTime();
}
else {
preventCachingRegex = /([?|&]preventCaching=)[^\&]+/;
imageURL = imageURL.replace(preventCachingRegex, '$1' + (new Date()).getTime());
}
if(imageURL.indexOf("?from=") === -1 && imageURL.indexOf("&from=") === -1) {
imageURL = imageURL + "&from=" + document.getElementById("graphiteDateRange").value;
}
else {
graphDateRangeRegex = /([?|&]from=)[^\&]+/;
imageURL = imageURL.replace(graphDateRangeRegex, '$1' + document.getElementById("graphiteDateRange").value);
}
document.images['renderedGraphImage'].src = imageURL;
}
}
3 changes: 2 additions & 1 deletion graphite_tattle_schema_alpha.sql
Expand Up @@ -50,7 +50,8 @@ CREATE TABLE `checks` (
`last_check_value` int(11) DEFAULT NULL,
`last_check_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`repeat_delay` int(11) NOT NULL DEFAULT '60',
`type` varchar(45) NOT NULL,
`type` varchar(255) NOT NULL,
`regression_type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`check_id`),
UNIQUE KEY `user_id` (`user_id`,`name`)
) CHARSET=utf8;
Expand Down
42 changes: 9 additions & 33 deletions inc/views/add_edit.php
Expand Up @@ -3,59 +3,35 @@
$tmpl->set('title', $page_title);
$breadcrumbs[] = array('name' => $page_title, 'url' => ($action == 'add' ? Check::makeURL($action,$check_type) : Check::makeURL($action,$check_type,$check)), 'active' => true);
$tmpl->set('breadcrumbs',$breadcrumbs);
$tmpl->set('addeditdocready',true);
$tmpl->place('header');
?>
<script language="javascript">
$(document).ready(function() {
$("fieldset.startCollapsed").collapse( { closed: false } );
reloadGraphiteGraph();
});

function reloadGraphiteGraph() {
var imageURL = document.images['renderedGraphImage'].src;
document.images['renderedGraphImage'].src = "";
if(imageURL.indexOf("?preventCaching=") === -1 && imageURL.indexOf("&preventCaching=") === -1) {
imageURL = imageURL + "&preventCaching=" + (new Date()).getTime();
}
else {
preventCachingRegex = /([?|&]preventCaching=)[^\&]+/;
imageURL = imageURL.replace(preventCachingRegex, '$1' + (new Date()).getTime());
}
if(imageURL.indexOf("?from=") === -1 && imageURL.indexOf("&from=") === -1) {
imageURL = imageURL + "&from=" + document.getElementById("graphiteDateRange").value;
}
else {
graphDateRangeRegex = /([?|&]from=)[^\&]+/;
imageURL = imageURL.replace(graphDateRangeRegex, '$1' + document.getElementById("graphiteDateRange").value);
}
document.images['renderedGraphImage'].src = imageURL;
}
</script>
<div class="row">
<div class="span4">
<form class="form-stacked" action="<?=fURL::get(); ?>?action=<?=$action; ?>&check_id=<?=$check_id; ?>" method="post">
<div class="main" id="main">
<fieldset>
<div class="clearfix">
<label for="check-name">Name<em>*</em></label>
<label class="masterTooltip" title="Name used to identify this check" for="check-name">Name<em>*</em></label>
<div class="input">
<input id="check-name" class="span3" type="text" size="30" name="name" value="<?=$check->encodeName(); ?>" />
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-target">Graphite Target<em>*</em></label>
<label class="masterTooltip" title="The path of your new Graph Target to check up on" for="check-target">Graphite Target<em>*</em></label>
<div class="input">
<input id="check-target" class="span3" type="text" size="30" name="target" value="<?=$check->encodeTarget(); ?>" />
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-error">Error Threshold<em>*</em></label>
<label class="masterTooltip" title="The threshold level at which an Error will be triggered" for="check-error">Error Threshold<em>*</em></label>
<div class="input">
<input id="check-error" class="span3" type="text" name="error" value="<?=$check->encodeError(); ?>" />
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-warn">Warn Threshold<em>*</em></label>
<label class="masterTooltip" title="The threshold level at which a Warning will be triggered" for="check-warn">Warn Threshold<em>*</em></label>
<div class="input">
<input id="check-warn" class="span3" type="text" name="warn" value="<?=$check->encodeWarn(); ?>" />
</div>
Expand All @@ -64,13 +40,13 @@ function reloadGraphiteGraph() {
<fieldset class="startCollapsed">
<legend>Advanced</legend>
<div class="clearfix">
<label for="check-sample">Sample Size in Minutes<em>*</em></label>
<label class="masterTooltip" title="Number of data points to use when calculating the moving average. Each data point spans one minute" for="check-sample">Sample Size in Minutes<em>*</em></label>
<div class="input">
<input id="check-warn" class="span3" type="text" name="sample" value="<?=$check->encodeSample(); ?>" />
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-over_under">Over/Under<em>*</em></label>
<label class="masterTooltip" title="Over will trigger an alert when the value retrieved from Graphite is greater than the warning or error threshold. Under will trigger an alert when the value retrieved from Graphite is less than the warning or the error threshold" for="check-over_under">Over/Under<em>*</em></label>
<div class="input">
<select name="over_under" class="span3">
<?
Expand All @@ -82,7 +58,7 @@ function reloadGraphiteGraph() {
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-visibility">Visibility<em>*</em></label>
<label class="masterTooltip" title="Public checks can be subscribed to by any user while private checks remain hidden from other users" for="check-visibility">Visibility<em>*</em></label>
<div class="input">
<select name="visibility" class="span3">
<?
Expand All @@ -94,7 +70,7 @@ function reloadGraphiteGraph() {
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="check-repeat_delay">Repeat Delay<em>*</em></label>
<label class="masterTooltip" title="After an alert is triggered, the number of minutes to wait before sending another one" for="check-repeat_delay">Repeat Delay<em>*</em></label>
<div class="input">
<?php
$check_delay = (is_null($check->getRepeatDelay()) ? 30 : $check->encodeRepeatDelay()); ?>
Expand Down
12 changes: 12 additions & 0 deletions inc/views/header.php
Expand Up @@ -25,6 +25,18 @@
</script>

<?php }


if ($this->get('addeditdocready')) { ?>
<script type="text/javascript">
$(document).ready(function() {
$("fieldset.startCollapsed").collapse( { closed: false } );
reloadGraphiteGraph();
attachTooltips();
});
</script>
<?php }


if (!$this->get('full_screen')) { ?>
<style type="text/css">
Expand Down
2 changes: 1 addition & 1 deletion inc/views/list_checks.php
Expand Up @@ -25,7 +25,7 @@
<th class="masterTooltip" title="The threshold level at which an Error will be triggered"><?=fCRUD::printSortableColumn('error','Error'); ?></th>
<th class="masterTooltip" title="Number of data points to use when calculating the moving average. Each data point spans one minute"><?=fCRUD::printSortableColumn('sample','Sample'); ?></th>
<th><?=fCRUD::printSortableColumn('baseline','Baseline'); ?></th>
<th class="masterTooltip" title="Over will trigger an event when the value retrieved from Graphite is greater than the warning or error threshold. Under will trigger an event when the value retrieved from Graphite is less than the warning or the error threshold"><?=fCRUD::printSortableColumn('over_under','Over/Under'); ?></th>
<th class="masterTooltip" title="Over will trigger an alert when the value retrieved from Graphite is greater than the warning or error threshold. Under will trigger an alert when the value retrieved from Graphite is less than the warning or the error threshold"><?=fCRUD::printSortableColumn('over_under','Over/Under'); ?></th>
<th class="masterTooltip" title="Public checks can be subscribed to by any user while private checks remain hidden from other users"><?=fCRUD::printSortableColumn('visiblity','Visibility'); ?></th>
<th>Action</th>
</tr></thead><tbody>
Expand Down

0 comments on commit 870a356

Please sign in to comment.