Packaging zabbix-agent 1.8.1 for Solaris 10

(post moved from old blog)

I had no idea how to make Solaris packages but after trying to squeeze the zabbix agent into boxes via ops center I realised it was time to learn.

Thanks to a couple of websites for info:

How to make a Solaris package (pkg format) and

Adding Service Management Facility (SMF) to Packages

I wouldn't necessarily say this is the correct method or the best method… but it works (ymmv 8-)

The package sets up the zabbix user and a zabbix-agent smf service which is disabled by default. We need to copy /etc/zabbix/zabbix_agentd.conf.sample to zabbix_agentd.conf and edit the hostname and server fields before you can enable the service. The user and service are removed when the package is uninstalled.

One caveat - the package assumes that no zabbix user exists !

So here's how…

Create the following files:

Note you can generate this with the pkgproto command although it seems you will need awk afterwards ;-)

Once these are all created you need to create the software subdirs - these should be:

etc/
etc/zabbix
etc/zabbix/zabbix_agentd.conf.sample
usr/
usr/local
usr/local/bin
usr/local/bin/zabbix_get
usr/local/bin/zabbix_sender
usr/local/share
usr/local/share/man
usr/local/share/man/man1
usr/local/share/man/man1/zabbix_get.1
usr/local/share/man/man1/zabbix_sender.1
usr/local/share/man/man8
usr/local/share/man/man8/zabbix_agentd.8
usr/local/sbin
usr/local/sbin/zabbix_agent
usr/local/sbin/zabbix_agentd

Now you can generate the package with 'make pkg'.

If you want to provision this with ops-center then just create the /etc/zabbix zabbix_agentd.conf from an example one from source or the zabbix website replacing server with your server's ip address and hostname with "^AM^server_hostname^AM^". This can then be updated by a server_hostname macro script that just returns the hostname:

#!/bin/sh
hostname

You can then use ops-center to provision the package and config all in one go - start the smf in a postinstall script you use at setup time or create one just for the job.

There's a lot more to packaging than I have covered here or know (this was a learning exercise) but this at least gives me a nice clean way to install though ops-center.

EDIT: Probably would have helped if I had found the sun guide for application packaging first 8-)

Date: 2010-05-22 Sat

Emacs 24.5.1 (Org mode 8.2.10)