private function getPreviewImage($host, $service, $metric)
 {
     if ($host != Null) {
         $target = Macro::resolveMacros($this->hostMacro, $host);
     } elseif ($service != null) {
         $target = Macro::resolveMacros($this->serviceMacro, $service);
     } else {
         $target = '';
     }
     $target .= '.' . Macro::escapeMetric($metric);
     $target = $this->metricPrefix . "." . $target;
     $imgUrl = $this->baseUrl . Macro::resolveMacros($this->imageUrlMacro, array("target" => $target), false);
     $largeImgUrl = $this->baseUrl . Macro::resolveMacros($this->largeImageUrlMacro, array("target" => $target), false);
     $url = Url::fromPath('graphite', array('graphite_url' => urlencode($largeImgUrl)));
     $html = '<a href="%s" title="%s"><img src="%s" alt="%s" width="300" height="120" /></a>';
     return sprintf($html, $url, $metric, $imgUrl, $metric);
 }
Ejemplo n.º 2
0
 private function getPreviewImage($host, $service, $metric)
 {
     // metrics can contain chars which have to be replaced, too
     $metric = Macro::escapeMetric($metric, $this->legacyMode);
     if ($host != null) {
         $target = Macro::resolveMacros($this->hostMacro, $host, $this->legacyMode);
     } elseif ($service != null) {
         $target = Macro::resolveMacros($this->serviceMacro, $service, $this->legacyMode);
     } else {
         $target = '';
     }
     $target = Macro::resolveMacros($target, array("metric" => $metric), $this->legacyMode);
     $imgUrl = $this->baseUrl . Macro::resolveMacros($this->imageUrlMacro, array("target" => $target), $this->legacyMode, false);
     $largeImgUrl = $this->baseUrl . Macro::resolveMacros($this->largeImageUrlMacro, array("target" => $target), $this->legacyMode, false);
     $url = Url::fromPath('graphite', array('graphite_url' => urlencode($largeImgUrl)));
     $html = '<a href="%s" title="%s"><img src="%s" alt="%s" width="300" height="120" /></a>';
     return sprintf($html, $url, $metric, $imgUrl, $metric);
 }