Deploy of Nagios Core 4.1.1 on Solaris 10

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
giorgiom92
Posts: 3
Joined: Tue Jul 26, 2016 12:59 pm

Deploy of Nagios Core 4.1.1 on Solaris 10

Post by giorgiom92 »

Hey guys!

I'm trying to deploy nagios core 4.1.1 on a Solaris s10_u11wos_24a SPARC.
and i had tooooons of problems by now, the one is bothering me right now is:

when i try to execute "/etc/init.d/nagios start" i get the following output "/etc/init.d/nagios: syntax error at line 87: `TMPFILE=$' unexpected"...

the script im using is this one:
"processname: nagios
# File : nagios
#
# Author : Jorge Sanchez Aymar (jsanchez@lanchile.cl)
#
# Changelog :
#
# 1999-07-09 Karl DeBisschop <kdebisschop@infoplease.com>
# - setup for autoconf
# - add reload function
# 1999-08-06 Ethan Galstad <egalstad@nagios.org>
# - Added configuration info for use with RedHat's chkconfig tool
# per Fran Boon's suggestion
# 1999-08-13 Jim Popovitch <jimpop@rocketship.com>
# - added variable for nagios/var directory
# - cd into nagios/var directory before creating tmp files on startup
# 1999-08-16 Ethan Galstad <egalstad@nagios.org>
# - Added test for rc.d directory as suggested by Karl DeBisschop
# 2000-07-23 Karl DeBisschop <kdebisschop@users.sourceforge.net>
# - Clean out redhat macros and other dependencies
# 2003-01-11 Ethan Galstad <egalstad@nagios.org>
# - Updated su syntax (Gary Miller)
#
# Description: Starts and stops the Nagios monitor
# used to provide network services status.
#
### BEGIN INIT INFO
# Provides: nagios
# Required-Start: $local_fs $syslog $network
# Required-Stop: $local_fs $syslog $network
# Short-Description: Starts and stops the Nagios monitoring server
# Description: Starts and stops the Nagios monitoring server
### END INIT INFO

# Our install-time configuration.
prefix=/usr/local/nagios
exec_prefix=${prefix}
NagiosBin=${exec_prefix}/bin/nagios
NagiosCfgFile=${prefix}/etc/nagios.cfg
NagiosCfgtestFile=${prefix}/var/nagios.configtest
NagiosStatusFile=${prefix}/var/status.dat
NagiosRetentionFile=${prefix}/var/retention.dat
NagiosCommandFile=${prefix}/var/rw/nagios.cmd
NagiosVarDir=${prefix}/var
NagiosRunFile=${prefix}/var/nagios.lock
NagiosLockDir=/var/lock/subsys
NagiosLockFile=nagios
NagiosCGIDir=${exec_prefix}/sbin
NagiosUser=nagios
NagiosGroup=nagios
checkconfig="true"

# Source function library
# Some *nix do not have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi

# Load any extra environment variables for Nagios and its plugins.
if test -f /etc/sysconfig/nagios; then
. /etc/sysconfig/nagios
fi

# Automate addition of RAMDISK based on environment variables
USE_RAMDISK=${USE_RAMDISK:-0}
if test "$USE_RAMDISK" -ne 0 && test "$RAMDISK_SIZE"X != "X"; then
ramdisk=`mount |grep "${RAMDISK_DIR} type tmpfs"`
if [ "$ramdisk"X == "X" ]; then
mkdir -p -m 0755 ${RAMDISK_DIR}
mount -t tmpfs -o size=${RAMDISK_SIZE}m tmpfs ${RAMDISK_DIR}
mkdir -p -m 0755 ${RAMDISK_DIR}/checkresults
chown -R $NagiosUser:$NagiosGroup ${RAMDISK_DIR}
fi
fi


