BLAH-BLAH > IT > Webserver > Install Observium

Install Observium

How to install Observium on Gentoo
(03.Jul.2011)


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
    • If the package "PEAR-Net_IPv6" does not exist run "pear install pear.php.net/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.