Author: Lars Michelsen <[email protected]>
Date: Sun Sep 4 14:34:20 2011 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Sun Sep 4 14:34:20 2011 +0200
Backends can now override the NagVis summary_output/summary_state
algorithms to provide their own custom information
---
ChangeLog | 2 +
share/server/core/classes/objects/NagVisObject.php | 14 +++-----
share/server/core/classes/objects/NagiosHost.php | 33 ++++++++++++-------
.../core/classes/objects/NagiosHostgroup.php | 17 ++++++++--
.../core/classes/objects/NagiosServicegroup.php | 20 +++++++++--
share/server/core/functions/nagvisErrorHandler.php | 17 ++--------
6 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 86f3b2d..310d79d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@ Core
* omd_install.sh can now be called from other directories
* Allowing more unicode signs in e.g. map aliases
* Added new icon *_unreachable icon to represent the UNREACHABLE host state
+ * Backends can now override the NagVis summary_output/summary_state
algorithms
+ to provide their own custom information
Frontend
* Readded the "edit" action to the maps module. In this mode all object are
diff --git a/share/server/core/classes/objects/NagVisObject.php
b/share/server/core/classes/objects/NagVisObject.php
index aa76b1b..0226551 100644
--- a/share/server/core/classes/objects/NagVisObject.php
+++ b/share/server/core/classes/objects/NagVisObject.php
@@ -466,18 +466,11 @@ class NagVisObject {
return $ret;
}
- # End public methods
- # #########################################################################
-
/**
- * PROTECTED getUrl()
- *
+ * PUBLIC getUrl()
* Returns the url for the object link
- *
- * @return String URL
- * @author Lars Michelsen <[email protected]>
*/
- protected function getUrl() {
+ public function getUrl() {
if(isset($this->url)) {
return $this->url;
} else {
@@ -485,6 +478,9 @@ class NagVisObject {
}
}
+ # End public methods
+ # #########################################################################
+
/**
* PROTECTED getUrlTarget()
*
diff --git a/share/server/core/classes/objects/NagiosHost.php
b/share/server/core/classes/objects/NagiosHost.php
index a2dac32..f264f7d 100644
--- a/share/server/core/classes/objects/NagiosHost.php
+++ b/share/server/core/classes/objects/NagiosHost.php
@@ -84,16 +84,23 @@ class NagiosHost extends NagVisStatefulObject {
*/
public function fetchSummariesFromCounts() {
// Generate summary output
- $this->fetchSummaryOutputFromCounts();
-
- // Add host state to counts
- // This should be done after output generation and before
- // summary state fetching. It could confuse the output fetching but
- // is needed for the summary state
- $this->addHostStateToStateCounts();
-
- // Calculate summary state
- $this->fetchSummaryStateFromCounts();
+ // Only create summary output from childs when the summary_output is
empty.
+ // It might be generated by the backend.
+ if($this->summary_output === '')
+ $this->fetchSummaryOutputFromCounts();
+
+ // Only create summary from childs when the summary_state is empty.
+ // It might be generated by the backend.
+ if($this->summary_state === '') {
+ // Add host state to counts
+ // This should be done after output generation and before
+ // summary state fetching. It could confuse the output fetching but
+ // is needed for the summary state
+ $this->addHostStateToStateCounts();
+
+ // Calculate summary state
+ $this->fetchSummaryStateFromCounts();
+ }
}
/**
@@ -149,8 +156,10 @@ class NagiosHost extends NagVisStatefulObject {
if($this->aStateCounts !== null) {
$this->fetchSummariesFromCounts();
} else {
- $this->fetchSummaryState();
- $this->fetchSummaryOutput();
+ if($this->summary_state === '')
+ $this->fetchSummaryState();
+ if($this->summary_output === '')
+ $this->fetchSummaryOutput();
}
}
diff --git a/share/server/core/classes/objects/NagiosHostgroup.php
b/share/server/core/classes/objects/NagiosHostgroup.php
index 171da4e..0ee240f 100644
--- a/share/server/core/classes/objects/NagiosHostgroup.php
+++ b/share/server/core/classes/objects/NagiosHostgroup.php
@@ -90,11 +90,20 @@ class NagiosHostgroup extends NagVisStatefulObject {
// calculate summary state and output
if($this->aStateCounts !== null) {
// Calculate summary state and output
- $this->fetchSummaryStateFromCounts();
- $this->fetchSummaryOutputFromCounts();
+
+ // Only create summary from childs when not set yet (e.g by
backend)
+ if($this->summary_state === '')
+ $this->fetchSummaryStateFromCounts();
+
+ // Only create summary from childs when not set yet (e.g by
backend)
+ if($this->summary_output === '')
+ $this->fetchSummaryOutputFromCounts();
} else {
- $this->fetchSummaryState();
- $this->fetchSummaryOutput();
+ if($this->summary_state === '')
+ $this->fetchSummaryState();
+
+ if($this->summary_output === '')
+ $this->fetchSummaryOutput();
}
$this->state = $this->summary_state;
diff --git a/share/server/core/classes/objects/NagiosServicegroup.php
b/share/server/core/classes/objects/NagiosServicegroup.php
index e8bc3c6..41c80a4 100644
--- a/share/server/core/classes/objects/NagiosServicegroup.php
+++ b/share/server/core/classes/objects/NagiosServicegroup.php
@@ -89,11 +89,22 @@ class NagiosServicegroup extends NagVisStatefulObject {
// calculate summary state and output
if($this->aStateCounts !== null) {
// Calculate summary state and output
- $this->fetchSummaryStateFromCounts();
- $this->fetchSummaryOutputFromCounts();
+
+ // Only create summary from childs when the summary_state is empty.
+ // It might be generated by the backend.
+ if($this->summary_state === '')
+ $this->fetchSummaryStateFromCounts();
+
+ // Only create summary output from childs when the summary_output
is empty.
+ // It might be generated by the backend.
+ if($this->summary_output === '')
+ $this->fetchSummaryOutputFromCounts();
} else {
- $this->fetchSummaryState();
- $this->fetchSummaryOutput();
+ if($this->summary_state === '')
+ $this->fetchSummaryState();
+
+ if($this->summary_output === '')
+ $this->fetchSummaryOutput();
}
$this->state = $this->summary_state;
@@ -183,6 +194,7 @@ class NagiosServicegroup extends NagVisStatefulObject {
}
}
+
// FIXME: Recode mergeSummaryOutput method
$this->mergeSummaryOutput($arrServiceStates, l('services'));
diff --git a/share/server/core/functions/nagvisErrorHandler.php
b/share/server/core/functions/nagvisErrorHandler.php
index 1bc0fe7..da2e15b 100644
--- a/share/server/core/functions/nagvisErrorHandler.php
+++ b/share/server/core/functions/nagvisErrorHandler.php
@@ -29,22 +29,11 @@
*
* @author Lars Michelsen <[email protected]>
*/
-function ajaxError($errno, $errstr = '', $file = '', $line = '') {
- // Use current error_reporting settings to skip unwanted errors
- if(!(error_reporting() & $errno))
- return false;
-
- echo "Error: (".$errno.") ".$errstr. " (".$file.":".$line.")";
- die();
-}
function nagvisException($OBJ) {
try {
- if(get_class($OBJ) == 'ErrorException') {
- echo "Error: (".$OBJ->getCode().") ".$OBJ->getMessage()
- ." (".$OBJ->getFile().":".$OBJ->getLine().")<br /><br />\n ";
- echo "<code>".str_replace("\n", "<br />\n",
$OBJ->getTraceAsString())."</code>";
- } elseif(get_class($OBJ) == 'NagVisException') {
+ if(get_class($OBJ) == 'NagVisException'
+ || get_class($OBJ) == 'NagVisErrorException') {
echo $OBJ;
} else {
echo "Error (".get_class($OBJ)."): ".$OBJ->getMessage();
@@ -62,7 +51,7 @@ function nagvisExceptionErrorHandler($errno, $errstr,
$errfile, $errline ) {
if(!(error_reporting() & $errno))
return false;
- throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+ throw new NagVisErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("nagvisExceptionErrorHandler");
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins