New Solaris features: How to monitor SMF services via mail?
It’s a small feature compared to other additions to Solaris, however already i got the first questions how to configure it: the capability of the Service Management Facility to send mails when a state transitions occur.
Some theory
The capability to send notifications in case of service transitions is just a part of the capabilities of this feature. At first the feature can’t only send mails, you can send SNMP traps as well. Additionally the feature isn’t just able to send mails or SNMP traps in case of service state transitions, you can also configure the system to send mail in case of problems detected by the Fault Management Architecture at the hardware. But both is stuff for different articles. In it’s lifetime a service goes trough a number of states. From being disabled up to up-and-running. You will find a description of the states in my tutorial about SMF. The description of the states is located almost at at the end of part 2. The notification frameworks adds mechanisms to enable SMF to tell the outside world, when a services transitions away from one state or into a state. So number of such transitions are monitored by the notification framework:
|
|
Installation
The demon needed to send this mail isn’t in the default installation. So you have to install the package pkg install service/fault-management/smtp-notify
in addition to your basic system:
Now you can enable the daemon by enabling the service controlling it.
Afterwards you should see an the smtp-notify
via ps
Now let’s configure the notifications:
I will use the Apache service to demonstrate the functionality, because it’s extremely easy to send the service into maintenance mode.
To force it into maintainance mode i just added a SNAFU
at the beginning of the file /etc/apache2/2.2/httpd.conf
and restarted the service with
Let’s check the situation. The apache-22
service has transitioned into the maintainance mode:
When you check your mail you will find a mail:
Managing notifications
When you want to know what notification are already configured for a service, you can use the listnotify
subcommand of svccfg
.
When you want to stop notifications, you can use the delnotify
subcommand.
Notifications for a single service
When you don’t want to activate notifications for all services, you can just activate it service by service:
root@solaris:/# svccfg -s svc:/network/http:apache22 setnotify from-online mailto:root@localhost root@solaris:/#</code></blockquote> Please note, that the-g
option is missing. When you use the-g
the configuration done insvc:/system/svc/global:default
no matter what service you've declare later on in the command line. Let's check the configuration:
It's important to know, that a service has as well the global as the locally set notifications. Let's assume you've setfrom-maintenance
atsvc:/system/svc/global
and you've setfrom-online
atsvc:/network/http:apache22
. Then the servicesvc:/network/http:apache22
will have both notifications:
When you look at the source for each event, you can see, what's the source of this notification setting.Conclusion
Due to the smtp-notify capability of the Service Management facility it's really easy to give all services managed by SMF the capability to send some kind of notification to the admin.Want to learn more?
man pages
docs.sun.com - manpage smtp-notify - the daemon that sends the mails
docs.sun.com - manpage svccfg - for the setnotify,delnotify,listnotify subcommands
Misc.
PSARC 2009/619 - PSARC case for email notifications in SMF