Skip to content

Commit 05c52f1

Browse files
author
vagrant
committed
Fixes to make building RPMs easier and added a spec file.
1 parent 94f7b2b commit 05c52f1

File tree

6 files changed

+297
-11
lines changed

6 files changed

+297
-11
lines changed

configure.ac

+14-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ AC_PATH_PROG(PCRE_CONFIG, [pcre-config], $pcre_config_prog)
1414

1515
AC_PROG_CC
1616
AM_PROG_CC_C_O
17-
AM_PROG_AR
1817
AC_PROG_LIBTOOL
1918

2019
LT_INIT
@@ -24,7 +23,7 @@ AC_CHECK_LIB([zmq], [zmq_socket], [],
2423

2524
AC_HEADER_STDC
2625
AC_CHECK_HEADERS([ctype.h fcntl.h float.h pthread.h signal.h stdarg.h \
27-
sys/types.h syslog.h time.h zmq.h jansson.h ev.h])
26+
sys/types.h syslog.h time.h zmq.h jansson.h ev.h libev/ev.h])
2827

2928
AC_TYPE_SIZE_T
3029
AC_TYPE_SIGNAL
@@ -59,7 +58,10 @@ AC_ARG_WITH([icinga-headers],
5958
WITHHEADERS="-I$withval"
6059
AC_DEFINE([HAVE_ICINGA], [], [Compiling against Icinga])
6160
],
62-
[]
61+
[
62+
AC_CHECK_HEADER([icinga.h],
63+
[AC_DEFINE([HAVE_ICINGA], [], [Compiling against Icinga])])
64+
]
6365
)
6466

6567
AC_ARG_WITH([nagios3-headers],
@@ -68,8 +70,7 @@ AC_ARG_WITH([nagios3-headers],
6870
[
6971
WITHEADERS="-I$withval"
7072
AC_DEFINE([HAVE_NAGIOS3], [], [Compiling against Nagios 3])
71-
],
72-
[]
73+
]
7374
)
7475

7576
AC_ARG_WITH([nagios4-src],
@@ -79,7 +80,13 @@ AC_ARG_WITH([nagios4-src],
7980
WITHHEADERS="-I$withval/include -I$withval"
8081
AC_DEFINE([HAVE_NAGIOS4], [], [Compiling against Nagios 4])
8182
],
82-
[]
83+
[
84+
AC_CHECK_HEADERS([nagios/nagios.h nagios/lib/libnagios.h],
85+
[
86+
WITHHEADERS="-I/usr/include/nagios"
87+
AC_DEFINE([HAVE_NAGIOS4], [], [Compiling against Nagios 4])
88+
])
89+
]
8390
)
8491

8592
AC_ARG_WITH([naemon-src],
@@ -90,8 +97,7 @@ AC_ARG_WITH([naemon-src],
9097
# For right now these are one and the same
9198
AC_DEFINE([HAVE_NAGIOS4], [], [Compiling against Nagios 4.x])
9299
AC_DEFINE([HAVE_NAEMON], [], [Compiling against Naemon])
93-
],
94-
[]
100+
]
95101
)
96102

97103
CFLAGS_BAK=$CFLAGS

dnxmq/config.h.in

