-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CP-18271 first cut at C library for RRD plugins
This PR implements the C library for writing RRD plugins. It has been tested using the code in the repository and against the rrd-transport library. A strange bug currently remains: the rrd-transport installed via yum (`ocaml-rrd-transport-devel`) reports a problem whereas an rrd-transport library compiled from source code does not.
- Loading branch information
Showing
12 changed files
with
1,051 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.[ch]~ | ||
rrdclient | ||
rrdtest | ||
ocaml/_build | ||
ocaml/rrdreader.native | ||
*.o | ||
*.a | ||
*.rrd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "parson"] | ||
path = parson | ||
url = https://github.com/kgabis/parson.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
language: c | ||
sudo: false | ||
|
||
matrix: | ||
include: | ||
- compiler: gcc | ||
os: linux | ||
|
||
script: | ||
- make parson | ||
- make | ||
- make test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Citrix | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# vim: set ts=8 sw=8 noet: | ||
# | ||
# | ||
|
||
CC = gcc | ||
CFLAGS = -std=gnu99 -g -Wall | ||
OBJ += librrd.o | ||
OBJ += parson/parson.o | ||
LIB += -lz | ||
|
||
OCB = ocamlbuild -use-ocamlfind | ||
|
||
.PHONY: all | ||
all: librrd.a rrdtest rrdclient | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(OBJ) | ||
rm -f librrd.a | ||
rm -f librrd.o | ||
rm -f parson/parson.o | ||
rm -f rrdtest.o rrdtest | ||
rm -f rrdclient.o rrdclient | ||
rm -rf config.xml cov-int html coverity.out | ||
cd ocaml; $(OCB) -clean | ||
|
||
.PHONY: test | ||
test: rrdtest rrdclient | ||
./rrdtest | ||
seq 1 10 | ./rrdclient rrdclient.rrd | ||
seq 1 10 \ | ||
| while read i; do echo $$i; sleep 1; done \ | ||
| ./rrdclient rrdclient.rrd | ||
|
||
.PHONY: valgrind | ||
valgrind: rrdtest | ||
valgrind --leak-check=yes ./rrdtest | ||
seq 1 10 | valgrind --leak-check=yes ./rrdclient rrdclient.rrd | ||
|
||
.PHONY: indent | ||
indent: librrd.h librrd.c rrdtest.c | ||
indent -orig -nut $^ | ||
|
||
.PHONY: depend | ||
depend: librrd.c rrdtest.c | ||
$(CC) -MM $^ | ||
|
||
.PHONY: parson | ||
parson: | ||
# git submodule add https://github.com/kgabis/parson.git | ||
git submodule init | ||
git submodule update | ||
|
||
%.o: %.c | ||
$(CC) $(CFLAGS) -c -o $@ $< | ||
|
||
librrd.a: $(OBJ) | ||
ar rc $@ $(OBJ) | ||
ranlib $@ | ||
|
||
rrdtest: rrdtest.o librrd.a | ||
$(CC) $(CFLAGS) -o $@ $^ $(LIB) | ||
|
||
rrdclient: rrdclient.o librrd.a | ||
$(CC) $(CFLAGS) -o $@ $^ $(LIB) | ||
|
||
# coverity analysis | ||
|
||
COV_OPTS += --cpp | ||
COV_OPTS += --aggressiveness-level high | ||
COV_OPTS += --all | ||
COV_OPTS += --rule | ||
COV_OPTS += --disable-parse-warnings | ||
COV_OPTS += --enable-fnptr | ||
|
||
COV_DIR = cov-int | ||
|
||
cov: parson | ||
cov-configure --gcc --config config.xml | ||
cov-build --dir $(COV_DIR) --config config.xml $(MAKE) | ||
cov-analyze $(COV_OPTS) --dir $(COV_DIR) --config config.xml | ||
cov-format-errors --dir $(COV_DIR) --emacs-style > coverity.out | ||
cov-format-errors --dir $(COV_DIR) --html-output html | ||
|
||
# C dependencies | ||
|
||
parson/parson.h: parson | ||
parson/parson.c: parson | ||
|
||
parson/parson.o: parson/parson.h | ||
rrdtest.o: parson/parson.h librrd.h | ||
librrd.o: parson/parson.h librrd.h | ||
|
||
# OCaml test utility | ||
# You need: yum install -y ocaml-rrd-transport-devel | ||
|
||
rrdreader: | ||
cd ocaml; $(OCB) -pkg rrd-transport -tag thread rrdreader.native | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.