Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
349 lines (324 sloc) 12.2 KB
diff -ur A/include/classes/graphdraw/CLineGraphDraw.php B/include/classes/graphdraw/CLineGraphDraw.php
--- A/include/classes/graphdraw/CLineGraphDraw.php 2015-12-09 13:04:08.000000000 +0100
+++ B/include/classes/graphdraw/CLineGraphDraw.php 2015-12-09 13:10:21.000000000 +0100
@@ -34,7 +34,7 @@
$this->skipRightScale = 0; // in case if right axis should be drawn but doesn't contain any data
$this->ymin_itemid = 0;
$this->ymax_itemid = 0;
- $this->legendOffsetY = 90;
+ $this->legendOffsetY = 80;
$this->percentile = array(
'left' => array(
'percent' => 0, // draw percentage line
@@ -63,18 +63,20 @@
// PRE CONFIG: ADD / SET / APPLY
/********************************************************************************************************/
public function updateShifts() {
- if ($this->yaxisleft == 1 && $this->yaxisright == 1) {
+ /*if ($this->yaxisleft == 1 && $this->yaxisright == 1) {
$this->shiftXleft = 85;
$this->shiftXright = 85;
}
elseif ($this->yaxisleft == 1) {
- $this->shiftXleft = 85;
+ $this->shiftXleft = 55;
$this->shiftXright = 30;
}
elseif ($this->yaxisright == 1) {
$this->shiftXleft = 30;
$this->shiftXright = 85;
- }
+ }*/
+ $this->shiftXleft = 65;
+ $this->shiftXright = 65;
}
public function getShifts() {
@@ -1483,6 +1485,7 @@
$units = null;
$unitsLong = null;
$byteStep = false;
+ $font_size = 8;
for ($item = 0; $item < $this->num; $item++) {
if ($this->items[$item]['axisside'] == $side) {
@@ -1523,7 +1526,7 @@
imageText(
$this->im,
- 9,
+ $font_size,
90,
$tmpX,
$tmpY,
@@ -1618,7 +1621,7 @@
if ($side == GRAPH_YAXIS_SIDE_LEFT) {
$dims = imageTextSize(8, 0, $str);
- $posX = $this->shiftXleft - $dims['width'] - 9;
+ $posX = $this->shiftXleft - $dims['width'] - 4;
}
else {
$posX = $this->sizeX + $this->shiftXleft + 12;
@@ -1629,7 +1632,7 @@
imageText(
$this->im,
- 8,
+ $font_size,
0,
$posX,
$posY,
@@ -1660,7 +1663,7 @@
imageText(
$this->im,
- 8,
+ $font_size,
0,
$posX,
$this->shiftY + 4,
@@ -1821,14 +1824,14 @@
}
protected function drawLegend() {
- $leftXShift = 20;
+ $leftXShift = 65;
$units = array('left' => 0, 'right' => 0);
// draw item legend
$legend = new CImageTextTable($this->im, $leftXShift - 5, $this->sizeY + $this->shiftY + $this->legendOffsetY);
$legend->color = $this->getColor($this->graphtheme['textcolor'], 0);
- $legend->rowheight = 14;
- $legend->fontsize = 9;
+ $legend->rowheight = 10;
+ $legend->fontsize = 11;
// item legend table header
$row = array(
@@ -2391,7 +2394,7 @@
$this->fullSizeY = $this->sizeY + $this->shiftY + $this->legendOffsetY;
if ($this->drawLegend) {
- $this->fullSizeY += 14 * ($this->num + 1 + (($this->sizeY < 120) ? 0 : count($this->triggers))) + 8;
+ $this->fullSizeY += 15 * ($this->num + 1 + (($this->sizeY < 120) ? 0 : count($this->triggers))) + 8;
}
// if graph height is big enough, we reserve space for percent line legend
@@ -2513,12 +2516,12 @@
$this->drawLegend();
}
- $this->drawLogo();
+ //$this->drawLogo();
$str = sprintf('%0.2f', microtime(true) - $start_time);
$str = _s('Data from %1$s. Generated in %2$s sec.', $this->dataFrom, $str);
$strSize = imageTextSize(6, 0, $str);
- imageText($this->im, 6, 0, $this->fullSizeX - $strSize['width'] - 5, $this->fullSizeY - 5, $this->getColor('Gray'), $str);
+ imageText($this->im, 6, 0, 62, $this->fullSizeY - 5, $this->getColor('Gray'), $str);
unset($this->items, $this->data);
diff -ur A/include/classes/pagefilter/CPageFilter.php B/include/classes/pagefilter/CPageFilter.php
--- A/include/classes/pagefilter/CPageFilter.php 2015-12-09 13:04:09.000000000 +0100
+++ B/include/classes/pagefilter/CPageFilter.php 2015-12-09 14:07:41.673432586 +0100
@@ -525,9 +525,15 @@
$options = zbx_array_merge($def_ptions, $options);
$graphs = API::Graph()->get($options);
order_result($graphs, 'name');
-
- foreach ($graphs as $graph) {
- $this->data['graphs'][$graph['graphid']] = $graph;
+
+ if ($this->hostsAll) {
+ foreach ($graphs as $graph) {
+ $this->data['graphs'][$graph['name']] = $graph;
+ }
+ } else {
+ foreach ($graphs as $graph) {
+ $this->data['graphs'][$graph['graphid']] = $graph;
+ }
}
// no graphid provided
diff -ur A/include/defines.inc.php B/include/defines.inc.php
--- A/include/defines.inc.php 2015-12-09 13:04:09.000000000 +0100
+++ B/include/defines.inc.php 2015-12-09 13:21:02.000000000 +0100
@@ -42,6 +42,7 @@
define('ZBX_FONTPATH', realpath('fonts')); // where to search for font (GD > 2.0.18)
define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
+define('ZBX_GRAPH_FONT_NAME', 'calibri');
define('ZBX_GRAPH_LEGEND_HEIGHT', 120); // when graph height is less then this value, some legend will not show up
define('ZBX_SCRIPT_TIMEOUT', 60); // in seconds
diff -ur A/include/views/monitoring.charts.php B/include/views/monitoring.charts.php
--- A/include/views/monitoring.charts.php 2015-12-09 13:04:03.000000000 +0100
+++ B/include/views/monitoring.charts.php 2015-12-09 13:13:56.000000000 +0100
@@ -1,3 +1,74 @@
+<script type="text/javascript">
+ jQuery(function() {
+ if(jQuery('#groupid option').length>25){
+ //merge group names by left part
+ jQuery('#groupid').hide();
+ jQuery('#groupid').after('<select id="groups" class="input select">');
+ jQuery('#groupid option').each(function(i){
+ var name = jQuery(this).text(),
+ id = jQuery(this).val();
+ if(name.indexOf(' ') != -1 ){
+ var left=jQuery(this).text().split(' ')[0];
+ if(jQuery('#groups option[name="'+left+'"]').length) return;
+ if(jQuery('#groupid option:contains("'+left+' ")').length>1){
+ jQuery('#groups').append('<option name="'+left+'">'+left+' &gt;</option>');
+ return;
+ }
+ }
+ jQuery('#groups').append('<option name="'+name+'" value="'+id+'">'+name+'</option>');
+ });
+
+ //show subgroup select for merged groups
+ jQuery('#groups').change(function(){
+ var text=jQuery("#groups option:selected" ).text(),
+ group=jQuery("#groups option:selected" ).attr('name'),
+ len=group.length + 1,
+ val=jQuery("#groups option:selected" ).val();
+ if(text.endsWith('>')){
+ if(jQuery('#subgroups').length) jQuery('#subgroups').remove();
+ jQuery('#groups').after('<select id="subgroups" class="input select">');
+ //jQuery('#subgroups').append('<option></option>');
+ jQuery('#groupid option:contains("'+group+' ")').each(function(i){
+ var name = jQuery(this).text(),
+ id = jQuery(this).val();
+ if(name.startsWith(group+' ')){
+ name=name.substring(len);
+ jQuery('#subgroups').append('<option name="'+name+'" value="'+id+'">'+name+'</option>');
+ }
+ });
+ jQuery('#subgroups').focus(function(){
+ this.selectedIndex = -1;
+ });
+ jQuery('#subgroups').change(function(){
+ var val=jQuery("#subgroups option:selected").val();
+ if(val.length){
+ jQuery('#groupid option[value="'+val+'"]').attr('selected','selected');
+ jQuery('#groupid').trigger('change');
+ }
+ });
+ }
+ else {
+ jQuery('#groupid option[value="'+val+'"]').attr('selected','selected');
+ jQuery('#groupid').trigger('change');
+ }
+ });
+
+ //restore selection on page load
+ var val=jQuery("#groupid option:selected" ).val(),
+ i=jQuery('#groups option[value="'+val+'"]'),
+ text=jQuery("#groupid option:selected" ).text();
+ if(i.length) i.attr('selected','selected');
+ else{
+ var left=text.split(' ')[0];
+ jQuery('#groups option[name="'+left+'"]').attr('selected','selected');
+ jQuery('#groups').trigger('change');
+ //jQuery('#subgroups option')[0].remove();
+ jQuery('#subgroups option[value="'+val+'"]').attr('selected','selected');
+ }
+ }
+ });
+</script>
+
<?php
/*
** Zabbix
@@ -18,7 +89,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-
$chartsWidget = new CWidget('hat_charts');
$chartForm = new CForm('get');
$chartForm->addVar('fullscreen', $this->data['fullscreen']);
@@ -49,7 +119,8 @@
);
$chartsWidget->addItem(BR());
-if (!empty($this->data['graphid'])) {
+//single graph selected, host selected
+if(!empty($this->data['graphid']) && $this->data['pageFilter']->hostid) {
// append chart to widget
$screen = CScreenBuilder::getScreen(array(
'resourcetype' => SCREEN_RESOURCE_CHART,
@@ -68,7 +139,8 @@
'profileIdx' => $screen->profileIdx
));
}
-else {
+//nothing selected
+else if(empty($this->data['graphid']) && !$this->data['pageFilter']->hostid) {
$screen = new CScreenBuilder();
CScreenBuilder::insertScreenStandardJs(array(
'timeline' => $screen->timeline
@@ -76,5 +148,74 @@
$chartsWidget->addItem(new CTableInfo(_('No graphs found.')));
}
+//cumulative graphs
+else {
+ //host not selected, graph selected
+ if (!empty($this->data['graphid']) && !$this->data['pageFilter']->hostid) {
+ //all servers
+ if(!$this->data['pageFilter']->groupid){
+ $options = array(
+ 'output' => array('graphid', 'name', 'graphtype'),
+ //'limit' => 50,
+ 'filter' => array('name' => $this->data['pageFilter']->graphs[$this->data['graphid']]['name']),
+ 'templated' => false,
+ 'sortfield' => 'name'
+ );
+ }
+ //group selected
+ else{
+ $options = array(
+ 'output' => array('graphid', 'name', 'graphtype'),
+ 'groupids' => $this->data['pageFilter']->groupid,
+ 'filter' => array('name' => $this->data['pageFilter']->graphs[$this->data['graphid']]['name']),
+ 'templated' => false,
+ 'sortfield' => 'name'
+ );
+ }
+ }
+ //host selected, graph not selected
+ else if ($this->data['pageFilter']->hostid != 0) {
+ $options = array(
+ 'output' => array('graphid', 'name', 'graphtype'),
+ 'hostids' => $this->data['pageFilter']->hostid,
+ 'sortfield' => 'name'
+ );
+ }
+ $chartTable = new CTable(_('No graphs defined.'), 'screen_view');
+
+ $graphs = API::Graph()->get($options);
+ CWebUser::$data['rows_per_page'] = 20;
+ $paging = getPagingLine($graphs);
+
+ $i=0;
+ $newColumns = array();
+ foreach ($graphs as $graph) {
+ $screen = CScreenBuilder::getScreen(array(
+ 'resourcetype' => SCREEN_RESOURCE_GRAPH,
+ 'screenitem' => array('width' => '600', 'height' => '200', 'resourceid'=>$graph['graphid'], 'screenitemid' => $graph['graphid'], 'screenid'=>1, 'dynamic'=>0),
+ //'resourcetype' => SCREEN_RESOURCE_CHART, //uncomment to have selectable graphs
+ 'graphid' => $graph['graphid'],
+ 'profileIdx' => 'web.screens',
+ 'profileIdx2' => $graph['graphid'],
+ 'dataId' => 'graph_full_' . $graph['graphid']
+ ));
+ $newColumn = new CCol($screen->get(), 'cntr_top screenitem');
+ array_push($newColumns, $newColumn);
+ if($i){
+ $chartTable->addRow(new CRow($newColumns));
+ $i=0;
+ $newColumns = array();
+ }
+ else $i++;
+ }
+ if($i){$chartTable->addRow(new CRow($newColumns));}
+
+ $chartsWidget->addItem(array($paging,$chartTable,$paging));
+
+ CScreenBuilder::insertScreenStandardJs(array(
+ 'timeline' => $screen->timeline,
+ 'profileIdx' => $screen->profileIdx
+ ));
+}
return $chartsWidget;
diff -ur A/js/gtlc.js B/js/gtlc.js
--- A/js/gtlc.js 2015-12-09 13:04:10.000000000 +0100
+++ B/js/gtlc.js 2015-12-09 13:23:35.000000000 +0100
@@ -135,7 +135,7 @@
}
// url
- if (isset('graphtype', obj.objDims) && obj.objDims.graphtype < 2) {
+ if (isset('graphtype', obj.objDims) && (obj.objDims.graphtype < 2 || obj.objDims.graphtype>=10)) {
var graphUrl = new Curl(obj.src);
graphUrl.setArgument('width', obj.objDims.width);