Blog Archives

Fixing the monitoring hosts > hosts view in centreon 2.1.4

When opening the Monitoring > Hosts > Hosts view to view all the available and configured hosts in Centreon 2.1.4 you will get a blank result. This happens because there is a coding error in the following file.

/usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php on line 249

To correct it you need to add a else statement to the if, elseif validation that happens there. So open the file listed above using your fav. editor (vim in my case)

vim /usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php

Version 2.1.4

Skip to line 249 typing ” :249 ” followed by an enter stroke.
On that line there should be something like;

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";

Change it to this by adding the part starting from “else”.

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";
                else
                        $hard_duration = " unknown ";

Version 2.1.8

Goto rule 272 in the same file and locate this piece of code:

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";

Add the following to make it work.

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";
                else
                        $hard_duration = "N/A";

This same rule is responsible for the following errors in your apache error_log.

PHP Notice: Undefined variable: hard_duration in /usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php on line 271, referer: http://centreon.amis.nl/centreon/main.php?p=20102&o=h

This change should fix it for ya.

Grtz, Chris.

Advertisements

Compare File contence using VBScript.

Ever had the need to compare a file using VBS? You might wonder why you might need something like that? For instance. You have all your coperate templates on your network, but you want to upload these to your portable clients so they always have access to these templates. To keep these clients up-to-date you only want to upload these template each time a version file is changed on the network.

To do this you need to compare the contence of that file. Here is a script that will enable you to do just that.

Set Fso = WScript.CreateObject(“Scripting.FileSystemObject”)

CopyTemplates = “NotSet”
If Fso.FileExists(“C:\office\version.txt”) then
set objFile1 = Fso.opentextfile(“C:\AMIS-Huisstijl\office\versie.txt”,1)
Else
CopyTemplates = “True”
End If
If Fso.FileExists(“F:\office\version.txt”) then
set objFile2 = Fso.opentextfile(“F:\AMIS-Huisstijl\office\versie.txt”,1)
Else
CopyTemplates = “True”
End If
If CopyTemplates = “NotSet” Then
arrFile1 = split(objFile1.ReadAll,vbNewLine)
arrFile2 = split(objFile2.ReadAll,vbNewLine)
objFile1.close
objFile2.close
If ubound(arrFile1) ubound(arrFile2) then
intLineCount = ubound(arrFile2)
strError = strFile2 & ” is bigger than ” & strFile1
Else
intLineCount = ubound(arrFile2)
End if
for i = 0 to intLineCount
if not arrFile1(i) = arrFile2(i) then
exit for
end if
next
If i < (intLineCount + 1) then
CopyTemplates = “True”
Elseif strError “” then
CopyTemplates = “True”
Else
CopyTemplates = “False”
End If
WScript.Echo “Copy Templates = ” & CopyTemplates
End If