My Zenoss Development Environment – Part 1

Over the past 18 months the developers at Zenoss have used a variety of development environments and methods to productively work with Zenoss, but there are a lot of best practices that have emerged out of this diversity.

I develop Zenoss primarily on Mac OS X, with some work done on Ubuntu when necessary. I normally use Eclipse as my development editor, although I’ll often just use vim when doing quick changes or bug fixes. In either case, careful setup of the Zenoss environment is key to being able to productively work with both the new development version and with the shipping versions that require maintenance.

The environment you get by default when you check out the source version of Zenoss from the source repository, or from a source tarball, is not necessarily setup in the best way to develop productively using tools like Eclipse.

The rest of this post will document how both my Mac OS X and Ubuntu environments are initially configured so that a working source Zenoss installation is realized.

Mac OS X Prerequisites

These prerequisite instructions assume Mac OS X 10.5 Leopard; 10.6 Snow Leopard will not be able to compile Zenoss’s third-party dependencies, so an additional work-around is required for that platform until Zenoss moves to Python 2.6.

  1. Install Xcode. Why? Installs the GNU C/C++ compiler and other command-line development tools needed to build dependencies used by Zenoss.
  2. Install Universal Subversion 1.6.x from CollabNet Community.Why? Leopard only comes with Subversion 1.4.x. This version is not compatible with the Subclipse plug-in for Eclipse that will be used later. In order to be able to use both the command-line and Eclipse Subversion versions simultaneously on the same checked our source, the release of subversion should match. This installation will place the Subversion binaries in /opt/subversion and should automatically add it to your PATH.
  3. Install MySQL Community Edition 5.1 32-bit. Why? Zenoss needs MySQL for storage of event data.

Ubuntu Prerequisites

These prerequisite instructions assume Ubuntu 9.04 32-bit Desktop Edition. Installing the server edition or one with different options may require additional prerequisites to be installed.

  1. Install Subversion. Why? Working with the Zenoss product in source form requires Subversion to access the source repositories (it is also possible to build directly from a source tarball, but this is not discussed here).
    sudo apt-get -y install subversion
  2. Install MySQL. Why? Zenoss needs MySQL for storage of event data.
    sudo apt-get -y install mysql-client mysql-server libmysqlclient15-dev
  3. Install additional development environment tools. Why? Zenoss third-party dependencies require several binaries to be built from source.
    sudo apt-get -y install patch make vim gcc g++ autoconf
  4. Install SNMP support. Why? Zenoss requires SNMP libraries for monitoring, and having a local SNMP agent is useful for testing.
    sudo apt-get -y install libsnmp-base snmp snmpd
  5. Install Liberation TrueType fonts. Why? Graphs generated by RRDtool will not contain the correct glyphs without this font package.
    sudo apt-get -y install ttf-liberation

Environment Configuration

Configuring Eclipse will require determining where you want to work with your Zenoss installation, and installing Eclipse plug-ins to provide the features required for Python and Subversion support.

  1. Create your Zenoss root directory:
    mkdir $HOME/zenoss
  2. Create and run a setup.sh script that will configure needed environment variables for zenoss. This script can be started from your log in profile if desired.
    cd $HOME/zenoss
    cat > zenoss-config.sh <<EOF
    ZENHOME=$HOME/zenoss/zenhome
    PYTHONPATH=$ZENHOME/lib/python
    PATH=\$ZENHOME/bin:\$PATH
    export ZENHOME PYTHONPATH PATH
    EOF
    chmod +x zenoss-config.sh
    . zenoss-config.sh
    mkdir $ZENHOME
  3. Checkout the Zenoss source installation tree. Why? This tree is used to bootstrap the installation from the source repository and create a running Zenoss installation. We’ll need this before we modify it to fit the needs of our development environment.
    svn co http://dev.zenoss.org/svn/trunk/inst inst
  4. Run the installation script to checkout, compile, and configure a zenoss environment. If you need to customize your MySQL configuration at all do not use the --no-prompt argument.
    cd inst
    ./install.sh --no-prompt
  5. Modify the zensocket file to be setuid root. Why? Some of the Zenoss daemons use a privileged port and making the file owned by root and accessible by the Zenoss user allows the daemons to be run as a non-priviledged user but still use the privileged port.
    sudo chown root:`id -g` $ZENHOME/bin/zensocket
    sudo chmod 04750 $ZENHOME/bin/zensocket

At this point, you should have running zeo and zope processes and be able to log on to the local Zenoss instance. Your Zenoss root directory should look similar to the following:
zenoss workspace

Next…

