Welcome to docs.opsview.com

Setting Up An Opsview Development Server

This page details how to create a single Opsview development server. While you can edit Opsview with a normal install, this allows the overlaying of the SVN files, which means you can easily tell which files have changed.

Assumptions

  • This document is targeted to Opsview version 3.9, but it should work on other versions
  • Assumes installation on a Debian Lenny server, which has a base install. You can use the same techniques for other OSs

New steps

apt-get install opsview-dev
apt-get install opsview-perl
mv /usr/local/nagios/perl /usr/local/opsview_perl
apt-get remove opsview-base opsview-perl
  • Add entry in for nagios user in /etc/sudoers:
nagios ALL=(ALL) NOPASSWD:ALL
  • Switch to nagios user and checkout latest code and then set up the development user profile. The checkout can be in any directory - we use $HOME/opsview-trunk
su - nagios
svn checkout https://secure.opsera.com/svn/opsview/trunk opsview-trunk
opsview-trunk/opsview-core/installer/set_profile -d
  • Create necessary links as the root user:
sudo rm -rf /usr/local/nagios /usr/local/opsview-web
sudo ln -s ~nagios/opsview-trunk/opsview-core /usr/local/nagios
sudo ln -s ~nagios/opsview-trunk/opsview-web /usr/local/opsview-web
  • Log out and back into the nagios account
  • Compile and install code:
cd $HOME/opsview-trunk
make dev
sudo make install-dev
  • Move back the opsview-perl software:
sudo mv /usr/local/opsview_perl /usr/local/nagios/perl

Alternatively, you can get the latest opsview-perl and install that. If you do this, check the build-requires in the debian/control file to install other build dependencies. Ensure you do this as the nagios user.

cd $HOME
svn co https://secure.opsera.com/svn/opsview-perl/trunk opsview-perl-trunk
cd opsview-perl-trunk
make
make install
make dev   # For some extra dev modules
make dev-install
  • Setup CPAN. If you are going to update perl modules, you will need CPAN to pull newer modules down. Run cpan as nagios user and allow it to automatically update information. Then change ~/.cpan/CPAN/MyConfig.pm so that:
'prerequisites_policy' => q[follow],

Change the urllist if desired

  • Create the databases if necessary. We suggest that you rename the databases to names other than the default, to catch any errors where you could hardcode database names in, so vi /usr/local/nagios/etc/opsview.conf:
$db = "opsviewdev";
$odw_db = "odwdev";
$runtime_db = "runtimedev";
$reports_db = "reportsdev";

Then create the databases

cd /usr/local/nagios/bin
./db_mysql -u <user> -p <password>
./db_opsview db_install
./db_runtime db_install
./db_odw db_install
./db_reports db_install
  • Run the post-installation tasks
cd /usr/local/nagios
./bin/rc.opsview gen_config
./installer/postinstall
  • Set up Apache to proxy correctly
sudo cp /usr/local/nagios/installer/apache_proxy.conf /etc/apache2/sites-available/opsview
sudo a2enmod proxy_http
sudo a2ensite opsview
sudo a2dissite default
sudo apache2ctl restart
  • Startup the web app in debug mode:
cd /usr/local/opsview-web
./script/opsview_web_server.pl -d

You should now be able to goto http://server and get to the Opsview login page. The default username is admin, with a password of initial.

Extra suggested steps

As the nagios user

  • Ensure /usr/local/nagios/perl/bin is included on the $PATH:
echo ". /usr/local/nagios/bin/profile" >> $HOME/.bash_profile
  • ln -s $HOME/opsview-trunk/opsview-core/utils/perltidyrc $HOME/.perltidyrc
  • ln -s $HOME/opsview-trunk/opsview-core/utils/vimrc $HOME/.vimrc

You can the run the following within the vi session to amend the formatting of perl files

<Esc>,pt

All perl files should use this standard both before and after changes have been made (i.e. before making any changes ensure the formatting is correct and commit style changes if necessary, then make code changes and ensure the formatting is correct before the final commit). See also the perl style guide.

Using git instead of svn

If you would like to use git instead of subversion, ensure you have git-svn installed and then do the following

If you have not used git before, run

git config --global user.name "<your name>"
git config --global user.email "<your email address>"

Otherwise, continue with the checkout by

git svn clone https://secure.opsera.com/svn/opsview -T trunk -t tags -b branches [--username=<user>]
cd opsview
git checkout -b local_trunk trunk

Then do the same for opsview-perl

git svn clone https://secure.opsera.com/svn/opsview-perl -T trunk -t tags -b branches [--username=<user>]
cd opsview-perl
git checkout -b local_trunk trunk

Continue with the remaining commands above for finishing off your development installation.

Note: the .gitignore files were created from the svn:ignore property by running

git svn create-ignore

If changes to the svn:ignore property are made this should be reflected in the .gitignore files by rerunning this command. Would have been nice to just use .svnignore files and symlink them to .gitignore, but .svnignore files are not honoured currently..

Useful git commands

These are just a few of the useful commands git provides, and is not complete in any way.

  • To pull in recent code changes (this rewinds aswell you changes back to the last fetch, puts in all the changes from the repository and then reruns any local changes over the top)
git svn rebase
  • If conflicts occur, edit the necessary files to resolve them and then
git add <file>
git rebase --continue
  • To send changes back to the repository (if you have commit access)
git svn dcommit
  • To amend the text of the last commit or to add files to it
git add <filename>
git commit --amend
  • To reorder, edit or squash the last x commits (before pushing back into the subversion repository)
git rebase -i HEAD~x

and then

  1. Remove commits by deleting lines.
  2. Reorder commits by reordering lines.
  3. Replace “pick” with “edit” to mark a commit for amending.
  4. Replace “pick” with “squash” to merge a commit with the previous one.
  • To temporarily store away any local changes without committing, use
git stash
  • To bring them back, use
git stash apply
  • To commit changes, use
git add <files>
git commit

and then add in a 40 character description, a blank line, and then further detail about the change.