Index: trunk/servmon/bldenv.sh |
— | — | @@ -1,64 +0,0 @@ |
2 | | -#! /bin/sh |
3 | | -# $Header$ |
4 | | -# |
5 | | -# servmon build env configuration |
6 | | - |
7 | | -die() { |
8 | | - echo $* |
9 | | - exit 1 |
10 | | -} |
11 | | - |
12 | | -usage() { |
13 | | - die "usage: $0 buildfile <debug|prod>" |
14 | | -} |
15 | | - |
16 | | -[ -n "$1" ] || usage |
17 | | -[ -n "$2" ] || usage |
18 | | - |
19 | | -case $2 in |
20 | | - debug) |
21 | | - CFLAGS=-g |
22 | | - ;; |
23 | | - *) |
24 | | - CFLAGS="-O -g" |
25 | | - ;; |
26 | | -esac |
27 | | - |
28 | | -CXXFLAGS=$CFLAGS |
29 | | - |
30 | | -SHELL=${SHELL:-"/bin/sh"} |
31 | | - |
32 | | -unset CC CXX PREFIX |
33 | | -unset LDFLAGS |
34 | | - |
35 | | -. $1 |
36 | | - |
37 | | -CC=${CC:-$cc}; export CC |
38 | | -CXX=${CXX:-$CC}; export CXX |
39 | | -CPPFLAGS="${CPPFLAGS:-$CPPFLAGS}"; export CPPFLAGS |
40 | | -CXXFLAGS=${CXXFLAGS}; export CXXFLAGS |
41 | | -CFLAGS=${CFLAGS}; export CFLAGS |
42 | | -LDFLAGS=${LDFLAGS:-$LDFLAGS}; export LDFLAGS |
43 | | -PREFIX=${PREFIX:-"/opt/wmf"}; export PREFIX |
44 | | -export BOOST |
45 | | - |
46 | | -CPPFLAGS="$CPPFLAGS -Iinclude -I." |
47 | | - |
48 | | -grep=`which grep` |
49 | | -[ -x /usr/xpg4/bin/grep ] && grep=/usr/xpg4/bin/grep |
50 | | -($CXX -V 2>&1 | $grep -q "Sun C++") && CXXFLAGS="$CXXFLAGS -features=iddollar" |
51 | | -($CC -V 2>&1 | $grep -q "Sun C") && CFLAGS="$CFLAGS -features=iddollar" |
52 | | - |
53 | | -echo "Using CC : $CC" |
54 | | -echo " CXX: $CXX" |
55 | | -echo " CPPFLAGS: $CPPFLAGS" |
56 | | -echo " CXXFLAGS: $CXXFLAGS" |
57 | | -echo " CFLAGS: $CFLAGS" |
58 | | -echo " LDFLAGS: $LDFLAGS" |
59 | | -echo "Boost suffix: $BOOST" |
60 | | -echo "Installation prefix: $PREFIX" |
61 | | -echo |
62 | | -echo Starting new shell. |
63 | | -echo |
64 | | - |
65 | | -exec $SHELL |
Index: trunk/servmon/Makefile |
— | — | @@ -1,73 +0,0 @@ |
2 | | -# $Header$ |
3 | | - |
4 | | -SERVMONOBJS= csmplex.o servmon.o smalrm.o smauth.o smcfg.o \ |
5 | | - smirc.o smlog.o smmc.o smmon.o smnet.o smqb.o \ |
6 | | - smstdrt.o smthr.o smtmr.o smtrm.o smutl.o \ |
7 | | - l_memcache.o sminfo.o msgtab.o snmp.o mysql.o \ |
8 | | - server.o |
9 | | - |
10 | | -SYSTATDOBJS= systatd.o |
11 | | -SMLOGMSGOBJS= smlogmsg.o |
12 | | - |
13 | | -all: exec smlogmsg systatd sm-monitor |
14 | | - |
15 | | -exec: $(SERVMONOBJS) bconf/ldflags |
16 | | - $(CXX) $(CXXFLAGS) $(SERVMONOBJS) -o $@ $(LDFLAGS) -lboost_thread$(BOOST) \ |
17 | | - -lboost_regex$(BOOST) -lnetsnmp -lmysqlclient -lssl -lcrypto \ |
18 | | - `cat bconf/ldflags` |
19 | | - |
20 | | -sminfo.o: sminfo.cxx |
21 | | -sminfo.cxx: sminfo.sh |
22 | | - sh sminfo.sh >$@ |
23 | | -msgtab.hxx msgtab.cxx: mktab messages.tab |
24 | | - ./mktab messages.tab |
25 | | -mktab: mktab.cxx |
26 | | - $(CXX) $(CPPFLAGS) $(CXXFLAGS) mktab.cxx -o mktab $(LDFLAGS) |
27 | | -smlogmsg: smlogmsg.c |
28 | | - $(CC) $(CPPFLAGS) $(CFLAGS) smlogmsg.c -o smlogmsg $(LDFLAGS) `cat bconf/ldflags` |
29 | | -systatd: systatd.c |
30 | | - $(CC) $(CPPFLAGS) $(CFLAGS) systatd.c -o systatd $(LDFLAGS) `cat bconf/ldflags` |
31 | | -sm-monitor: monitor.c |
32 | | - $(CC) $(CPPFLAGS) $(CFLAGS) monitor.c -o sm-monitor $(LDFLAGS) `cat bconf/ldflags` -levent |
33 | | - |
34 | | -install: |
35 | | - mkdir -p $(PREFIX)/bin |
36 | | - mkdir -p $(PREFIX)/sbin |
37 | | - mkdir -p $(PREFIX)/lib/servmon |
38 | | - cp systatd sm-monitor $(PREFIX)/sbin |
39 | | - cp smlogmsg $(PREFIX)/bin |
40 | | - cp exec $(PREFIX)/lib/servmon |
41 | | - |
42 | | -.c.o: |
43 | | - $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $< |
44 | | -.cxx.o: |
45 | | - $(CXX) $(CPPFLAGS) $(CFLAGS) -c $< |
46 | | -bconf/prelude.h: |
47 | | - -mkdir bconf |
48 | | - echo '#define PFX "$(PREFIX)"' >bconf/prelude.h |
49 | | -bconf/ldflags: |
50 | | - -mkdir bconf |
51 | | - rm -f $@ |
52 | | - echo "int main() { return 0; }" > test.c |
53 | | - -($(CC) test.c -lsocket -lnsl -o /dev/null && echo -lsocket -lnsl) >>$@ |
54 | | - -($(CC) test.c -lkstat -o /dev/null && echo -lkstat) >>$@ |
55 | | - -($(CC) test.c -lresolv -o /dev/null && echo -lresolv) >>$@ |
56 | | - rm -f test.c |
57 | | -bconf/headers.h: |
58 | | - -mkdir bconf |
59 | | - rm -f $@ |
60 | | - echo '#include <paths.h>' >test.c |
61 | | - -($(CC) -c -o /dev/null test.c && echo '#define T_PATHS 1') >>bconf/headers.h |
62 | | - echo '#include <mntent.h>' >test.c |
63 | | - -($(CC) -c -o /dev/null test.c && echo '#define T_MNTENT 1') >>bconf/headers.h |
64 | | - echo '#include <stdio.h>' >test.c |
65 | | - echo '#include <sys/mnttab.h>' >>test.c |
66 | | - -($(CC) -c -o /dev/null test.c && echo '#define T_SYS_MNTTAB 1') >>bconf/headers.h |
67 | | - rm -f test.c |
68 | | -clean: |
69 | | - rm -rf bconf |
70 | | - rm -f servmon systatd smlogmsg smlogmsg.o systatd.o msgtab.cxx msgtab.hxx $(SERVMONOBJS) |
71 | | -configure: bconf/prelude.h bconf/ldflags bconf/headers.h |
72 | | -.PHONY: install clean |
73 | | -.SUFFIXES: .cxx .c .o |
74 | | -.KEEP_STATE: |
Index: trunk/servmon/buildconfig.sample |
— | — | @@ -22,3 +22,6 @@ |
23 | 23 | # "libboost_signals-gcc-mt-d", set this to the suffix part |
24 | 24 | # (i.e. "-gcc-mt-d"). |
25 | 25 | boostsuffix = '' |
| 26 | + |
| 27 | +libpath = ['/usr/lib/mysql'] |
| 28 | +cpppath = [] |
Index: trunk/servmon/SConstruct |
— | — | @@ -0,0 +1,74 @@ |
| 2 | +# @(#) $Header$ |
| 3 | + |
| 4 | +config = dict() |
| 5 | +execfile('buildconfig', config) |
| 6 | + |
| 7 | +cc = ARGUMENTS.get('cc', config['cc']) |
| 8 | +cxx = ARGUMENTS.get('cxx', config['cxx']) |
| 9 | + |
| 10 | +cflags = ARGUMENTS.get('cflags', config['cflags']) |
| 11 | +cppflags = ARGUMENTS.get('cppflags', config['cppflags']) |
| 12 | +ldflags = ARGUMENTS.get('ldflags', config['ldflags']) |
| 13 | + |
| 14 | +prefix = ARGUMENTS.get('prefix', config['prefix']) |
| 15 | +boostsuffix = ARGUMENTS.get('boostsuffix', config['boostsuffix']) |
| 16 | + |
| 17 | +libpath = ARGUMENTS.get('libpath', config['libpath']) |
| 18 | +cpppath = ARGUMENTS.get('cpppath', config['cpppath']) |
| 19 | + |
| 20 | +import os |
| 21 | +try: |
| 22 | + os.remove('sminfo.cxx') |
| 23 | +except: |
| 24 | + pass |
| 25 | + |
| 26 | +srcs = Split( 'servmon.cxx csmplex.cxx smthr.cxx smnet.cxx smutl.cxx smcfg.cxx smirc.cxx ' |
| 27 | + 'smauth.cxx smtmr.cxx smmon.cxx smqb.cxx smmc.cxx smalrm.cxx l_memcache.c ' |
| 28 | + 'smlog.cxx smstdrt.cxx smtrm.cxx msgtab.cxx') |
| 29 | + |
| 30 | +conflags = [] |
| 31 | +env = Environment(CPPFLAGS = cppflags + ' -DPFX="\\"' + prefix + '\\""', |
| 32 | + CCFLAGS = cflags, |
| 33 | + LDFLAGS = ldflags, |
| 34 | + CC = cc, |
| 35 | + CXX = cxx, |
| 36 | + CPPPATH = cpppath + ['.', 'include'], |
| 37 | + LIBPATH = libpath, |
| 38 | + LIBS = []) |
| 39 | +conf = Configure(env) |
| 40 | +socketlibs = [] |
| 41 | +# BSD & glibc has err.h. Most others don't. |
| 42 | +if conf.CheckCHeader('err.h'): |
| 43 | + env.Append(CPPFLAGS = ' -DHAVE_ERR_H') |
| 44 | +if conf.CheckCHeader('paths.h'): |
| 45 | + env.Append(CPPFLAGS = ' -DHAVE_PATHS_H') |
| 46 | +if conf.CheckCHeader('mntent.h'): |
| 47 | + env.Append(CPPFLAGS = ' -DHAVE_MNTENT_H') |
| 48 | +if conf.CheckCHeader(['stdio.h', 'sys/mnttab.h']): |
| 49 | + env.Append(CPPFLAGS = ' -DHAVE_SYS_MNTTAB_H') |
| 50 | +# snmp needs kstat on Solaris. |
| 51 | +conf.CheckLib('kstat') |
| 52 | +if conf.CheckLib('nsl'): |
| 53 | + socketlibs += ['nsl'] |
| 54 | +if conf.CheckLib('socket'): |
| 55 | + socketlibs += ['socket'] |
| 56 | +if conf.CheckLib('resolv'): |
| 57 | + socketlibs += ['resolv'] |
| 58 | +conf.CheckLib('pkcs11') |
| 59 | +if conf.CheckFunc('setmntent'): |
| 60 | + env.Append(CPPFLAGS = ' -DHAVE_SETMNTENT') |
| 61 | +if conf.CheckFunc('getmntent'): |
| 62 | + env.Append(CPPFLAGS = ' -DHAVE_GETMNTENT') |
| 63 | +if conf.CheckFunc('daemon'): |
| 64 | + env.Append(CPPFLAGS = ' -DHAVE_DAEMON') |
| 65 | +env = conf.Finish() |
| 66 | +# these aren't checked above because they're required... except maybe pthread. |
| 67 | +env.Append(LIBS = ['pthread', 'boost_thread'+boostsuffix, 'boost_regex'+boostsuffix, 'netsnmp', 'ssl', 'crypto', 'mysqlclient']) |
| 68 | +env.Command('sminfo.cxx', 'sminfo.sh', '/bin/sh $SOURCE >$TARGET') |
| 69 | +env.Command(['msgtab.hxx', 'msgtab.cxx'], ['mktab', 'messages.tab'], './mktab messages.tab') |
| 70 | + |
| 71 | +env.Program ('mktab', ['mktab.cxx'], LIBS = []) |
| 72 | +env.Program ('servmon', srcs) |
| 73 | +env.Program ('smlogmsg', ['smlogmsg.c'], LIBS = socketlibs) |
| 74 | +env.Program ('systatd', ['systatd.c'], LIBS = socketlibs) |
| 75 | +env.Alias('install', prefix) |
Property changes on: trunk/servmon/SConstruct |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 76 | + native |
Added: svn:keywords |
2 | 77 | + Author Date Id Revision |
Index: trunk/servmon/README |
— | — | @@ -1,16 +1,26 @@ |
| 2 | +::Servmon:. |
| 3 | + |
2 | 4 | Servmon is an automated server monitoring tool used on the Wikimedia servers. |
3 | | -It's also meant to be usable elsewhere, but may need some tweaking. Please send |
4 | | -any changes you make back to me at <keturner@livejournal.com>. |
| 5 | +It's also meant to be usable elsewhere, but may need some tweaking. |
5 | 6 | |
| 7 | +Please send any changes you make back to me at <keturner@livejournal.com>. |
| 8 | + |
6 | 9 | To use servmon you will need: |
7 | | - - Unix. It's tested on Solaris and RedHat Linux. Other systems may or may |
8 | | - not work; if you have to make any changes to build it, please let me know. |
9 | | - I am interested in supporting non-Unix systems but do not have access to any. |
10 | | - - A C++ compiler. GCC <2.95 will not work. GCC 2.95 may work. Tested with |
11 | | - >= 3.3. |
12 | | - - The Boost library (http://www.boost.org/). |
13 | | - - SCons (http://www.scons.org/). |
14 | | - |
| 10 | + - Unix. It's tested on Solaris, RedHat Linux and GNU/Debian. |
| 11 | + Other systems may or may not work; if you have to make any changes |
| 12 | + to build it, please let me know. I am interested in supporting non-Unix |
| 13 | + systems but do not have access to any. |
| 14 | + - A C++ compiler. GCC <2.95 will not work. GCC 2.95 may work. |
| 15 | + Tested with >= 3.3. |
| 16 | + - The Boost library (http://www.boost.org/). Debian users can install it |
| 17 | + using the packages libboost-dev libboost-thread-dev |
| 18 | + libboost-regex-dev |
| 19 | + - SCons (http://www.scons.org/). |
| 20 | + |
| 21 | +You will also need development headers for at least: |
| 22 | + libmysql (libmysql15-dev) |
| 23 | + libsnmp (libsnmp9-dev) |
| 24 | + |
15 | 25 | To build: |
16 | 26 | copy buildconfig.sample to buildconfig and edit as needed; |
17 | 27 | run 'scons' |
Index: trunk/servmon/smcfg.cxx |
— | — | @@ -3,8 +3,6 @@ |
4 | 4 | #include "smcfg.hxx" |
5 | 5 | #include "smlog.hxx" |
6 | 6 | |
7 | | -#include "bconf/prelude.h" |
8 | | - |
9 | 7 | namespace smcfg { |
10 | 8 | |
11 | 9 | namespace { |