# Upgrade to version 0.6.x

The web-frontend has been completely rewritten and is now based on the PHP MVC framework Kohana. This leads to changed dependencies which must be checked prior to installation.

Note: At first an upgrade is like a new installation. Afterwards some changes should be made which are described further down.

Without specifying any options during `./configure` PNP 0.4.x was installed below an existing Nagios-Installation at `/usr/local/nagios`.

Without specifying any options during `./configure` PNP 0.6.x will be installed in a separate directory at `/usr/local/pnp4nagios`, i.e. it should be viewed as an independent application.

Note: It is sufficient to copy the *.rrd files from the old to the new location. They contain the data The *.xml files are recreated every time new performance data arrives as they contain meta information. The internal structure of the xml files has changed so you wouldn't be able to use them either way.

## Comparison of the structure

Summary of a PNP 0.4.14 installation

    ./configure
    ...
    *** Configuration summary for pnp 0.4.14 05-02-2009 ***

      General Options:
      -------------------------         -------------------
      Nagios user/group:                nagios nagios
      Install directory:                /usr/local/nagios
      HTML Dir:                         /usr/local/nagios/share/pnp
      Config Dir:                       /usr/local/nagios/etc/pnp
      Location of rrdtool binary:       /usr/bin/rrdtool Version 1.3.1
      RRDs Perl Modules:                FOUND (Version 1.3001)
      RRD Files stored in:              /usr/local/nagios/share/perfdata
      process_perfdata.pl Logfile:      /usr/local/nagios/var/perfdata.log
      Perfdata files (NPCD) stored in:  /usr/local/nagios/var/spool/perfdata/

Summary of a PNP 0.6.0 installation

    ./configure
    ...
    *** Configuration summary for pnp4nagios-0.6.0 07-30-2009 ***

      General Options:
      -------------------------         -------------------
      Nagios user/group:                nagios nagios
      Install directory:                /usr/local/pnp4nagios
      HTML Dir:                         /usr/local/pnp4nagios/share
      Config Dir:                       /usr/local/pnp4nagios/etc
      Location of rrdtool binary:       /usr/bin/rrdtool Version 1.3.1
      RRDs Perl Modules:                FOUND (Version 1.3001)
      RRD Files stored in:              /usr/local/pnp4nagios/var/perfdata
      process_perfdata.pl Logfile:      /usr/local/pnp4nagios/var/perfdata.log
      Perfdata files (NPCD) stored in:  /usr/local/pnp4nagios/var/spool

      Web Interface Options:  -------------------------         -------------------
      HTML URL:                         http://localhost/pnp4nagios/
      Apache Config File:               /etc/apache2/conf.d/pnp4nagios.conf

Looking at these lines result in the parameters to be changed and the upgrade strategy.

## Adjustments

The templates of the action_url definitions have changed. Instead of ”/nagios/pnp” the URL should be ”/pnp4nagios” and instead of “index.php” now “graph” will be used.

    define host {
      name       host-pnp
      register   0
      action_url /pnp4nagios/graph?host=$HOSTNAME$
    }

    define service {
      name       srv-pnp
      register   0
      action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
    }

The definitions for the preview popup function are similar

    define host {
       name       host-pnp
       action_url /pnp4nagios/graph?host=$HOSTNAME$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$
       register   0
    }

    define service {
       name       srv-pnp
       action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
       register   0
    }

Attention: It is not an error that the strings in front and after “class” contain only one quote.

Other than described in the 0.4.x documentation these templates can be used for Nagios 2.x and 3.x.

The variables in the files in the templates folder have to be initialised before first use. Example

    $lower = ""

Earlier you were able to append to variables which weren't initialised before first use. Example:

    foreach ($DS as $i) {
        $def[1] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;

Now you have to change that to

    $def[1] = "";
    foreach ($DS as $i) {
        $def[1] .= "DEF:var$i=$rrdfile:$DS[$i]:AVERAGE " ;

Constants in template files don't work anymore, so that they have to be converted to variables.

    define("_WARNRULE", '#FFFF00');

may be changed to

     $WARNRULE = '#FFFF00';

Please keep in mind that all occurrences have to be changed .

## Upgrade scenario using NPCD

1. planning the new setup
2. perform test installation and acquaint oneself with the new system
3. create backup of the old installation
4. install PNP 0.6.x at `/usr/local/pnp4nagios`
5. make install-config
6. make install-webconf
7. reload Apache
8. test Apache-config
   1. call of `/pnp4nagios` has to report an empty perfdata directory
9. create `/usr/local/pnp4nagios/etc/npcd.cfg` from `npcd.cfg-sample`
   1. check paths and adapt changes from 0.4.x if necessary
10. adjust all paths in nagios.cfg to the new PNP installation
11. adjust all paths in the command definitions
12. stop npcd using `/etc/init.d/npcd stop`
13. `make install-init` installs the new init script for npcd
14. `/etc/init.d/nagios stop`
15. copy `/usr/local/nagios/share/perfdata` to `/usr/local/pnp4nagios/var/perfdata`. Attention: check the permissions
16. `/etc/init.d/npcd start`
17. `/etc/init.d/nagios start`