Friday, April 13, 2007

OpenSolaris - an SMF Package for Nagios

(Updated to be zone-friendly)

While playing around with Nagios, I figured it was time to learn how SMF
works a bit more, and brush on Solaris packaging while I was at it.

I've created an SMF package for Nagios, which I hope others find useful.

The first pass at this allows you to specify the location where nagios is install (detecting /usr/local/nagios is the default action).

In addition, you can specify the username and group that nagios is launched by.

Download:

Without further ado: GTnagios-smf-1.1.pkg.gz

Version 1.1 will create the startup files in /opt/GTnagios-smf, which can be installed in a zone by itself, or made globally available (pkgadd -G).

The first version (if you dont require zones) can be used GTnagios-smf-1.0.pkg.gz Zones are useful, so I'm updating the SMF packages I've written to adhere to their rules.

Manual Installation
Decompress:
# gunzip GTnagios-smf-1.1.pkg.gz
Add the Package:
# pkgadd -d GTnagios-smf-1.1.pkg
Verify SMF sees it:
# svcs nagios
Startup nagios:
# svcadm enable nagios
Check logs:
# tail -f /var/svc/log/network-nagios\:default.log

Automated Install

Automated installs are common, here's how to automate pkgadd.

Create a response file like this gtresponse.cf:
NAGIOS_HOME=/usr/local/nagios
NAGIOS_USER=nagios
NAGIOS_GROUP=nagios
Run pkgadd using response file:
# echo y | pkgadd -r gtresponse.cf -d GTnagios-smf-1.1.pkg GTnagios-smf

I'll publish the "how to make an smf package installer" soon as well.

Cheers

Brian

3 comments:

TommyTheKid said...

# pkgadd -d GTnagios-smf.pkg

The following packages are available:
1 GTnagios-smf SMF files for Nagios
(all) 1.0

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: 1

Processing package instance *GTnagios-smf* from */var/tmp/GTnagios-smf.pkg*

SMF files for Nagios(all) 1.0
GibbonTech (www.gibbontech.com) 2007
Nagios installation not detected in /usr/local/nagios
Enter path to Nagios Installation:
/opt/nagios
Nagios verified at /opt/nagios
Enter username for nagios [nagios]:

Enter group for nagios [nagios]:

Using */* as the package base directory.
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of *GTnagios-smf* [y,n,?] y

Installing SMF files for Nagios as *GTnagios-smf*

## Installing part 1 of 1.
/lib/svc/method/svc-nagios
pkgadd: ERROR: unable to open */lib/svc/method/svc-nagios* for writing: (30) Read-only file system
/var/svc/manifest/network/nagios.xml
[ verifying class *none* ]
ERROR: attribute verification of */lib/svc/method/svc-nagios* failed
pathname does not exist
## Executing postinstall script.
NAGIOS_HOME set to /opt/nagios
NAGIOS_USER set to nagios
NAGIOS_GROUP set to nagios

Installation of *GTnagios-smf* partially failed.


You should not be sticking this into /lib, on a "zones" server /lib is read-only, I believe the correct location is inside of the application delivery directory, which in my case, that would be /opt/nagios/SOMETHING probably? I am sure I can hack the file out of the package stream and put it somewhere else, but you may consider releasing an update :)

Tommy

Brian Gann said...

You're absolutely right :)

I'll make an update asap.

Thanks!

Brian

Brian Gann said...

New package version 1.1 will work with zones. I created a "small-zone" and tested installing just to it, and also with -G option to have a global install. Both seem to work fine.