Skip to content

Migrating PHP Graphs to Gweb 2

drauh edited this page Jan 17, 2013 · 1 revision

Table of Contents

Changes

If you are in the process of migrating from an old Ganglia Web installation to Gweb2, there are a few things to note about the new PHP graphs. The best place to double check any questions you have are to review the examples in the included sample_report.php and varnish_report.php.

The main difference is that many of the variables that were explicitly defined as globals are now part of `$conf` (e.g. `$strip_domainname` is now `$conf['strip_domainname']`).

Procedure

To migrate the graphs make sure to:

 # Include `$conf` in the list of globals after the function definition.
 # Change any instances of variables like `$strip_domainname` to `$conf!['strip_domainname']`
 # Change your colors like `$cpu_user_color` to `$conf['cpu_user_color']`
 # Change `$hostname` to `$GLOBALS['hostname']`
 # *Make sure there is no whitespace after the final `?>` in your code!*

Example Code

Here is some Perl you can hack on to do much of this for you `(run as cat oldGraph.php | perl scriptname > newGraph.php)`, use at your own risk:

    # for colors generally
    $line =~ s/\#\$(\w+)/\#\${conf[\'$1\']}/g if $line =~ /\#\$\w+/;
  
    # for EOF, warning if you have > elsewhere
    $line =~ s/\>\s+/\>/;
    print $line;
  }

After you create your new PHP graphs, you will need to apply them to the different hosts and clusters as you like. They will not automatically be applied everywhere as they were in the old ganglia-web.

Troubleshooting

If there is something wrong with your new graph code, you may see what is represented as a broken image in your browser. One helpful way of finding out why is to `Copy Image Location` and paste the URL in your browser bar. Then append `&debug=5` to the end of your URL. This will show you the `rrdtool` command being used to generate your graph. You can copy and paste this to your command line to see if an actual image is being generated.