[Nagiosplug-checkins] CVS: nagiosplug/lib getloadavg.c,NONE,1.1 getloadavg.m4,NONE,1.1 Makefile.am,1.1,1.2
Ton Voon
tonvoon at users.sourceforge.net
Tue Feb 18 16:46:12 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv8132/lib
Modified Files:
Makefile.am
Added Files:
getloadavg.c getloadavg.m4
Log Message:
Move getloadavg to lib directory. Must run "aclocal -I lib"
--- NEW FILE ---
/* Get the system load averages.
Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995, 1997
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
[...1047 lines suppressed...]
perror ("Error getting load average");
exit (1);
}
if (loads > 0)
printf ("1-minute: %f ", avg[0]);
if (loads > 1)
printf ("5-minute: %f ", avg[1]);
if (loads > 2)
printf ("15-minute: %f ", avg[2]);
if (loads > 0)
putchar ('\n');
if (naptime == 0)
break;
sleep (naptime);
}
exit (0);
}
#endif /* TEST */
--- NEW FILE ---
#serial 9
# A replacement for autoconf's macro by the same name. This version
# accepts an optional argument specifying the name of the $srcdir-relative
# directory in which the file getloadavg.c may be found. It is unusual
# (but justified, imho) that this file is required at ./configure time.
undefine([AC_FUNC_GETLOADAVG])
# AC_FUNC_GETLOADAVG
# ------------------
AC_DEFUN([AC_FUNC_GETLOADAVG],
[ac_have_func=no # yes means we've found a way to get the load average.
AC_CHECK_HEADERS(locale.h unistd.h mach/mach.h fcntl.h)
AC_CHECK_FUNCS(setlocale)
# By default, expect to find getloadavg.c in $srcdir/.
ac_lib_dir_getloadavg=$srcdir
# But if there's an argument, DIR, expect to find getloadavg.c in $srcdir/DIR.
m4_ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
# Make sure getloadavg.c is where it belongs, at ./configure-time.
test -f $ac_lib_dir_getloadavg/getloadavg.c \
|| AC_MSG_ERROR([getloadavg.c is not in $ac_lib_dir_getloadavg])
# FIXME: Add an autoconf-time test, too?
ac_save_LIBS=$LIBS
# Check for getloadavg, but be sure not to touch the cache variable.
(AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
# On HPUX9, an unprivileged user can get load averages through this function.
AC_CHECK_FUNCS(pstat_getdynamic)
# Solaris has libkstat which does not require root.
AC_CHECK_LIB(kstat, kstat_open)
test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
# Some systems with -lutil have (and need) -lkvm as well, some do not.
# On Solaris, -lkvm requires nlist from -lelf, so check that first
# to get the right answer into the cache.
# For kstat on solaris, we need libelf to force the definition of SVR4 below.
if test $ac_have_func = no; then
AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
fi
if test $ac_have_func = no; then
AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
# Check for the 4.4BSD definition of getloadavg.
AC_CHECK_LIB(util, getloadavg,
[LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
fi
if test $ac_have_func = no; then
# There is a commonly available library for RS/6000 AIX.
# Since it is not a standard part of AIX, it might be installed locally.
ac_getloadavg_LIBS=$LIBS
LIBS="-L/usr/local/lib $LIBS"
AC_CHECK_LIB(getloadavg, getloadavg,
[LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
fi
# Make sure it is really in the library, if we think we found it,
# otherwise set up the replacement function.
AC_CHECK_FUNCS(getloadavg, [],
[_AC_LIBOBJ_GETLOADAVG])
# Some definitions of getloadavg require that the program be installed setgid.
AC_CACHE_CHECK(whether getloadavg requires setgid,
ac_cv_func_getloadavg_setgid,
[AC_EGREP_CPP([Yowza Am I SETGID yet],
[#include "$ac_lib_dir_getloadavg/getloadavg.c"
#ifdef LDAV_PRIVILEGED
Yowza Am I SETGID yet
@%:@endif],
ac_cv_func_getloadavg_setgid=yes,
ac_cv_func_getloadavg_setgid=no)])
if test $ac_cv_func_getloadavg_setgid = yes; then
NEED_SETGID=true
AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
[Define if the `getloadavg' function needs to be run setuid
or setgid.])
else
NEED_SETGID=false
fi
AC_SUBST(NEED_SETGID)dnl
if test $ac_cv_func_getloadavg_setgid = yes; then
AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
# If we got an error (system does not support symlinks), try without -L.
test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
ac_cv_group_kmem=`echo $ac_ls_output \
| sed -ne ['s/[ ][ ]*/ /g;
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
/ /s/.* //;p;']`
])
AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
fi
if test "x$ac_save_LIBS" = x; then
GETLOADAVG_LIBS=$LIBS
else
GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
fi
LIBS=$ac_save_LIBS
AC_SUBST(GETLOADAVG_LIBS)dnl
])# AC_FUNC_GETLOADAVG
Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Makefile.am 10 Feb 2003 23:32:39 -0000 1.1
--- Makefile.am 19 Feb 2003 00:45:43 -0000 1.2
***************
*** 1,9 ****
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libnagiosplug.a
noinst_HEADERS = getopt.h
! libnagiosplug_a_SOURCES = getopt.c getopt1.c
INCLUDES = -I$(srcdir)
--- 1,11 ----
## Process this file with automake to produce Makefile.in
+ EXTRA_DIST = getloadavg.m4
+
noinst_LIBRARIES = libnagiosplug.a
noinst_HEADERS = getopt.h
! libnagiosplug_a_SOURCES = getopt.c getopt1.c getloadavg.c
INCLUDES = -I$(srcdir)
More information about the Commits
mailing list