[collectd] Making collection3 compatible with cgi-bin

Chris Kittlitz ckittlitz at gmail.com
Wed May 29 19:08:09 CEST 2013


Hello.

I had a problem recently where the graphs were loading fine on my
development machine, but not on my production machine.

I've narrowed down the problem to the fact that web servers with a cgi-bin
(or cgi) directory will assume everything within that directory is
executable.  Attempts made to access files in that directory from html will
result in those files being executed instead of read.  For example, if
style.css is in the cgi-bin directory, then it will not be correctly read
by the web browser.

The graphing tools in collection3 are all within a single collection3
directory;
$ pwd;ls
/usr/share/doc/collectd-4.9.1/contrib/collection3
bin  etc  lib  README  share

And the index.cgi and htmlcss.cgi reference the css and js files in the
share directory using a relative path.  For example "../share/navigate.js".

When I tried to deploy this on a tomcat server, I was forced to put this in
the cgi directory as follows.
$ pwd
/usr/local/apache-tomcat-7.0.18/webapps/system/WEB-INF/cgi
$ ln -s /usr/share/doc/collectd-4.9.1/contrib/collection3 collectd

However, when I went to access the graphs via firefox, I noticed that the
buttons didn't work.  This was because navigate.js couldn't be loaded, so
all the functions defined in it were undefined.

I found reference to this type of problem online here:
http://www.theadminzone.com/forums/showthread.php?t=6156
and here:
http://forums.jaguarpc.com/open-discussion-chit-chat/13449-external-javascript-file-problem.html


To fix this I did the following.

1. Create another link to collection3 in the webapps directory.
$ pwd
/usr/local/apache-tomcat-7.0.18/webapps
$ ln -s /usr/share/doc/collectd-4.9.1/contrib/collection3 collectd

2. Edit the index.cgi and htmlcss.cgi files to reference
"/collectd/share/..." instead of "../share/...".

The graphs then load normally.

While this works, I dislike having the change the source code because it is
something that will have to be repeated every time we update collectd.

Has anyone else had this problem?  Have you been able to solve it better
than I?

Thanks!!

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20130529/32270480/attachment.html>


More information about the collectd mailing list