Setting up Scripts August 14, 2010
Everything in the post below, except for verifying database access, can be completed by the noc-install-upgrade.sh script. See the post Install/Upgrade Scripts for more information.
All the scripts on this site rely on a common configuration so they can find the resources they need. They are designed to be run on the same system as OpenNMS. If you’ve already installed OpenNMS then you should be able to follow the steps below and be ready to run the scripts. A future post will talk about setting up CGIs and SHTML pages which require the Apache web server to be installed.
In some organizations, network monitoring comes under a function called “Network Operations Center”. That’s why the NOC acronym is used below.
NOCBASE Directory
Create a NOCBASE directory with bin and functions sub-directories. I suggest /opt/noc as shown below. Future posts will add other directories under NOCBASE.
NOCBASE=/opt/noc mkdir $NOCBASE mkdir $NOCBASE/bin mkdir $NOCBASE/functions chmod -R a+rx /opt/noc
You may want to add $NOCBASE/bin to your shells PATH. I don’t bother since I’m not running these scripts more than a few times per week. Most of the heavily used scripts are run by the web server or cron jobs.
Functions File
Download and save the base.func file to $NOCBASE/functions/base.func. These functions will be used by most of the scripts.
cd $NOCBASE/functions/ wget http://opennms.dougbakewell.ca/downloads/functions/base.func
NOC Config File
Create the file /etc/noc.conf with the following contents. Change the values of NOCBASE and OPENNMSBASE to match your environment.
NOCBASE=/opt/noc #OpenNMS is normally in /opt/opennms or /usr/share/opennms OPENNMSBASE=/opt/opennms #The next loop adds the NOC script functions into the shell environment. for f in $NOCBASE/functions/* ; do source $f done
Verify Database Access
Ensure all users who will be running the scripts can access the opennms database. If you used the default setup for OpenNMS then this should work without any changes. The following commands should run without any errors and return the number of nodes in your opennms database:
/bin/bash source /etc/noc.conf sql "select count(*) from node;"
If the sql command produced an error you will need to modify the database configuration or the psql command in the file $NOCBASE/functions/base.func until it works. See the OpenNMS install documentation to ensure your database is configured correctly.
Leave a Reply