check_config ()
{
TMPFILE=$(mktemp /tmp/.configtest.XXXXXXXX)
$NagiosBin -vp $NagiosCfgFile > "$TMPFILE"
WARN=`grep ^"Total Warnings:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
ERR=`grep ^"Total Errors:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`

if test "$WARN" = "0" && test "${ERR}" = "0"; then
echo "OK - Configuration check verified" > $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown $NagiosUser:$NagiosGroup $NagiosCfgtestFile
/bin/rm "$TMPFILE"
return 0
elif test "${ERR}" = "0"; then
# Write the errors to a file we can have a script watching for.
echo "WARNING: Warnings in config files - see log for details: $NagiosCfgtestFile" > $NagiosCfgtestFile
egrep -i "(^warning|^error)" "$TMPFILE" >> $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown $NagiosUser:$NagiosGroup $NagiosCfgtestFile
/bin/rm "$TMPFILE"
return 0
else
# Write the errors to a file we can have a script watching for.
echo "ERROR: Errors in config files - see log for details: $NagiosCfgtestFile" > $NagiosCfgtestFile
egrep -i "(^warning|^error)" "$TMPFILE" >> $NagiosCfgtestFile
chmod 0644 $NagiosCfgtestFile
chown $NagiosUser:$NagiosGroup $NagiosCfgtestFile
cat "$TMPFILE"
exit 8
fi
}


status_nagios ()
{
if test -x $NagiosCGI/daemonchk.cgi; then
if $NagiosCGI/daemonchk.cgi -l $NagiosRunFile > /dev/null 2>&1; then return 0; fi
else
if ps -p $NagiosPID > /dev/null 2>&1; then return 0; fi
fi

return 1
}

printstatus_nagios ()
{
if status_nagios; then
echo "nagios (pid $NagiosPID) is running..."
else
echo "nagios is not running"
fi
}

killproc_nagios ()
{
kill -s "$1" $NagiosPID
}

pid_nagios ()
{
if test ! -f $NagiosRunFile; then
echo "No lock file found in $NagiosRunFile"
exit 1
fi

NagiosPID=`head -n 1 $NagiosRunFile`
}



# Check that nagios exists.
if [ ! -f $NagiosBin ]; then
echo "Executable file $NagiosBin not found. Exiting."
exit 1
fi

# Check that nagios.cfg exists.
if [ ! -f $NagiosCfgFile ]; then
echo "Configuration file $NagiosCfgFile not found. Exiting."
exit 1
fi

# See how we were called.
case "$1" in

start)
echo -n "Starting nagios:"

if test "$checkconfig" = "true"; then
check_config
# check_config exits on configuration errors.
fi

if test -f $NagiosRunFile; then
NagiosPID=`head -n 1 $NagiosRunFile`
if status_nagios; then
echo " another instance of nagios is already running."
exit 0
fi
fi

touch $NagiosVarDir/nagios.log $NagiosRetentionFile
rm -f $NagiosCommandFile
touch $NagiosRunFile
chown $NagiosUser:$NagiosGroup $NagiosRunFile $NagiosVarDir/nagios.log $NagiosRetentionFile
$NagiosBin -d $NagiosCfgFile
if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi

echo " done."
;;

stop)
echo -n "Stopping nagios:"

pid_nagios
killproc_nagios TERM

# now we have to wait for nagios to exit and remove its
# own NagiosRunFile, otherwise a following "start" could
# happen, and then the exiting nagios will remove the
# new NagiosRunFile, allowing multiple nagios daemons
# to (sooner or later) run - John Sellens
#echo -n 'Waiting for nagios to exit .'
for i in 1 2 3 4 5 6 7 8 9 10 ; do
if status_nagios > /dev/null; then
echo -n '.'
sleep 1
else
break
fi
done
if status_nagios > /dev/null; then
echo ''
echo 'Warning - nagios did not exit in a timely manner'
else
echo ' done.'
fi

rm -f $NagiosStatusFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile
;;

status)
pid_nagios
printstatus_nagios
;;

checkconfig)
if test "$checkconfig" = "true"; then
printf "Running configuration check...\n"
check_config
fi

if [ $? -eq 0 ]; then
echo " OK."
else
echo " CONFIG ERROR! Check your Nagios configuration."
exit 1
fi
;;

restart)
if test "$checkconfig" = "true"; then
printf "Running configuration check...\n"
check_config
fi

$0 stop
$0 start
;;

reload|force-reload)
if test "$checkconfig" = "true"; then
printf "Running configuration check...\n"
check_config
fi

if test ! -f $NagiosRunFile; then
$0 start
else
pid_nagios
if status_nagios > /dev/null; then
printf "Reloading nagios configuration...\n"
killproc_nagios HUP
echo "done"
else
$0 stop
$0 start
fi
fi
;;

