Monitoring internal SAS disks on Sun servers
Posted on November 30th, 2010
We need to monitor disk health on Sun M4000 machine running Solaris 10. It can be done just fine with smartmontools package.
1. install smartmontools using blastwave package system.
2. check if smart status can be read from disk
bash-3.00# /opt/csw/sbin/smartctl -H /dev/rdsk/c0t0d0s2 smartctl version 5.36 [sparc-sun-solaris2.8] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ SMART Health Status: OK
3. We are going to integrate this check into nagios. So we did a bit of searching and found check_smart.pl plugin. As this plugin was developed with linux in mind we did some corrections and adopted it for Solaris.
4. The plugin uses smartctl, so we need to allow this tool to be run as root while nagios plugin running as nagios user.
We modified Solaris pfexec configuration to run smartctl as root
Create profile for nagios.
file: /etc/security/prof_attr
Nagios:::Nagios Profile:
file: /etc/security/exec_attr
Modify execution attributes
Nagios:suser:cmd:::/opt/csw/sbin/smartctl:uid=0;gid=0;euid=0
Assign Nagios profile to nagios user
usermod -P Nagios nagios
Check it out
bash-3.00# su - nagios Sun Microsystems Inc. SunOS 5.10 Generic January 2005 $ bash bash-3.00$ pfexec /opt/csw/sbin/smartctl -H /dev/rdsk/c0t0d0s2 smartctl version 5.36 [sparc-sun-solaris2.8] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ SMART Health Status: OK
5. Ok, next we modify linux firiendly plugin to run pfexec smartctl instead of sudo.
6. modify nrpe.cfg
command[check_rootdisk]=/usr/local/nagios/libexec/check_smart.pl -e -d /dev/rdsk/c0t0d0s2
Solaris ready check_smart.pl plugin
Filed under Plugins | No Comments »
Building nagios-core under Solaris 10
Posted on November 3rd, 2010
When doing Solaris 10 build of nagios-core (latest at the time is 3.2.2) I’ve got the error:
"nagios.c", line 653: warning: implicit function declaration: asprintf ld: fatal: file ../common/snprintf.o: open failed: No such file or directory ld: fatal: File processing errors. No output written to nagios *** Error code 1 make: Fatal error: Command failed for target `nagios' Current working directory /soft/free/src/nagios-3.2.2/base *** Error code 1 make: Fatal error: Command failed for target `all'
The solution is to build these .o files manualy
$ cd common $ for file in `ls *.c`; do make `basename $file .c`.o; done $ cd .. $ make
And build process will continue.
Filed under Installation and Upgrade | No Comments »
Solaris 10 smf manifest for nagios server
Posted on September 14th, 2010
After installing nagios from source you may want to create a service manifest to fit in Solaris 10 system of services.
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <service_bundle type="manifest" name="nagios"> <service name="site/nagios" type="service" version="1"> <create_default_instance enabled="true"/> <single_instance/> <dependency name="milestone" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/milestone/multi-user"/> </dependency> <exec_method type="method" name="start" exec="/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg" timeout_seconds="60"/> <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/> <stability value="Unstable"/> <template> <common_name> <loctext xml:lang="C"> nagios monitoring</loctext> </common_name> </template> </service> </service_bundle>
Create a file named nagios.xml and copy it to manifest directory, then enable the service.
cp nagios.xml /var/svc/manifest/site svccfg import /var/svc/manifest/site/nagios.xml svcadm enable nagios
Tags: Nagios, smf, Solaris
Filed under Installation and Upgrade | No Comments »
Upgrading nagios server installation without using packages
Posted on September 14th, 2010
Lets suppose you installed nagios server in the default /usr/local/nagios directory from source and time came to make an upgrade. I’ve tested the procedure with upgrade to nagios core 3.2.2 on Solaris 10 system.
# cd nagios-3.2.2 # ./configure --prefix=/usr/local/nagios --enable-embedded-perl # make install-html install-base install-cgis # cp p1.pl /usr/local/nagios/bin # svcadm disable nagios # svcadm enable nagios
Thats all.
Filed under Installation and Upgrade | No Comments »
Monitoring free memory in Solaris
Posted on August 4th, 2010
This post introduces a little plugin for Nagios NMS you can use to monitor free physical memory in Solaris OS. It should be run locally or by nrpe daemon and depends on kstat Solaris command. You can find brief description and usage from plugin file itself. nagios plugin for Solaris free memory monitoring
Tags: monitoring, Nagios, Solaris
Filed under Plugins, Solaris | No Comments »
Creating Net-SNMP 5.5 package for Solaris 10
Posted on July 6th, 2010
Recently I’ve discovered a bug in net-snmp version 5.4, which I’ve downloaded from sunfreeware. So as there was no most recent version of net-snmp package I’ve decided to build it myself.
First, unpack the source, configure and install it into some location, for example in this case it will be
/soft/build/net-snmp/sparc
gunzip -cd net-snmp-5.5.tar.gz | tar xf - ./configure --prefix=/soft/build/net-snmp/sparc/usr/local \ --execprefix=/soft/build/net-snmp/sparc/usr/local make make install
Create smf starter script
#!/bin/sh . /lib/svc/share/smf_include.sh # Start processes required for snmpd if [ -x /usr/local/sbin/snmpd ]; then /usr/local/sbin/snmpd else echo "snmpd is missing or not executable." exit $SMF_EXIT_ERR_CONFIG fi exit $SMF_EXIT_OK
and place it in there too
mkdir -p /soft/build/net-snmp/sparc/lib/svc/method cp svc-net-snmp /soft/build/net-snmp/sparc/lib/svc/method
Next, create some dir and place these file into it
Makefile depend postinstall preremove
Makefile:
all:
echo "i pkginfo" > prototype
echo "i postinstall" >> prototype
echo "i preremove" >> prototype
echo "i depend" >> prototype
echo PKG=NetSNMP-5-5-sol10-sparc > pkginfo
echo NAME=NetSNMP package >> pkginfo
echo ARCH=sparc >> pkginfo
echo VERSION=5.5 >> pkginfo
echo CATEGORY=system >> pkginfo
echo BASEDIR=/usr/local >> pkginfo
echo PSTAMP=\"`date '+%m/%d/%Y'`\" >> pkginfo
pkgproto /soft/build/net-snmp/sparc=/ >> prototype
pkgmk -o -b / -r /
pkgtrans /var/spool/pkg NetSNMP-5.5-sol10-sparc.pkg NetSNMP-5-5-sol10-sparcdepend:
P SMCossl OpenSSL P SMClgcc346 libgcc
postinstall:
#!/bin/sh
cat >/tmp/snmp.xml<<EOF
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='net-snmp'>
<service name='system/net-snmp' type='service' version='1'>
<create_default_instance enabled='false' />
<single_instance/>
<dependency name='milestone' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/sysconfig' />
</dependency>
<dependency name='filesystem' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
<dependency name='name-services' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/name-services' />
</dependency>
<dependent name='net-snmp_single-user' grouping='optional_all' restart_on='none'>
<service_fmri value='svc:/milestone/multi-user' />
</dependent>
<exec_method type='method' name='start' exec='/lib/svc/method/svc-net-snmp' timeout_seconds='60' />
<exec_method type='method' name='stop' exec=':kill' timeout_seconds='60' />
<exec_method type='method' name='refresh' exec=':kill -HUP' timeout_seconds='60' />
<property_group name='general' type='framework'>
<propval name='action_authorization' type='astring' value='solaris.smf.manage.net-snmp' />
</property_group>
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>net-snmp</loctext>
</common_name>
<documentation>
<manpage title='net-snmp' section='1M' manpath='/usr/share/man' />
</documentation>
</template>
</service>
</service_bundle>
EOF
svccfg import /tmp/snmp.xml
svcadm enable net-snmp
rm /tmp/snmp.xmlpreremove:
svcadm disable -s net-snmp svccfg delete net-snmp
Next, make the package.
Filed under Nagios, Packages | No Comments »