Re: [Nagvis-devel] [PATCH] Don't crach for weathermap lines if perfdata is missing
Brought to you by:
larsi-
From: Lars M. <lm...@la...> - 2013-06-10 21:08:02
|
Hello Max, thanks for the patch. I just applied it to the git master. Regards Lars On 05/14/2013 01:35 PM, Max Sikstrom wrote: > From: Max Sikström <msi...@op...> > > Adding a weathermap line (-->BW+%-><-BW+%--) for a service not presenting the > correct performace data, or for a line without a related service, the perfdata > variable in the method drawNagVisLine is set to null. > > This results in an error when trying to access perfdata[0]. > > This patch sets perfdata to an empty array, making array access to the perfdata > available, but perfdata[0] isn't set, which is ok due to tests afterwards. > > When perfdata isn't set, make the output nicer than a string "null" too. > > Signed-off-by: Max Sikström <msi...@op...> > --- > share/frontend/nagvis-js/js/lines.js | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/share/frontend/nagvis-js/js/lines.js b/share/frontend/nagvis-js/js/lines.js > index 29b885f..c4d7d67 100644 > --- a/share/frontend/nagvis-js/js/lines.js > +++ b/share/frontend/nagvis-js/js/lines.js > @@ -259,6 +259,11 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, width, colorFill, col > var xEnd = x[x.length - 1]; > var yEnd = y[y.length - 1]; > > + //If no performance data is available, make perfdata defined, so perfdata[0] > + //doesn't trigger an error, but is unset > + if(perfdata == null) > + perfdata = []; > + > // Handle start/end offsets > //xStart = xStart + newX(xEnd-xStart, yEnd-yStart, 16, 0); > //yStart = yStart + newY(xEnd-xStart, yEnd-yStart, 16, 0); > @@ -266,8 +271,10 @@ function drawNagVisLine(objectId, lineType, cuts, x, y, z, width, colorFill, col > //yEnd = yEnd + newY(xEnd-xStart, yEnd-yStart, -16, 0); > > width = parseInt(width, 10); > - var perfdataA = null; > - var perfdataB = null; > + > + // If not set below, better output something readable than "null" > + var perfdataA = "N/A"; > + var perfdataB = "N/A"; > > // Cuts > // Lines meeting point position -- Lars Michelsen IT Keltenstraße 4 85586 Poing Mobile: +49 151 26965801 E-Mail: lm...@la... |