-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstackdriver-agent.spec
More file actions
376 lines (318 loc) · 10.4 KB
/
stackdriver-agent.spec
File metadata and controls
376 lines (318 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
%global _hardened_build 1
%global __provides_exclude_from .*/collectd/.*\\.so$
# we have some references to the buildroot in the binaries for the include path
%define __arch_install_post %{nil}
%define programprefix stackdriver-
# Everything lives under /opt/ except config files which live in /etc/stackdriver/
%define _prefix /opt/stackdriver/collectd
%define _sysconfdir %{_prefix}/etc
%define _confdir /etc/stackdriver
%define _mandir %{_prefix}/man
%define _initddir /etc/rc.d/init.d
# some things that we enable or not based on distro version
%define docker_flag --disable-docker
%define has_yajl 0
%define bundle_yajl 0
%define has_hiredis 0
%define mongo 0
%define varnish 0
%define java_plugin 0
%define dep_filter 0
%define java_version 1.7.0
%if 0%{?rhel} >= 6
%define has_yajl 1
%define has_hiredis 1
%define mongo 1
%define varnish 1
%define java_plugin 1
%define dep_filter 1
%endif
%if 0%{?rhel} >= 7
%define curl_version 7.52.1
%define docker_flag --enable-docker
%else
%define curl_version 7.34.0
%define java_version 1.6.0
%endif
%if 0%{?amzn} >= 1
%define has_yajl 1
%define has_hiredis 1
%define mongo 1
%define varnish 1
%define java_plugin 1
%define dep_filter 1
%define bundle_yajl 1
%endif
%if %{has_hiredis}
%define redis_flag --enable-redis --with-libhiredis
%endif
%if %{has_yajl}
%define curl_json_flag --enable-curl_json
%define gcm_flag --enable-write_gcm
%endif
%if %{mongo}
%define mongo_flag --enable-mongodb
%endif
%if %{varnish}
%define varnish_flag --enable-varnish
%endif
%if %{java_plugin}
%define java_flag --enable-java --with-java=/usr/lib/jvm/java
%endif
Summary: Stackdriver system metrics collection daemon
Name: stackdriver-agent
Version: %{collectd_version}
Release: %{build_num}%{?dist}
License: GPLv2
Group: System Environment/Daemons
URL: http://www.stackdriver.com/
Source: collectd-%{version}.tar.gz
# embed libcurl so we know it's linked against openssl instead of
# nss. this avoids problems of nss leaking with libcurl. sigh.
Source1: curl-%{curl_version}.tar.bz2
Source200: stackdriver-agent
Source201: collectd.conf
Source202: stackdriver.sysconfig
Source203: stack-config
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(ExtUtils::Embed)
BuildRequires: python-devel
BuildRequires: libgcrypt-devel
BuildRequires: autoconf, automake
BuildRequires: mysql-devel
# this is in the main mysql package sometimes but -devel ends up
# just depending on libs.
BuildRequires: /usr/bin/mysql_config
BuildRequires: postgresql-devel
BuildRequires: git
BuildRequires: openssl-devel
%if %{java_plugin}
BuildRequires: java-%{java_version}-openjdk-devel
BuildRequires: java-%{java_version}-openjdk
BuildRequires: java-devel
%endif
%if %{has_hiredis}
BuildRequires: hiredis-devel
%endif
%if %{has_yajl}
BuildRequires: yajl-devel
%if ! %{bundle_yajl}
Requires: yajl
%endif
%endif
%if %{mongo}
BuildRequires: varnish-libs-devel
%endif
Requires: curl
Requires: sed
Requires(preun): /sbin/chkconfig
Requires(post): /sbin/chkconfig
Requires(post): /bin/grep
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%define _use_internal_dependency_generator 0
# NOTE: this will only work for EL6. If we want to support EL5, we'll
# have to do some more work
%if %{dep_filter}
%filter_requires_in mysql
%filter_requires_in postgresql
%filter_requires_in redis
%filter_requires_in curl_json
%filter_requires_in varnish
%filter_requires_in write_gcm
%filter_requires_in java
%filter_setup
%endif
%description
The Stackdriver system metrics daemon collects system statistics and
sends them to the Stackdriver service.
Currently includes collectd.
%prep
# update for aarch64
%setup -q -n collectd-%{version} -a 1
%build
# build libcurl first
pushd curl-%{curl_version}
./configure --prefix=%{buildroot}%{_prefix} --with-ssl --disable-threaded-resolver --enable-ipv6 \
--with-libidn --disable-shared --enable-static --disable-manual \
--with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt
%{__make} %{?_smp_mflags}
%{__make} install
popd
export PATH=%{buildroot}/%{_prefix}/bin:$PATH
# install mongo-c-driver into mongodb-mongo-c-driver/build
%configure CFLAGS="%{optflags} -DLT_LAZY_OR_NOW='RTLD_NOW|RTLD_GLOBAL' -Icurl-%{curl_version}/include" \
--program-prefix=stackdriver- \
--disable-all-plugins \
--disable-static \
--disable-perl --without-libperl --without-perl-bindings \
--with-libiptc \
--with-libmongoc=own \
--with-libcurl=%{buildroot}/%{_prefix} \
--enable-cpu \
--enable-curl \
--enable-df \
--enable-disk \
--enable-load \
--enable-logfile \
--enable-logging-metrics \
--enable-memory \
--enable-swap \
--enable-syslog \
--enable-interface \
--enable-tcpconns \
--enable-write_http \
--enable-aggregation \
--enable-csv \
--enable-nginx \
--enable-apache \
--enable-memcached \
--enable-mysql \
--enable-protocols \
--enable-postgresql \
--enable-plugin_mem \
--enable-processes \
--enable-python \
--enable-ntpd \
--enable-nfs \
--enable-zookeeper \
--enable-stackdriver_agent \
--enable-exec \
--enable-tail \
--enable-statsd \
--enable-network \
--enable-match_regex --enable-target_set \
--enable-target_replace --enable-target_scale \
--enable-match_throttle_metadata_keys \
--enable-write_log \
--enable-unixsock \
--with-useragent="stackdriver_agent/%{version}-%{release}" \
%{docker_flag} \
%{java_flag} \
%{redis_flag} \
%{curl_json_flag} \
%{mongo_flag} \
%{varnish_flag} \
%{gcm_flag} \
--enable-debug
%{__make} %{?_smp_mflags}
%install
# we have to reinstall as %%install cleans the buildroot
pushd curl-%{curl_version}
%{__make} install
# now remove things to avoid unpackaged files
rm -rf %{buildroot}/%{_prefix}/bin %{buildroot}/%{_prefix}/man
rm -rf %{buildroot}/%{_prefix}/share %{buildroot}/%{_prefix}/lib*/pkgconfig
popd
%{__rm} -rf contrib/SpamAssassin
%{__make} install DESTDIR="%{buildroot}"
%{__install} -Dp -m0755 %{SOURCE200} %{buildroot}/%{_initddir}/stackdriver-agent
%{__install} -Dp -m0644 %{SOURCE201} %{buildroot}/%{_confdir}/collectd.conf
%{__install} -Dp -m0644 %{SOURCE202} %{buildroot}/etc/sysconfig/stackdriver
%{__install} -Dp -m0755 %{SOURCE203} %{buildroot}/opt/stackdriver/stack-config
%{__install} -d -m0755 %{buildroot}/%{_datadir}/collectd/collection3/
find contrib/ -type f -exec %{__chmod} a-x {} \;
# Remove Perl hidden .packlist files.
find %{buildroot} -name .packlist -exec rm {} \;
# Remove Perl temporary file perllocal.pod
find %{buildroot} -name perllocal.pod -exec rm {} \;
# Move config contribs
mkdir -p %{buildroot}%{_sysconfdir}/collectd.d/
mkdir -p %{buildroot}%{_confdir}/collectd.d/
# *.la files shouldn't be distributed.
rm -f %{buildroot}%{_libdir}/{collectd/,}*.la
rm -f %{buildroot}%{_sysconfdir}/collectd.conf
rm -f %{buildroot}%{_sysconfdir}/collectd.conf.pkg-orig
# now remove more libcurl stuff that was needed to finish the install
rm -rf %{buildroot}%{_prefix}/include/curl %{buildroot}%{_prefix}/lib/libcurl*
# remove libmongoc and libbson includes and doc files
%{__rm} -rf %{buildroot}%{_prefix}/include/libmongoc-1.0
%{__rm} -rf %{buildroot}%{_prefix}/include/libbson-1.0
%{__rm} -rf %{buildroot}%{_prefix}/share/doc/mongo-c-driver
%{__rm} -rf %{buildroot}%{_prefix}/share/doc/libbson
%{__rm} -f %{buildroot}%{_prefix}/bin/stackdriver-mongoc-stat
# Remove files that are laying about that rpmbuild is complaining about.
%{__rm} -f %{buildroot}%{_prefix}/man/man5/%{programprefix}collectd-email.5*
%{__rm} -f %{buildroot}%{_prefix}/man/man5/%{programprefix}collectd-java.5*
%{__rm} -f %{buildroot}%{_prefix}/man/man5/%{programprefix}collectd-lua.5*
%{__rm} -f %{buildroot}%{_prefix}/man/man5/%{programprefix}collectd-perl.5*
%{__rm} -f %{buildroot}%{_prefix}/man/man5/%{programprefix}collectd-snmp.5*
%{__rm} -f %{buildroot}%{_prefix}/bin/stackdriver-utils_vl_lookup_test
%if %{bundle_yajl}
mkdir -p %{buildroot}%{_libdir}/yajl/
cp /usr/lib64/libyajl.so.1 %{buildroot}%{_libdir}/yajl/
ln -s -t %{buildroot}%{_libdir} yajl/libyajl.so.1
cp /usr/share/doc/yajl-1.0.7/COPYING yajl.COPYING
%endif
%post
/sbin/ldconfig
/sbin/chkconfig --add stackdriver-agent
%preun
if [ $1 -eq 0 ]; then
/sbin/service stackdriver-agent stop &>/dev/null || :
/sbin/chkconfig --del stackdriver-agent
fi
%postun
/sbin/ldconfig
/sbin/service stackdriver-agent condrestart &>/dev/null || :
%files
%defattr(-, root, root, -)
%config %{_confdir}/collectd.conf
%config(noreplace) %{_sysconfdir}/collectd.d/
%config(noreplace) %{_confdir}/collectd.d/
%{_bindir}/%{programprefix}collectd-nagios
%{_bindir}/%{programprefix}collectdctl
%{_bindir}/%{programprefix}collectd-tg
%{_bindir}/%{programprefix}read_agent_logging
%{_sbindir}/%{programprefix}collectd
%{_sbindir}/%{programprefix}collectdmon
%dir %{_libdir}/collectd
%{_libdir}/collectd/*.so
%{_datadir}/collectd/types.db
%{_datadir}/collectd/postgresql_default.conf
# collectdclient - TBD reintroduce -devel subpackage?
%{_libdir}/libcollectdclient.so
%{_libdir}/libcollectdclient.so.1
%{_libdir}/libcollectdclient.so.1.0.0
%{_libdir}/pkgconfig/libcollectdclient.pc
%{_includedir}/collectd/client.h
%{_includedir}/collectd/lcc_features.h
%{_includedir}/collectd/network.h
%{_includedir}/collectd/network_buffer.h
%{_libdir}/libbson-1.0.*
%{_libdir}/libmongoc-1.0.*
%{_libdir}/libmongoc-priv.*
%{_libdir}/pkgconfig/*
%if %{bundle_yajl}
%dir %{_libdir}/yajl/
%{_libdir}/yajl/libyajl.so.1
%{_libdir}/libyajl.so.1
%endif
%if %{java_plugin}
%dir %{_datadir}/collectd/java
%{_datadir}/collectd/java/collectd-api.jar
%{_datadir}/collectd/java/generic-jmx.jar
%endif
%doc AUTHORS ChangeLog COPYING README
%if %{bundle_yajl}
%doc yajl.COPYING
%endif
%doc %{_mandir}/man1/%{programprefix}collectd.1*
%doc %{_mandir}/man1/%{programprefix}collectdctl.1*
%doc %{_mandir}/man1/%{programprefix}collectd-nagios.1*
%doc %{_mandir}/man1/%{programprefix}collectd-tg.1*
%doc %{_mandir}/man1/%{programprefix}collectdmon.1*
%doc %{_mandir}/man5/%{programprefix}collectd.conf.5*
%doc %{_mandir}/man5/%{programprefix}collectd-exec.5*
%doc %{_mandir}/man5/%{programprefix}collectd-python.5*
%doc %{_mandir}/man5/%{programprefix}collectd-threshold.5*
%doc %{_mandir}/man5/%{programprefix}collectd-unixsock.5*
%doc %{_mandir}/man5/%{programprefix}types.db.5*
# Stackdriver.
%{_initddir}/stackdriver-agent
%config(noreplace) /etc/sysconfig/stackdriver
# Backward compatibility.
%dir /opt/stackdriver
/opt/stackdriver/stack-config
%changelog
* Mon Oct 16 2017 Stackdriver Agents <stackdriver-agents@google.com> 5.5.2-372
- Make --write-gcm the default.