Index: trunk/servmon/Makefile |
— | — | @@ -9,9 +9,9 @@ |
10 | 10 | SYSTATDOBJS= systatd.o |
11 | 11 | SMLOGMSGOBJS= smlogmsg.o |
12 | 12 | |
13 | | -all: servmon smlogmsg systatd |
| 13 | +all: exec smlogmsg systatd sm-monitor |
14 | 14 | |
15 | | -servmon: $(SERVMONOBJS) bconf/ldflags |
| 15 | +exec: $(SERVMONOBJS) bconf/ldflags |
16 | 16 | $(CXX) $(CXXFLAGS) $(SERVMONOBJS) -o $@ $(LDFLAGS) -lboost_thread$(BOOST) \ |
17 | 17 | -lboost_regex$(BOOST) -lnetsnmp -lmysqlclient -lssl -lcrypto \ |
18 | 18 | `cat bconf/ldflags` |
— | — | @@ -27,7 +27,17 @@ |
28 | 28 | $(CC) $(CPPFLAGS) $(CFLAGS) smlogmsg.c -o smlogmsg $(LDFLAGS) `cat bconf/ldflags` |
29 | 29 | systatd: systatd.c |
30 | 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) |
31 | 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 | + |
32 | 42 | .c.o: |
33 | 43 | $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $< |
34 | 44 | .cxx.o: |
Index: trunk/servmon/monitor.c |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +/* $Header$ */ |
| 3 | + |
| 4 | +#include <stdio.h> |
| 5 | +#include <unistd.h> |
| 6 | + |
| 7 | +#include "bconf/prelude.h" |
| 8 | + |
| 9 | +#define SERVMON PFX "/lib/servmon/exec" |
| 10 | + |
| 11 | +int |
| 12 | +main(argc, argv) |
| 13 | + int argc; |
| 14 | + char *argv[]; |
| 15 | +{ |
| 16 | + for (;;) { |
| 17 | + pid_t pid; |
| 18 | + int status; |
| 19 | + int lo, hi; |
| 20 | + |
| 21 | + if ((pid = fork()) == -1) { |
| 22 | + perror("fork"); |
| 23 | + exit(1); |
| 24 | + } |
| 25 | + |
| 26 | + if (pid == 0) { |
| 27 | + execv(SERVMON, argv); |
| 28 | + perror("exec"); |
| 29 | + exit(1); |
| 30 | + } |
| 31 | + |
| 32 | + waitpid(pid, &status, 0); |
| 33 | + lo = status & 0xF; |
| 34 | + hi = status << 8 & 0xF; |
| 35 | + if (lo == 0) { |
| 36 | + fprintf(stderr, "exec exited with exit status %d\n", hi); |
| 37 | + } else { |
| 38 | + fprintf(stderr, "exec exited with signal %d\n", lo); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
Property changes on: trunk/servmon/monitor.c |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 42 | + native |
Added: svn:keywords |
2 | 43 | + Author Date Id Revision |