configtest)
$NagiosBin -vp $NagiosCfgFile
;;

*)
echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig|configtest}"
exit 1
;;

esac

# End of this script"
i had also tried to start nagios by executing " /etc/rcS.d/S99nagios start", but the result is exactly the same...

Any help would be appreciated =) thank you in advance.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by Box293 »

I'm no Solaris expert but I recently did a bit of testing installing NRPE v3 on Solaris 10 & 11.

One thing I learnt was the commands used to control services, they were:

Code: Select all

svcadm enable nrpe
svcadm disable nrpe
svcadm restart nrpe
svcs nrpe
svcs -xv nrpe
Replace nrpe with nagios.

Does any of this help?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
giorgiom92
Posts: 3
Joined: Tue Jul 26, 2016 12:59 pm

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by giorgiom92 »

Hey man, thanks for your advice but unfortunately no... it does not work with that commands...when i try to use them replacing "nrpe" with "nagios" i get
svcs: Pattern 'nagios' doesn't match any instances
or
svcadm: Pattern 'nagios' doesn't match any instances
=( which means that I'm stuck at the same point.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by tgriep »

I found some instructions for installing Nagios on Solaris 11 which should work for 10. Take a look at it and see if helps you out.
http://www.oracle.com/technetwork/artic ... 79071.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
giorgiom92
Posts: 3
Joined: Tue Jul 26, 2016 12:59 pm

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by giorgiom92 »

tgriep, thanks for your answer but im no solaris expert and the difference between solaris10 and solaris11 commands are abysmal, so im actually pretty lost with the tutorial you posted, and unfortunately i have been searching unsuccessfully for an equivalent solaris 10 tutorial...
i have tried with nagios core 4.0.X, 4.2.0, 3.0.X, 3.X.X and its simply amazing how every time i try to compile or build nagios i get those weird unsolvable issues... and the worst part is that i cant give up installing nagios because it was my bosses assignment for this period =(

(last update with the nagios core 4.2.0 version, when i try to execute the nagios.conf file i get "Bus Error")
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by scottwilkerson »

What do you mean by
giorgiom92 wrote:when i try to execute the nagios.conf
what are you running?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
bwallace
Posts: 1146
Joined: Tue Nov 17, 2015 1:57 pm

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by bwallace »

Here is a good doc on installing the plugins and NRPE on Solaris 10
http://bigunix.blogspot.com/2009/06/ins ... ugins.html

It doesn't cover installing Core but this should be a good reference point (sorry I do not have a Solaris system to test this with at the moment)

Also, keep this doc handy should you run into OpenSSL problems during the procedure
https://blogs.oracle.com/darren/entry/o ... in_solaris

- Hope these help -
Be sure to check out the Knowledgebase for helpful articles and solutions!
ruffy01
Posts: 24
Joined: Wed Mar 23, 2016 4:59 pm

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by ruffy01 »

giorgiom92 wrote:tgriep, thanks for your answer but im no solaris expert and the difference between solaris10 and solaris11 commands are abysmal, so im actually pretty lost with the tutorial you posted, and unfortunately i have been searching unsuccessfully for an equivalent solaris 10 tutorial...
i have tried with nagios core 4.0.X, 4.2.0, 3.0.X, 3.X.X and its simply amazing how every time i try to compile or build nagios i get those weird unsolvable issues... and the worst part is that i cant give up installing nagios because it was my bosses assignment for this period =(

(last update with the nagios core 4.2.0 version, when i try to execute the nagios.conf file i get "Bus Error")
Hi giorgiom.
I attempted Nagios 4.1.1 on Solaris 11 (see here: https://support.nagios.com/forum/viewto ... =7&t=38023) with nothing but major headaches.
Having said that, I am a bit of a *nix newbie.
I wasn't committed to using Solaris, so I thought to use Centos 7 and found it a breeze.
So, if you're boss isn't set firmly on using Solaris, I'd highly recommend Centos. I also found a lot more info on Nagios/Centos than Nagios/Solaris.

Good luck,
Ruffy
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Deploy of Nagios Core 4.1.1 on Solaris 10

Post by rkennedy »

Thanks @ruffy01!

@giorgiom92 - let us know if you have any further questions.
Former Nagios Employee
Locked