+162-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,163 @@
1-
/* Define to 1 if you have the PCRE libraries installed */
1+
/* mods/config.h.in. Generated from configure.ac by autoheader. */
2+
3+
/* One parameter add_check_result_to_list */
4+
#undef HAVE_ADD_CHECK_RESULT_ONE
5+
6+
/* Two parameter add_check_result_to_list */
7+
#undef HAVE_ADD_CHECK_RESULT_TWO
8+
9+
/* Define to 1 if you have the <ctype.h> header file. */
10+
#undef HAVE_CTYPE_H
11+
12+
/* Have the really really long function name for deleting downtimes */
13+
#undef HAVE_DELETE_DOWNTIME_LONGNAME
14+
15+
/* Define to 1 if you have the <dlfcn.h> header file. */
16+
#undef HAVE_DLFCN_H
17+
18+
/* Define to 1 if you have the <ev.h> header file. */
19+
#undef HAVE_EV_H
20+
21+
/* Define to 1 if you have the <fcntl.h> header file. */
22+
#undef HAVE_FCNTL_H
23+
24+
/* Define to 1 if you have the <float.h> header file. */
25+
#undef HAVE_FLOAT_H
26+
27+
/* Define to 1 if you have the `free' function. */
28+
#undef HAVE_FREE
29+
30+
/* Compiling against Icinga */
31+
#undef HAVE_ICINGA
32+
33+
/* Define to 1 if you have the <inttypes.h> header file. */
34+
#undef HAVE_INTTYPES_H
35+
36+
/* Define to 1 if you have the <jansson.h> header file. */
37+
#undef HAVE_JANSSON_H
38+
39+
/* Define to 1 if you have the <libev/ev.h> header file. */
40+
#undef HAVE_LIBEV_EV_H
41+
42+
/* Define to 1 if you have the `pcre' library (-lpcre). */
43+
#undef HAVE_LIBPCRE
44+
45+
/* Define to 1 if you have the `zmq' library (-lzmq). */
46+
#undef HAVE_LIBZMQ
47+
48+
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
49+
to 0 otherwise. */
50+
#undef HAVE_MALLOC
51+
52+
/* Define to 1 if you have the <memory.h> header file. */
53+
#undef HAVE_MEMORY_H
54+
55+
/* Define to 1 if you have the `memset' function. */
56+
#undef HAVE_MEMSET
57+
58+
/* Compiling against Naemon */
59+
#undef HAVE_NAEMON
60+
61+
/* Compiling against Nagios 3 */
62+
#undef HAVE_NAGIOS3
63+
64+
/* Compiling against Nagios 4.x */
65+
#undef HAVE_NAGIOS4
66+
67+
/* Define to 1 if you have the <nagios/lib/libnagios.h> header file. */
68+
#undef HAVE_NAGIOS_LIB_LIBNAGIOS_H
69+
70+
/* Define to 1 if you have the <nagios/nagios.h> header file. */
71+
#undef HAVE_NAGIOS_NAGIOS_H
72+
73+
/* PCRE Libraries are installed */
274
#undef HAVE_PCRE
75+
76+
/* Define to 1 if you have the <pthread.h> header file. */
77+
#undef HAVE_PTHREAD_H
78+
79+
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
80+
and to 0 otherwise. */
81+
#undef HAVE_REALLOC
82+
83+
/* Define to 1 if you have the <signal.h> header file. */
84+
#undef HAVE_SIGNAL_H
85+
86+
/* Define to 1 if you have the <stdarg.h> header file. */
87+
#undef HAVE_STDARG_H
88+
89+
/* Define to 1 if you have the <stdint.h> header file. */
90+
#undef HAVE_STDINT_H
91+
92+
/* Define to 1 if you have the <stdlib.h> header file. */
93+
#undef HAVE_STDLIB_H
94+
95+
/* Define to 1 if you have the `strdup' function. */
96+
#undef HAVE_STRDUP
97+
98+
/* Define to 1 if you have the <strings.h> header file. */
99+
#undef HAVE_STRINGS_H
100+
101+
/* Define to 1 if you have the <string.h> header file. */
102+
#undef HAVE_STRING_H
103+
104+
/* Define to 1 if you have the <syslog.h> header file. */
105+
#undef HAVE_SYSLOG_H
106+
107+
/* Define to 1 if you have the <sys/stat.h> header file. */
108+
#undef HAVE_SYS_STAT_H
109+
110+
/* Define to 1 if you have the <sys/types.h> header file. */
111+
#undef HAVE_SYS_TYPES_H
112+
113+
/* Define to 1 if you have the <time.h> header file. */
114+
#undef HAVE_TIME_H
115+
116+
/* Define to 1 if you have the <unistd.h> header file. */
117+
#undef HAVE_UNISTD_H
118+
119+
/* Define to 1 if you have the <zmq.h> header file. */
120+
#undef HAVE_ZMQ_H
121+
122+
/* Define to the sub-directory in which libtool stores uninstalled libraries.
123+
*/
124+
#undef LT_OBJDIR
125+
126+
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
127+
#undef NO_MINUS_C_MINUS_O
128+
129+
/* Name of package */
130+
#undef PACKAGE
131+
132+
/* Define to the address where bug reports for this package should be sent. */
133+
#undef PACKAGE_BUGREPORT
134+
135+
/* Define to the full name of this package. */
136+
#undef PACKAGE_NAME
137+
138+
/* Define to the full name and version of this package. */
139+
#undef PACKAGE_STRING
140+
141+
/* Define to the one symbol short name of this package. */
142+
#undef PACKAGE_TARNAME
143+
144+
/* Define to the version of this package. */
145+
#undef PACKAGE_VERSION
146+
147+
/* Define as the return type of signal handlers (`int' or `void'). */
148+
#undef RETSIGTYPE
149+
150+
/* Define to 1 if you have the ANSI C header files. */
151+
#undef STDC_HEADERS
152+
153+
/* Version number of package */
154+
#undef VERSION
155+
156+
/* Define to rpl_malloc if the replacement function should be used. */
157+
#undef malloc
158+
159+
/* Define to rpl_realloc if the replacement function should be used. */
160+
#undef realloc
161+
162+
/* Define to `unsigned int' if <sys/types.h> does not define. */
163+
#undef size_t

