Page 1 of 1

Script to Build Nagios Solaris SMF Service Files for import

Posted: Wed Aug 21, 2019 11:28 am
by luczynj
Hello everyone.

Just a quick question. I have an estate of about 20 Solaris 10/11 servers running SMF (Service Management Facility).

I'd like to monitor every service with individual Nagios services.

We've toyed with the idea of having a single service to monitor SMF on each service, where it would return an OK if all services rae online; it would return a WARNING if any are in maintenance state; it would return a CRITICAL if any are offline. While I would expect most sysadmins would respond the same way regardless of how many services are not online (IE, they would log on and check the general health of the system including all the services).

But my argument is that if we micormanaged our systems down to each individual service having their own configured service on Nagios, that over time we might see a trend with a certain service going into maintenance mode while maybe the free memory was going down. That's just an example, but I would like to have one Nagios service per Solaris SMF.

That being said, has anyone ever written a *NIX script to take the output of the svcs command and building a custom Nagios service .cfg file?

For example, the script would do a loop looking at every availabe sevice...

root@solaris: svcs | grep ntp
online Aug_16 svc:/network/ntp:default

Then from within each service, you could do a svcs -l and get the long listing, including the text you could pop into the Nagios "service_description" field.

Here's the solaris long listing of NTP:

root@solaris: svcs -l ntp
fmri svc:/network/ntp:default
name Network Time Protocol (NTP) Version 4
enabled true
state online
next_state none
state_time Fri Aug 16 09:41:01 2019
logfile /var/svc/log/network-ntp:default.log
restarter svc:/system/svc/restarter:default
contract_id 92
manifest /etc/svc/profile/generic.xml
manifest /lib/svc/manifest/network/ntp.xml
dependency require_any/error svc:/network/service (online)
dependency require_all/error svc:/system/filesystem/minimal (online)
dependency exclude_all/none svc:/network/ptp:default (absent)


The script would build the service definition:

define service {
host_name GMV-OSS-RC-TPOSSMAS
service_description Network Time Protocol (NTP) Version 4
use xiwizard_nrpe_service
check_command check_nrpe_v2!check_ntp....!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
check_freshness 0
event_handler xi_service_event_handler
retain_status_information 1
retain_nonstatus_information 1
notification_interval 15
first_notification_delay 0
notification_period xi_timeperiod_24x7
notification_options w,c,u,r,f,s,
notifications_enabled 1
contacts luczynj,frontline,2ndline
contact_groups NM Support
_xiwizard solaris
register 1
}

After all that copy/pastingi, I probably could've written it already.

Thanks for your support!

Regards,
JL

Re: Script to Build Nagios Solaris SMF Service Files for imp

Posted: Wed Aug 21, 2019 3:55 pm
by mbellerue
If you're looking for someone to write the script for you, that's not really something we can do. But we can certainly help you along.

Like, I would imagine that if the svcs command just nets you a list of all of the services available on the system, then that's the basis for your initial for loop.

Inside of that loop, you run your svcs -l $currentservice, scrape the data you need and build out your API calls there, executing them just before running through the loop once more.

Check out the API docs for how to actually build the hosts and service checks. In Nagios XI just head over to Help -> and look through the links under API Docs.