In Part 2 of this series, we’ll download and configure the Eclipse IDE.

Published by

chadwick

Chad is a software developer from the Houston, Texas, USA. He's been working in the software industry since the 1980s and presently works for Alert Logic, a provider of managed security-as-a-service solutions for the Cloud. He spends way too much time bicycling or playing with cars.

11 thoughts on “My Zenoss Development Environment – Part 1”

  1. Thank you for this post. Do you have the actual workaround mentioned here, for building Zenoss on Snow Leopard?

  2. One of our developers came up with a work-around that uses the stack installer to provide the binaries and then you can customize that to make a development environment out of it, as described below:

    1. Download the latest BitRock stack (core) from http://www.zenoss.com such as http://downloads.sourceforge.net/zenoss/zenoss-stack-2.5.2.app.tar.gz
    2. Install it to, say, /Users/ian/zenoss. Unless your name is ian, I suggest you do not copy/paste this path.
    3. Don’t launch it yet
    4. Shut down the mysql daemon that was started by the installer:

    $ ps aux | grep $ZENDIR/mysql | awk ‘{print $2}’ | sudo xargs kill

    5. Run this:

    $ export ZENDIR=/Users/ian/zenoss
    $ export ZENUSR=ian # Again, probably not a copy/paste candidate here
    $ sudo chown -R $ZENUSR $ZENDIR/mysql/data/events
    $ find $ZENDIR -user zenoss | sudo xargs chown $ZENUSR:staff
    $ find $ZENDIR/mysql -user root -o -user _mysql | sudo xargs chown $ZENUSR

    6. Assuming you have a checkout of Zenoss trunk in ~/src/core, do:

    $ rm -rf $ZENDIR/zenoss/Products && ln -s ~/src/core/Products $ZENDIR/zenoss/Products

    7. Edit ~/.bashrc (or ~/.profile, if .bashrc isn’t sourced in .profile) and add:

    export PATH=$PATH:/Users/ian/zenoss/zenoss/bin

    To make life a little easier, can also add:

    export ZENHOME=/Users/ian/zenoss/zenoss
    alias cdp=cd $ZENHOME/Products
    alias cdz=cd $ZENHOME
    alias zpy=$ZENHOME/bin/python

    8. Make a few changes to $ZENHOME/etc/zope.conf. Find “effective-user zenoss” (line 153) and change it to:

    effective-user ian

    Then find “# debug-mode on” (line 138) and uncomment it.

    9. Get mysql into your path:

    $ ln -s $ZENDIR/mysql/scripts/ctl.sh $ZENDIR/zenoss/bin/zenmysqld
    $ ln -s $ZENDIR/mysql/bin/mysql $ZENDIR/zenoss/bin/zenmysql

    C’est ├ža. Should now be able to start up mysql:

    $ zenmysqld start

    Then ZEO, and run Zope in the foreground with debug output:

    $ zeoctl start
    $ runzope

  3. Fabulous, thank you. In general, I appreciate Apple’s innovation, and how willing they are to depart from the past (sacrificing backwards compatibility) in order to move technology forward. However, this isn’t one of those times… : )

  4. @Matthew For reference, we’re working on a native build for Snow Leopard and the trunk version of Zenoss right now. It’s using Python 2.6 so the build issues are going away… real soon now.

  5. So this is not running as user ‘zenoss’ but your usual login?

    Do you maintain environments for multiple Zenoss versions/instances? e.g. for sustaining/backports? How do you deal with mysql if so?

  6. Yep, everything in my dev environment is always being run as my local user. I usually maintain a trunk version and two older versions in separate directories for support. For the MySQL database, I just name the database something like events25 or events24 to keep them separate from one another.

  7. I also had to install mysql-devel (RHEL 5.5).

    So I did the build/install as described above but it defaulted to username ‘zenoss’; it looks like we might need to patch build-functions.sh. I was trying to figure out how to recover from that without doing another hour-long build, but I have up and hardcoded my username in build-functions.sh and install-functions.sh.

  8. So I’m not sure what steps I missed, but I ended up with an install with only Zenoss components in $ZENHOME/Products, and I had to execute a separate step to check that directory out from svn and then re-run part of the post-install config process. I don’t know if this happened because I was installing as a nonstandard user into a nonstandard place, or there are some steps missing from the build-from-svn process. I suspect the latter, actually.

  9. So are you building from source, and are you using trunk or another version like 2.4.x or 2.5.x?

    Trunk source builds are a little funky right now and are under great-flux as we move to the new version of Python and Zope…

Leave a Reply

Your email address will not be published. Required fields are marked *