Category Archives: Uncategorized

Times like these

Sometimes you just want to get something ‘easy’ done quickly and look around to find the appropriate tooling to do so. Quickly because done by hand it will take a lifetime, a lifetime I rather spend on different things.

In many cases you`ll find Excel as a perfect tool to quickly evaluate, filter or alter datasets to your liking. Even though Excel offers a bunch of neat little functions that can get allot done, it will clutter up quickly. For instance this example, extract the fully qualified domain name and port from a well formatted URL, for example: https://myweblogichost.domain.ext:7001/.

=MID(B2;(FIND("/"; B2; 1)+2);((FIND("/"; B2; (FIND("/"; B2; 1)+2)))-(FIND("/"; B2; 1)+2)))

Sadly sometimes you need pretty much creativity to mock an function like this up. Most users might never come to a working example and keep tinkering days after end. Its times like these I wonder why Excel doesn’t simply support regular Expressions. Oke, oke, Excel does support Regular Expressions when you enable the correct VBA lib through the developer console.

Why write this? Native support for regular expressions would make our lives so much easier. To give you an example, the function above could have been replaced with:


This little regular expression means: Look for ‘http’ at the ‘^’ start of the string, that might or might not (?) be followed by an ‘s’.  then the string ‘://’ should follow. After that start capturing ‘(‘ any char ‘.’ with one or more ‘+’ repetitions. Stop capturing ‘)’ when you find ‘/’ followed by any char ‘.’ with one or more ‘+’ repetitions. Finally return the captured string (usually done by the function handling Regular Expressions).

If you ask me its readable, understandable and logical. Why Microsoft does not implement this natively in Excel still eludes me.

I really hope Microsoft at one point will implement this.


Fun watch with some information on OMG

The best quote (2:11): “They work with that subcontractor using a shared process, in case of Boeing that is called: working together”

Oracle Enterprise Linux 6.x networking

Lately I got many questions regarding the network configuration of Oracle Enterprise Linux 6 (Red Hat Enterprise Linux 6).
Enough to write a little article about it.

It seems that some of the network configuration was altered in OEL6. The reason as far as I know is the implementation of the NetworkManager daemon. I don’t know why they are using CamelCase for the daemon name, but mind that. Even though the NetworkManager should make the configuration as painless as possible (at least thats what the manual page said), it seems to actually make the configuration more of a pain for some.

Below I will cover some topics in an effort to get you going and remove the pain 🙂

Configuring eth0 for manual operation

  • Step 1: disable the NetworkManager daemon
    service NetworkManager stop
  • Step 2: remove the NetworkManager from Init (start-up)
    chkconfig --level 2345 NetworkManager off
  • Step 3: open the ifcfg-eth0 config file (alter the suffix ‘eth0’ to match the adapter of your choice)
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
  • Step 4: Alter the following to match your environment…
    HWADDR={Your MAC address here}
    #PREFIX=24    [can be used alternativly to NETMASK=]
  • Step 5: Write/close the configuration file (:wq in vi)
  • Step 6: Restart the network service
    service network restart
  • TIP 0: Obviously match the configuration above to match your home network.
  • TIP 1: NetworkManager is not always present in which case you can obviously skip step 1 – 2.
  • TIP 2: There are reports that is actually more stable then PREFIX=xx notation.
    My advice, use NETMASK= which is also better understood by non networking guys.
  • TIP 3: Not sure about the correct NETWORK, NETMASK, BROADCAST or PREFIX settings, give ipcalc a try:
    ipcalc --netmask {IPADDR}
    ipcalc --prefix {IPADDR} {NETMASK}
    ipcalc --broadcast {IPADDR} {NETMASK}
    ipcalc --network {IPADDR} {NETMASK}

Configuring DNS

DNS always seems to be a bugger and a hard one to understand. Do note that DNS is JUST A IP PHONEBOOK. Nothing fancy there. Also there are various ways of configuring DNS. One way is by adding the DNS configuration in the ifcfg-suffix configuration file with the DNS1=ip.ip.ip.ip DNS2=ip.ip.ip.ip keywords. As an effect, the networking service will update the appropriate configuration files. To be frank, I find this to be confusing and do not like duplicate configurations everywhere in my -has to be clean- environment. My advice is to configure the DNS is the appropriate files directly like this…

  • Step 1: Edit the resolve.conf where DNS is configured.
    vi /etc/resolv.conf
  • Step 2: Add or Alter the following to match your environment
    search mydomain.home
  • Step 3: Test to see if name resolution works
    set debug
  • TIP 1: Linux actually tries to find the ip in the /etc/hosts file first. If you know the hostnamename and FQDN to an certain IP and it can be classified as static. Consider using the hostsfile instead of a centralized DNS. This will boost performance if the name is resolved often. If multiple systems use and depend on a machine reference, use centralized DNS in order to lighten the administrative tasks.
    vi /etc/hosts
  • TIP 2: Experiencing slow log on times or slow application performance? A faulty DNS configuration might just be the cause. A quick way to test this is by temp. disabling DNS all together. This can be done by editing the /etc/nsswitch.conf file.
    vi /etc/nsswitch.conf
    • alter the line
      hosts:     files dns
    • to the line
      hosts: files
    • write the file and test if the performance has improved.
  • The reason for this is that DNS is often used to register user logon or session information based on the visitors IP address. Examples are the ssh daemon, ftp servers, webservers, linux logon, etc.


In some case you want linux to use alternative routes to access certain Linux resources. The way to go in these cases are creating routes. In most cases you want these to be presistant in which case ‘route add –‘ wont suffice. In our example we will create two new routes. On describing a route to a specific host, the other describing the route to a specific network. Alter the example to match your needs.

  • STEP 1: Create a new file called static-routes in the /etc/sysconfig/ directory
    vi /etc/sysconfig/static-routes
  • STEP 2: Add the following, obviously matching your specific needs
    any net gw metric 1
    any host gw metric 1
  • STEP 3: Restart the network service
    service network restart
  • TIP 1: SIOCADDRT: No such process means the designated gateway doesnt exsist on any known interface. (typo?)
  • TIP 2: view the route information usint the route command
  • TIP 3: use the ipcalc –prefix {IPADDR} {NETMASK} command to determin the right /prefix for your environment.
  • TIP 4: In older environments the ifup-routes is used, this shscript still exsists in the /etc/sysconfig/network-scripts/ifup-routes

Locate my mac address

The ifcfg-eth# config allows you to configure the specific mac address to guarantee the IP is bound to the right adapter. In virtualized environments this might save you a lot of trouble in the situation where the virtualized domain is altered. On the other hand it might cause trouble when the staticly configured MAC is migrated in virtual environments. Either case, you might want to know the MAC linux sees belonging to an certain adapter. You can find the MAC address in the following location:

 cat /sys/class/net/eth0/address

Obviously you need to alter eth0 in the path to match the adapter you are looking for. Not sure? The change directory to /sys/class/net and perform a list to see all discovered and registered adapters.

IPTables (Linux firewall)

By default IPtables (which is the linux firewall) is enabled. You can view the running configuration by checking the service status like this.

 service iptables status

You can simply turn the firewall off by modifying and applying steps 1-2 of the first configuring eth0 instruction. This will reduce the security of your linux platform significantly. My advice, add the ports you need for your services and let IPtables protect you. The easiest way is by simply editing the iptables configuration file.

 vi /etc/sysconfig/iptables 

Adding a port is as easy as copy/pasting the always present firewall rule that allowes port 22 (ssh). Copy past it and alter the -p (protocol) -dport (destination port) to match your needs. For example, allowing HTTP/HTTPS.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

afterward restart iptables

service iptables restart

TIP: If you are experimenting with IPv6 (then your Instant COOL!), mind that the ipv6 firewall is called ip6tables and the configuration is called the same. The basic iptables doesnt handle ipv6 at all.

TIP: If you are using ipv6 code your IPv4 ip to ease administration. Example:

ipv6: 2001::0192:0168:0010:0001/64
Then route on the nibble of choice.

Additional questions?

Just post it below and maybe ill respond in due time 🙂

Lessons learned :)

Reminder to self…

“Never move too fast”
Its often better to slow down, take a moment, consider all the options, formulate a short term goal, move forward and reflect.

Essence of Business Intelligence?

You can only effectively control the breaks and throttle, when you know the type of car you are driving, type of breaks and throttle and how to handle them, break and throttle effect when you use them, current speed, effective speed limit, the environment you drive the car in, the reason to why you are driving at all….

Oh, you get the point…

Some nice articles to get you going (sadly most are written in Dutch).



networkmapping to sharepoint using VBS.

Some details need allot explaining, so ill just reference to the sources containing the needed information.

First, make sure the Clients WebClient is configured correctly. Configured incorrectly the WebClient will cause headaches. So make sure you read and understand “basic Authentication, and SSL.” Then read this:

Next figure out, what version of windows you are running. There are differences between XP (usually working just fine), Vista, Win7, Win8. Afterward read this:

finally create a script to test your environment:

Dim objNetwork
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "G:", "\\\site\Shared Documents\"
Wscript.Echo "Script completed!"

simple backup (bash) script monitoring webpage

Do you also use mail to “report” back on succesfull bash backup scripts running all over your enterprise? The “Backup” mailbox is flushed each day ending up being deleted instead of being checked?

Well for all people in that situation I have written a very basic but functional “Monitoring” script written in PHP. It is not finished yet (needs refinement) and your free to extend it as you see fit.

What does it look like? (yes it needs to be graphical! )

How does it work?

  • copy the php scripts into an php enable webserver (wamp / apache & php / iis & php )
  • create a directory ‘data’ in the directory where the index.php is located.
  • call the script using any commandline webclient (example using wget (linux))
    Generate an post file containing the post data, this can be done in a script using some creativity 😉
    echo “ok=hostname.domain.ext&msgs=all_backup_messages\n newline seperated” > ./post
    Use wget and the generated post file to call the script.
    wget -q –post-file ./post http://apache_php.hostname.ext/backup/index.php –output-document /dev/null
  • Logon to the backup script to view the state.

Possible calls?
index.php?msgs=[all messages \n is translated to <br> automatically]

Example call accumilated messages \n new line messages \n finished..

The application exists out of following files… 🙂

// Here is the sourcecode needed to get it all working 🙂 //
// Please dont be too harsh, the code NEEDS MORE WORK //
// HINTS? PLZ POST, BASHING move on 🙂 //

Good luck…

// Script by chris, written to track backup scripts over the network...


// Global vars being declared.
$err = false;                   // We start without any errors (duh)
$errmsg = array();              // The error message array is empty
$datadir='./data/';     // Where do we store our reported data?
$view=false;                    // At first we dont want to view the data
// check if any of the required vars was used //
// If no instructions (gets) (registering) where send we simply show the
// recorded data. (reporting)
if(isset($_GET['ok']) || isset($_GET['warn']) || isset($_GET['err']) || isset($_POST['ok']) || isset($_POST['err']) || isset($_POST['warn'])){
        //////// CATCH A POTENTIAL OK ///////////
        if(isset($_POST['ok']) || isset($_GET['ok'])){
                if((strlen($_POST['ok']) > 3 ) || (strlen($_GET['ok']) > 3)){
                        $host['ok'] = (isset($_POST['ok'])) ? $_POST['ok'] : $_GET['ok'];
                        $err = true;
                        $errmsg[] = 'Reported hostname to short!';
                $host['ok'] = false;
        //////// CATCH A POTENTIAL WARN ///////////
        if(isset($_POST['warn']) || isset($_GET['warn'])){
                if((strlen($_POST['warn']) > 3 ) || (strlen($_GET['warn']) > 3)){
                        $host['warn'] = (isset($_POST['warn'])) ? $_POST['warn'] : $_GET['warn'];
                        $err = true;
                        $errmsg[] = 'Reported hostname to short!';
                $host['warn'] = false;
        //////// CATCH A POTENTIAL ERROR ///////////
        if(isset($_POST['err']) || isset($_GET['err'])){
                if((strlen($_POST['err']) > 3 ) || (strlen($_GET['err']) > 3)){
                        $host['ok'] = (isset($_POST['ok'])) ? $_POST['err'] : $_GET['err'];
                        $err = true;
                        $errmsg[] = 'Reported hostname to short!';
                $host['error'] = false;
        //////// VIEW Debugging? ///////////
        if(isset($_GET['debug'])){$debug = true;}else{$debug = false;}
        // if we have no instructions (gets) show the report.
        $view = true;
// CATCH POTENTIAL MESSAGE(S) (intended for the backup log 😉 //
if(isset($_POST['msgs']) || isset($_GET['msgs'])){
        $msgs=(isset($_POST['msgs'])) ? $_POST['msgs'] : $_GET['msgs'];

// Start the functional part 🙂 //
                // Load the HTML header
                // Fetch the files from the data dir
                // If any? //
                if($content = opendir($datadir)){
                        // Global counter
                        $gc = 1;
                        // Read the directory contents
                        while($item = readdir($content)){
                                if(strstr($item, '.bak' )){
                                                // Clear the data array
                                                $data = '';
                                                if($fp = fopen($datadir.$item, 'r')){
                                                        while($line = fgets($fp)){
                                                                $data[] = $line;
                                                echo 'open failed?';
                                        // how much entries does this backup have?
                                        $n = 0;
                                        $n = count($data);
                                        // find the last index
                                        $l = $n - 1;
                                        // restore the data
                                        $entities = str_getcsv_cust($data[0], ';');
                                        $first_backup = $entities[0][0];
                                        $entities = str_getcsv_cust($data[$l], ';');
                                        // Get the current days of year
                                        $cdate = getdate();
                                        // Compare the date of the last registration
                                        // with the current day of year.
                                        $fdate = getdate(strtotime($entities[0][0]));
                                        $diff = $cdate['yday'] - $fdate['yday'];
                                        // Validate entities[3] (reported status) //
                                        if($entities[0]['3'] == 'ok'){$c1="<td bgcolor='green'>{$entities[0]['4']}</td><td bgcolor='green'>{$entities[0]['3']}</td>";
                                        }elseif($entities[0]['3'] == 'err'){$c1="<td bgcolor='yellow'>{$entities[0]['4']}</td><td bgcolor='yellow'>{$entities[0]['3']}</td>";
                                        }else{$c1="<td bgcolor='red'>{$entities[0]['4']}</td><td bgcolor='red'>{$entities[0]['3']}</td>";}
                                        // Validate the date difference //
                                        if($diff > 1){
                                                $c2="<td bgcolor='red'>{$entities[0]['0']}</td>";
                                                $c2="<td bgcolor='green'>{$entities[0]['0']}</td>";
                                        // Convert the backup msg so the \n are converted to a readable message(s)
                                        $bmsg = nl2br($entities[0]['5']);
                                        $bmsg = str_replace('\n', '<br/>', $bmsg);
                                        $bmsg = str_replace('\r', '', $bmsg);
                                        // Print the validated row...
                                        print("<tr><td><div id='links'><a href='#'>$gc<span><table class='tooltip'width='100%' align='right' cellspacing='0'><tr><th>Backup messages</th></tr><tr><td><div align='left' style='padding-left:5px;'>$bmsg<br/><br/></div></td></tr></table></span></a></div></td>

                                        // Up the global counter 🙂
                        print('no backups registered "YET" ;-)');
        // Close the table //
                // We are saving an backup state, register this request! //
                        // Is this host allowed? //
                                // Itterate through a single entry 🙂
                        foreach($host as $k => $v){
                                // Collect some random but usefull information about this registration
                                // Is this host allowed?
                                //if(in_array($v, $allowed_hosts)){
                                // Sometimes array indexes are predefined during script load, so filter these out 🙂 //
                                                // If the file doesnt exist create it 🙂 //
                                                if($fp = fopen($file, 'a')){
                                                        $csv = "$date;$time;$rip;$k;$v;$msgs";
                                                        if(fwrite($fp, $csv)){
                                                                print('true <br>');
                                                // Debugging are we?
                                                        print("$k > $v <br>\r\n");
                                //      print($_GET['ok']);
                                //      die('your host isnt allowed in the allowed_hosts yet!');
                        die('invalid instruction received!');
#if (!function_exists('str_getcsv')) {
    function str_getcsv_cust($input, $delimiter = ',', $enclosure = '"', $escape = '\\', $eol = '\n') {
        if (is_string($input) && !empty($input)) {
            $output = array();
            $tmp    = preg_split("/".$eol."/",$input);
            if (is_array($tmp) && !empty($tmp)) {
                while (list($line_num, $line) = each($tmp)) {
                    if (preg_match("/".$escape.$enclosure."/",$line)) {
                        while ($strlen = strlen($line)) {
                            $pos_delimiter       = strpos($line,$delimiter);
                            $pos_enclosure_start = strpos($line,$enclosure);
                            if (
                                is_int($pos_delimiter) && is_int($pos_enclosure_start)
                                && ($pos_enclosure_start < $pos_delimiter)
                                ) {
                                $enclosed_str = substr($line,1);
                                $pos_enclosure_end = strpos($enclosed_str,$enclosure);
                                $enclosed_str = substr($enclosed_str,0,$pos_enclosure_end);
                                $output[$line_num][] = $enclosed_str;
                                $offset = $pos_enclosure_end+3;
                            } else {
                                if (empty($pos_delimiter) && empty($pos_enclosure_start)) {
                                    $output[$line_num][] = substr($line,0);
                                    $offset = strlen($line);
                                } else {
                                    $output[$line_num][] = substr($line,0,$pos_delimiter);
                                    $offset = (
                                                && ($pos_enclosure_start < $pos_delimiter)
                            $line = substr($line,$offset);
                    } else {
                        $line = preg_split("/".$delimiter."/",$line);

                         * Validating against pesky extra line breaks creating false rows.
                        if (is_array($line) && !empty($line[0])) {
                            $output[$line_num] = $line;
                return $output;
            } else {
                return false;
        } else {
            return false;

// File for the view html

<!doctype html>
                <meta http-equiv="refresh" content="30">
                <meta http-equiv="X-UA-Compatible" content="IE=8">
                <meta http-equiv="content-type" content="text/html; charset=UTF-8">
                <title>Backup status</title>

                        border-top:1px solid #000;
                        border-right:1px solid #000;

                        table th{
                        border-left:1px solid #000;
                        border-bottom:1px solid #000;

                        table td{
                        border-left:1px solid #000;
                        border-bottom:1px solid #000;



                        div#links div{

                        div#links a:hover span {display: block;
                                position: absolute;
                                top: 0px;
                                left: 50px;
                                width: 700px;
                                padding: 5px;
                                margin: 10px;
                                z-index: 100;
                                color: #222;
                                background: #EEE;
                                font: 10px Verdana, sans-serif;
                                text-align: center;
                                border: 1px solid #000;

                        div#links a span {display: none;}

                        table tr:hover{


                        .tooltip table td{

// Start the Backup list
// Create a nice table
        <table cellspacing="0" cellpadding="2" width="90%">
        <tr><td colspan="7"><p>insert a new backup by calling this script using the following url<br>
           '.$_SERVER['PHP_SELF'].'?{ok|err|warn}={hostname}&msgs={backup log \n seperated}<br/><br />
           download an example bash script <a href="/backup/download/">here<a/> </p></td></tr>
                <th>Date Last</th>
                <th>Time Last</th>
                <th>Date First Ever</th>
                <th># in file</th>


Linux Filesystems what to know?

Here are some things that might help you out 🙂
There is much more to know about linux filessytems, but this might be a good start 🙂

hope this helps 🙂

# Some commands, they might come in handy 😉

df		        report file system disk space usage
df -h		        use the -h switch to display MBs instead of blocks.
df -i   	        show the free Inodes per file system
du		        estimate file space usage
du {file} -h	        use the -h switch to make the stats human readable.
tune2fs		adjust tunable filesystem parameters on ext2/3 filesystems.
tune2fs -l 	        show the actual filesystem superblock data {dev} should contain a SB.
e2label		Change the label on an ext2/3 filesystem
mkfs		        Build a linux file system
mke2fs		Build a Ext2 file system
mkisofs		Build a iso file system
mkudffs		Build a UDF file system
mkswap		Build a Swap file system
mkdosfs		Build a FAT File system
mkfs.vfat	        --
mkfs.msdos	        --
mount		Mount a linux filesystem
umount		Unmount a linux filesystem
swapon		Enable/disable devices and files for paging and swapping
swapoff		--
fsck		        Check a linux filesystem. (USE WITH CAUTION and RTFM FIRST!)
partprobe		inform the OS of partition table changes or list partitions on a device
parted		a partition manipulation program. A very strong but dangerious tool.

Linux devices
Next to these commands there is more to know about the linux filesystem. Most important aspect to know is how the fysical disks are made accessible. This is done by a process called mounting. When a linux OS boots it will probe for fysical attached disks and will create devices for each detected disk in the /dev/ directory. In some cases a device module (driver) is needed to be loaded into the kernel in order for it to access and probe the disk.

Depending on the device type a file (device) will be created in the /dev/ directory with a very specifik name. Here are some examples you might encounter in the /dev/ directory.

First MFM, RLL and IDE hard disk/CD-ROM interface
0 = /dev/hda		Master: whole disk (or CD-ROM)
64 = /dev/hdb		Slave: whole disk (or CD-ROM)

SCSI disk devices (0-15)
0 = /dev/sda		First SCSI disk whole disk
16 = /dev/sdb		Second SCSI disk whole disk
32 = /dev/sdc		Third SCSI disk whole disk

IBM iSeries virtual disk
0 = /dev/iseries/vda	First virtual disk, whole disk
8 = /dev/iseries/vdb	Second virtual disk, whole disk

For a full list check this site :)

Linux Logical Volume management (LVM)
Linux also supports software raid. I wont be paying to much attention here because I allways advice people to use hardware raid instead. When you encounter “Volgroup##” inside the fstab you know an LVM group has been created. The LVM can be manipulated and verified using one of the following commands.

lvchange     lvdisplay    lvmchange    lvmsadc      lvreduce     lvresize
lvconvert    lvextend     lvmdiskscan  lvmsar       lvremove     lvs
lvcreate     lvm          lvmdump      lvm.static   lvrename     lvscan

please consult the manual for more details about these commands.

linux creating a filesystem and mounting
When a device is available in the devices directory you can actually start to use the device. One way of doing this is simply using the mount command stating, mount {device} {mountpoint}. But before doing this you need to decide what you want to do with the device. In most cases a filesystem will be created ontop of the device. For this task you can use the mkfs command or use parted to create partitions.

Please readup on the various filesystem types available. Commonly the Ext2 / Ext3 filesystems are used because they offer the best safety and manupilation options (ext3 doesnt support all the manipulation options ext2 supports). The following site is a good starting point when you are looking for more information on the subject.

Other options are mounting the disk without a filesystem in place a so called raw device, or use the device as swap space using swapon/off. Clustered filesystems are also an option but not described in this article.

Once you have decided how to use the disk, and the disk is available within linux (drivers etc) the next step would be making the disk available after boot. For this the fstab file is used. Simply add a new line with the correct parameters and the disk will be mounted at boot.

Some Important Files and their Locations.

/etc/fstab           Static Information about filesystems.  
/etc/mtab           Table of mounted filesystems
/etc/mtab~         Table of mounted filesystems lockfile
/etc/mtab.tmp     Temporary file
/etc/filesystems   A list of filesystems to try

Finaly, some tips while working with fylesystems.

TIP. Test the fstab file using the “mount -a” command before attempting a reboot. Best test is to unmount the disk prior to the mount -a command.

TIP. Also best practise is to modify disks, partitions, perform fsck`s in INIT 1. This will limit the ammount of running deamons dramaticly and will make your filesystem manipulation tasks much easier.

TIP. The mtab file will always list “devices” instead of “labels”. If you are wondering which device is used by a label try consulting the /etc/mtab.

TIP. In the /dev/ directory there might be a /disk/ directory. This directory will allow you to mount devices by the following attributes;

This directory might come in handy when you are not sure what device was created by that usb disk you just plugged in. using the by-path for instance will show you de bus that is used by the various available disks, or by label that will show what label mappings exsist.
Always use the “ls -lart” command here to get the full details.

TIP. Be very carefull using the fsck command, it is well capable of destroying data on your disk if using incorrectly. Always read the manual fist using the manpages (man fsck).

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 ";
                        $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 ";
                        $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:;o=h

This change should fix it for ya.

Grtz, Chris.

sync ntp cron script.

Just a little script to sync the localtime against a ntp server using cron.

# Sync time next to ntp daemon
# Chris 5-2-1010
NTPD=`find /etc/init.d/ -name "ntpd"`;
echo $NTPD;
NTPDATE=`which ntpdate`;
if [ -f $NTPD ]; then
        STDOUT=`$NTPD stop`;
        if [ -f $NTPDATE ]; then
                STDOUT=`$NTPD start`;
                STDOUT=`$NTPD start`;
        exit 1;
exit 0;