This is a quick how-to for Opsview users who need to monitor an OpenStack (Essex) Swift installation. As a starting point we’ll perform a ‘front door’ check as this should work no matter what Swift implementation you are using.
Note that I’m using Authentication version 2.0 with Keystone rather than tempauth.
The following assume you already have both Opsview Server and OpenStack Object Storage (Swift) configured and running.
Pre-requisite set up tasks
The machine running the check needs to have a Swift client and an Opsview Agent. If you plan to monitor from a Swift proxy server you should only need the latter; if you plan to execute the checks from your Opsview server, then you’ll need the former.
Installing the Swift client
This relies on having Python installed – grab the source from:
sudo python setup.py install (for both)
Installing the Opsview Agent on Ubuntu
echo "deb http://downloads.opsview.com/opsview-core/latest/apt precise main" > /etc/apt/sources.list.d/opsview-core.list
apt-get install opsview-agent
Obtaining the check
The plugin details are here:
The direct download link:
Place this into /usr/local/nagios/libexec (on the Opsview Agent) and make the file executable (chmod +x check_swift) and owned by nagios (chmod nagios:nagios check_swift).
If you don’t already have the ST_AUTH (tenant), ST_USER and ST_KEY environment variables set, then you may want to modify the check accordingly (as per the following diff):
diff check_swift.orig check_swift
< export OS_AUTH_URL=$OPTARG
> export ST_AUTH=$OPTARG
< export OS_USERNAME=$OPTARG
> export ST_USER=$OPTARG
< export OS_PASSWORD=$OPTARG
> export ST_KEY=$OPTARG
Setting up NRPE
Whilst you could run the check from your Opsview server (if you install the Swift client), it is’d more likely it would be executed on an Opsview Agent via NRPE.
Therefore we need to add a service check command to the NRPE configuration on the Opsview Agent:
echo "command[check_swift]=/usr/local/nagios/libexec/check_swift \$ARG1\$" >> /usr/local/nagios/etc/nrpe_local/override.cfg
Configuring the check
On your Opsview server you’ll need to define a new Service Check, Figure 1 shows a completed example.
If you like to copy & paste, the arguments to check_nrpe are:
-H $HOSTADDRESS$ -c check_swift -a '-V 2 -U admin:admin -A http://127.0.0.1:5000/v2.0/ -K secrete -c container'
Substitute the values as applicable or override them at the host-level.
The check in action
Figure 2 shows the host-level view of the service check (note that it appears to be ignoring the -c container value).
There you go, quick and easy basic monitoring of OpenStack Swift.
If it doesn’t work, first check you can perform an upload using the swift client:
swift -V 2 -U admin:admin -A http://127.0.0.1:5000/v2.0/ -K secrete upload container check_swift
The second test is to verify the Nagios plugin returns a zero exit code:
check_swift -V 2 -U admin:admin -A http://127.0.0.1:5000/v2.0/ -K secrete -c container
Note that the plugin redirects output to /dev/null so you may need to tweak a copy of the script so that you can see the swift error messages if this step fails.
Lastly test NRPE:
check_nrpe -H localhost -c check_swift -a '-V 2 -U admin:admin -A http://127.0.0.1:5000/v2.0/ -K secrete -c container -s 128'