dnxmq/mqexec.c

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "config.h"
12
#include <stdio.h>
23
#include <stdlib.h>
34
#include <unistd.h>
@@ -7,7 +8,11 @@
78
#include <stdint.h>
89
#include <fcntl.h>
910
#include <pwd.h>
11+
#ifdef HAVE_LIBEV_EV_H
12+
#include <libev/ev.h>
13+
#else
1014
#include <ev.h>
15+
#endif
1116
#include <zmq.h>
1217
#include <jansson.h>
1318
#include <syslog.h>

mods/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pkglib_LTLIBRARIES = nagmq.la
44
nagmq_la_SOURCES = nagmq_pull.c nagmq_req.c nagmq_pub.c common.c jsonemitter.c jsonparser.c
55
nagmq_la_LDFLAGS = -module -fPIC -pipe
66
nagmq_la_LIBADD = -ljansson
7-
nagmq_la_CFLAGS = -I../jansson/src @WITHHEADERS@
7+
nagmq_la_CFLAGS = @WITHHEADERS@

nag.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python26
1+
#!/usr/bin/python
22

33
import json, time, zmq, re, os, pwd, types
44
from optparse import OptionParser

nagmq.spec

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
Name: nagmq
2+
Version: 1.4
3+
Release: 1%{?dist}
4+
Summary: NagMQ is an event broker that exposes the internal state and events of Nagios
5+
Group: Utilities/Monitoring
6+
License: GPL
7+
Url: https://github.com/jbreams/nagmq
8+
Source0: %{sourcedir}/nagmq-%{version}.tar.gz
9+
Packager: Daniel Wittenberg <[email protected]>
10+
Vendor: Jonathan Reams <[email protected]>
11+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
12+
BuildRequires: zeromq3-devel libev-devel jansson-devel
13+
Requires: zeromq3 libev jansson
14+
15+
%description
16+
NagMQ is an event broker that exposes the internal state and events of Nagios to endpoings on a ZeroMQ message bus.
17+
18+
Nagios objects and events are available as JSON. The broker exposes three sockets, all of which are optional:
19+
20+
Publisher - Publishes events coming out of the event broker in real-time
21+
Pull - Receives passive checks and commands, like the Nagios command pipe
22+
Request - Sends state data on demand to clients
23+
24+
There is a distributed DNX-style executor (mqexec) designed to have as many workers (possibly at the edge as an NRPE-replacement) and job brokers as you want. It can also submit its results to more than one Nagios instance. Each worker can filter what checks it runs based on any field in the service/host check and event handler initiate messages from the publisher.
25+
26+
27+
##### Client package #####
28+
%package client
29+
Summary: NagMQ is an event broker that exposes the internal state and events of Nagios
30+
Group: Utilities/Monitoring
31+
32+
%description client
33+
NagMQ client package
34+
##### #####
35+
36+
%prep
37+
%setup -q
38+
39+
%build
40+
%configure
41+
%{__make} %{?_smp_mflags}
42+
43+
%install
44+
%{__make} DESTDIR=${RPM_BUILD_ROOT} install
45+
%{__mkdir} -p ${RPM_BUILD_ROOT}/%{_docdir}/%{name}-%{version}/
46+
%{__cp} -a LICENSE ${RPM_BUILD_ROOT}/%{_docdir}/%{name}-%{version}/
47+
%{__cp} -a README.rst ${RPM_BUILD_ROOT}/%{_docdir}/%{name}-%{version}/
48+
%{__rm} ${RPM_BUILD_ROOT}%{_libdir}/nagmq/nagmq.so.0*
49+
%{__rm} ${RPM_BUILD_ROOT}%{_libdir}/nagmq/nagmq.a
50+
%{__rm} ${RPM_BUILD_ROOT}%{_libdir}/nagmq/nagmq.la
51+
52+
%files
53+
%defattr(-,root,root)
54+
%attr(0775,root,root) %dir %{_libdir}/nagmq/
55+
%attr(0664,root,root) %{_libdir}/nagmq/nagmq.so
56+
%attr(0664,root,root) %{_docdir}/%{name}-%{version}/*
57+
%attr(0755,root,root) %{_sbindir}/mqbroker
58+
%attr(0755,root,root) %{_bindir}/nag.py
59+
60+
%files client
61+
%attr(0755,root,root) %{_sbindir}/mqexec
62+
63+
%clean
64+
%__rm -rf $RPM_BUILD_ROOT
65+
66+
67+
%pre
68+
# Don't do all this stuff if we are upgrading
69+
#if [ $1 = 1 ] ; then
70+
# /usr/sbin/groupadd snort 2> /dev/null || true
71+
# /usr/sbin/useradd -M -d %{_var}/log/snort -s %{noShell} -c "Snort" -g snort snort 2>/dev/null || true
72+
#fi
73+
74+
%post
75+
# Make a symlink if there is no link for snort-plain
76+
#if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then \
77+
# %__rm -f %{_sbindir}/snort; %__ln_s %{_sbindir}/%{name}-plain %{_sbindir}/snort; fi
78+
79+
# We should restart it to activate the new binary if it was upgraded
80+
#%{_initrddir}/snortd condrestart 1>/dev/null 2>/dev/null
81+
82+
# Don't do all this stuff if we are upgrading
83+
#if [ $1 = 1 ] ; then
84+
# %__chown -R snort.snort %{_var}/log/snort
85+
# /sbin/chkconfig --add snortd
86+
#fi
87+
88+
89+
90+
%preun
91+
#if [ $1 = 0 ] ; then
92+
# # We get errors about not running, but we don't care
93+
# %{_initrddir}/snortd stop 2>/dev/null 1>/dev/null
94+
# /sbin/chkconfig --del snortd
95+
#fi
96+
97+
%postun
98+
# Try and restart, but don't bail if it fails
99+
#if [ $1 -ge 1 ] ; then
100+
# %{_initrddir}/snortd condrestart 1>/dev/null 2>/dev/null || :
101+
#fi
102+
103+
# Only do this if we are actually removing snort
104+
#if [ $1 = 0 ] ; then
105+
# if [ -L %{_sbindir}/snort ]; then %__rm -f %{_sbindir}/snort; fi
106+
# /usr/sbin/userdel snort 2>/dev/null
107+
#fi
108+
109+
110+
111+
%changelog
112+
* Sat Apr 14 2012 Daniel Wittenberg <[email protected]> 1.2.2-1
113+
- initial RPM build
114+

0 commit comments

Comments
 (0)