Segfault > IT > Webserver > Install Observium
First published on: 15.Oct.2011

How to install Observium on Gentoo


EDIT 17.Dec.2013
I started getting disappointed last year when after having upgraded Observium it did not show some of the metrics => as it then happened again after I reinstalled it I decided to look for alternatives.
I then had a look with a friend at all network/system monitoring software we found listed in Wikipedia and ended up opting for "NetXMS".

We have Netxms up and running since ~3 months (1 server on Windows monitoring 3 hosts, 1 server on Linux monitoring 4 hosts) and until now we like it, especially because it's very easy to configure and extremely flexible (but as of version 1.2.8  it was still at an early stage lacking some features and bugfixes - the current version while writing this message is 1.2.10 but so far we did not test any new version).

One thing we absolutely needed was a flexible dashboard to quickly show visually (and with low effort) the gathered metric data to immediately understand the status/trends of our systems, independently if it was the CPU usage or anything else  - unluckily as of version 1.2.8 NetXMS did not have such a functionality => because of this we wrote it on our own one (which we called "NetXMS Simple Dashboard") and published it here (I wrote all pages in a single evening, so things might be weird, but until now I got absolutely no feedback and I don't dare checking what I wrote :oP ).

"NetXMS Simple Dashboard" is nothing fancy and we wrote the SW in a hurry and it's currently in its alpha/concept-stage, but you might still find it useful - let us know here if you have any positive/negative remarks or wish anything special or just want to chat about it.
An example of the graphs that are plotted by "NetXMS Simple Dashboard" is here - the graph is updated through a Cronjob once per day, showing the max MS (probed once every 10 minutes) needed to load one of the pages of this website (www.blah-blah.ch) and of its sister site (research.blah-blah.ch) - the whole management of the metrics and data gathering is done by "NetXMS", and "NetXMS Simple Dashboard" takes care of just managing what to plot and how to do it.

Our current plan is to keep on testing it with real-world problems, see if it is useful and if yes then maintain and potentially improve it.



Here comes the legacy stuff, but I cannot guarantee that these informations are still valid, as I'm not using the SW anymore:

I wanted to monitor the server hosting my website.
After a quick selection I tried out a couple of SW-candidates including Cacti, Munin and Nagios.

As I am the only admin and as I didn't have to monitor a huge network of servers but just one, I did not want to spend too much time understanding the inner workings and how to get things up and running nor how to do smooth SW-upgrades.
In the end I chose Observium, which has a very simple setup, looks good, is very flexible and is not heavyweight - that's all I needed.

As my experiences during the first 5 days with it have been positive I publish here the steps I followed to set it up on a Linux host using the Gentoo distribution hoping to help anybody having troubles with it.


  • Emerge the following packages:
    • subversion
    • net-snmp (check the use-flags, like "diskio"!!!)
    • fping (check afterwards that the permissions of "/usr/sbin/fping" are "-r-s--x--x", so that as well non-root users can execute it)
    • rrdtool
    • graphviz
    • php (version 5.3?)
    • mysql (version 5.1?)
    • apache (version 2) with mod_php (and mod_rewrite?)
    • PEAR-Net_IPv4 (try to run "pear install Net_IPv4" to be sure that you have it otherwise you won't even see the login screen)
    • If the package "PEAR-Net_IPv6" does not exist run "pear install pear.php.net/Net_IPv6" or "pear install Net_IPv6" to install the IPv6 support manually. 
  • Go to what will be Observium's parent directory (change accordingly in all next steps if you choose a different directory):
    cd /var/www/localhost/htdocs
  • Check out the latest release of Observium:
    svn co http://www.observium.org/svn/observer/trunk observium
  • Create two additional directories:
    mkdir /var/www/localhost/htdocs/observium/graphs
    mkdir /var/www/localhost/htdocs/observium/rrd
  • Create Observium's config file:
    cp -iv /var/www/localhost/htdocs/observium/config.php.default /var/www/localhost/htdocs/observium/config.php
  • Edit the configuration file and set the properties of the MySQL DB (DB-name, username, password), the directory where you installed Observium and an extra line describing where the "fping" executable is:
    nano /var/www/localhost/htdocs/observium/config.php

...
#MYCUSTOM ENTRY
$config['fping'] = "/usr/sbin/fping";

### Database config
$config['db_host'] = "localhost";
$config['db_user'] = "observiumuser";
$config['db_pass'] = "observiumpassword";
$config['db_name'] = "observium";

### Locations
$config['install_dir']  = "/var/www/localhost/htdocs/observium";
...

  • Now go into mysql...
    mysql -u root -p
    • ...create the database...
      CREATE DATABASE observium;
    • ...create the user...
      GRANT ALL PRIVILEGES ON observium.* TO 'observiumuser'@'localhost' IDENTIFIED BY 'observiumpassword';
    • ...go into the database...
      CONNECT OBSERVIUM;
    • ...create the initial tables (you might get warnings, but there shouldn't be any errors)...
      SOURCE /var/www/localhost/htdocs/observium/database-schema.sql;
    • ...and quit:
      QUIT;
  • Go to the Observium directory if you aren't yet there...
    cd /var/www/localhost/htdocs/observium
    • ...and update the database schema to the latest version with (check that the files exist):

      scripts/update-sql.php database-update-pre1000.sql
      scripts/update-sql.php database-update-pre1435.sql
      scripts/update-sql.php database-update-pre2245.sql
      scripts/update-sql.php database-update.sql
    • You should get an echo of the SQLs, but no error. 
  • Go to the parent directory and change the ownership of Observium's directory to the one of the user running the webserver:
    cd /var/www/localhost/htdocs
    chown -R apache:apache observium/
  • Create for your webserver a vhost file pointing to the directory "/var/www/localhost/htdocs/observium/html". This very much depends on how you set up your vhost-files (for your Apache, Nginx, Weblogic etc... server).
  • Create an administrator user to be able to login into the web-interface of Observium (set whatever you want for the username and password):
    cd /var/www/localhost/htdocs/observium
    ./adduser.php myadminuser myadminpassword 10

    Ignore all messages concerning undefined indexes.
  • Before continuing you'll have to set up snmp and start it:
    • Go to snmp's config directory...
      cd /etc/snmp/
    • ...and copy the template configuration:
      cp -iv snmpd.conf.example snmpd.conf
  • Edit "snmpd.conf" and set the name of a "community" (whatever you like - but make sure it's complicated like a password because from what I understood it acts as a password), e.g. ...

...
#       sec.name  source          community
com2sec local     localhost       !!!SET_HERE_ANY_NAME1!!!
com2sec mynetwork NETWORK/24      !!!SET_HERE_ANY_NAME1!!!

#### 
...

...and set the location and contact information (your email):

...
# System contact information
#

# It is also possible to set the sysContact and sysLocation system
# variables through the snmpd.conf file.  **PLEASE NOTE** that setting
# the value of these objects here makes these objects READ-ONLY
# (regardless of any access control settings).  Any attempt to set the
# value of an object whose value is given here will fail with an error
# status of notWritable.

syslocation !!!SET_HERE_ANY_LOCATION_DESCR-E_G_USA!!!
...

  • Finally start snmp...
    /etc/init.d/snmpd start
    ...and add the new host to the ones being monitored by Observium (use the same community name you used above):
    cd /var/www/localhost/htdocs/observium
    ./addhost.php localhost !!!SET_HERE_ANY_NAME1!!! v2c
  • Do an initial discovery...
    cd /var/www/localhost/htdocs/observium
    ./discovery.php -h all
    ...and an initial load:
    ./poller.php -h all
  • Finally add the discovery and poll commands to your crontab:
    crontab -e

...
#Run Observium scripts
#Mi     HH      DD      Mo      Day of week
40      23     *       *       *       cd /var/www/localhost/htdocs/observium && ./discovery.php -h all >> /dev/null 2>&1
*/30     *       *       *       *       cd /var/www/localhost/htdocs/observium && ./discovery.php -h new >> /dev/null 2>&1
*/5     *       *       *       *       cd /var/www/localhost/htdocs/observium && ./poller.php -h all >> /dev/null 2>&1
...

If you now access the website you set up you should see that the graphs start to get populated.


Two problems I came accross were:

  • Check that you don't have any file called "config.php" in your user's home directory.
    If you do have one, that one will be used by the cronjobs instead of the "config.php" that resides in the site's home directory. Weird, but that's how it is. This almost made me go insane.
  • Don't use names containing any spaces in the syslocation parameter of "snmpd.conf" - generated for me the weird behaviour that I could see my host listed on the main screen, but could not navigate to the details - the "sub-URLs" were not reachable.
  • If you're using "nginx" as webserver instead of "apache":
    • Have a look at this guide.
    • In Gentoo you'll have to compile nginx with the flag "stub_status" if you want to monitor nginx's status.

A raw nginx config file (copied from here) that should make it possible to run Observium:

  1. server
  2. {
  3. listen 80;
  4. server_name monitoring.blah-blah.ch;
  5.  
  6. access_log /var/log/nginx/monitoring.blah-blah.ch.access_log main;
  7. error_log /var/log/nginx/monitoring.blah-blah.ch.error_log info;
  8.  
  9. root /var/www/localhost/htdocs/monitoring/html;
  10.  
  11. index index.php;
  12.  
  13. location / {
  14. try_files $uri $uri/ @observium;
  15. }
  16.  
  17. location @observium {
  18. rewrite ^(.+)$ /index.php/$1/ last;
  19. }
  20.  
  21. location ~ ^/(.*\.php).*$ {
  22. fastcgi_split_path_info ^(.*\.php)(.*)$;
  23. # or include the equivalent of below:
  24. fastcgi_pass 127.0.0.1:12345;
  25. fastcgi_index index.php;
  26. include fastcgi_params;
  27. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  28.  
  29.  
  30. fastcgi_param PATH_INFO $fastcgi_path_info;
  31. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  32.  
  33. fastcgi_param QUERY_STRING $query_string;
  34. fastcgi_param REQUEST_METHOD $request_method;
  35. fastcgi_param CONTENT_TYPE $content_type;
  36. fastcgi_param CONTENT_LENGTH $content_length;
  37.  
  38. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  39. fastcgi_param REQUEST_URI $request_uri;
  40. fastcgi_param DOCUMENT_URI $document_uri;
  41. fastcgi_param DOCUMENT_ROOT $document_root;
  42. fastcgi_param SERVER_PROTOCOL $server_protocol;
  43.  
  44. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  45. fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
  46.  
  47. fastcgi_param REMOTE_ADDR $remote_addr;
  48. fastcgi_param REMOTE_PORT $remote_port;
  49. fastcgi_param SERVER_ADDR $server_addr;
  50. fastcgi_param SERVER_PORT $server_port;
  51. fastcgi_param SERVER_NAME $server_name;
  52.  
  53. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  54. fastcgi_param REDIRECT_STATUS 200;
  55.  
  56. fastcgi_intercept_errors on;
  57.  
  58. }
  59. location ~ /\.ht {
  60. deny all;
  61. }
  62.  
  63. }
  64.