Skip to content

Commit 74123c5

Browse files
authored
Update to travis build and change to directory structure (KxSystems#9)
1 parent 6025f71 commit 74123c5

16 files changed

+210
-46
lines changed

.travis.yml

+94-43
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,98 @@
1-
os: linux
1+
matrix:
2+
include:
3+
- dist: xenial
4+
os: linux
5+
- dist: trusty
6+
os: linux
7+
- dist: bionic
8+
os: linux
9+
- os: osx
10+
- os: windows
211
language: c
312
compiler: gcc
413

5-
stage:
6-
- build Release
14+
before_install:
15+
- export FILE_ROOT="prometheus-exporter"
16+
- export TESTS="False"
17+
- export BUILD="False"
718

8-
jobs:
9-
include:
10-
# LINUX BUILD
11-
- stage: build Release
12-
os: linux
13-
script:
14-
tar -zcvf prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz LICENSE README.md *.q example/
15-
deploy:
16-
provider: releases
17-
api_key: "$GITHUB_APIKEY"
18-
file: prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz
19-
on:
20-
tags: true
21-
skip_cleanup: 'true'
22-
23-
# OSX BUILD
24-
- stage: build Release
25-
os: osx
26-
script:
27-
tar -zcvf prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz LICENSE README.md *.q example/
28-
deploy:
29-
provider: releases
30-
api_key: "$GITHUB_APIKEY"
31-
file: prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz
32-
on:
33-
tags: true
34-
skip_cleanup: 'true'
35-
36-
# WINDOWS BUILD
37-
- stage: build Release
38-
os: windows
39-
script:
40-
7z a -tzip prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip LICENSE README.md *.q example
41-
deploy:
42-
provider: releases
43-
api_key: "$GITHUB_APIKEY"
44-
file: prom-exporter-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip
45-
on:
46-
tags: true
47-
skip_cleanup: 'true'
19+
# Run instructions to install the C/C++ requirements (BUILD_HOME) set in place of PAHO_HOME/HDF5_HOME etc.
20+
# Files in this case are unzipped into cbuild within travis_setup.sh
21+
- if [[ $BUILD == "True" ]]; then
22+
chmod +x travis_setup.sh;
23+
./travis_setup.sh;
24+
export BUILD_HOME=$TRAVIS_BUILD_DIR/cbuild
25+
export LIB="cmake/$FILE_ROOT/lib";
26+
mkdir cmake;
27+
else
28+
export LIB="";
29+
fi
30+
31+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
32+
QLIBDIR=l64; OD=$L64;
33+
elif [[ $TRAVIS_OS_NAME == "osx" ]]; then
34+
QLIBDIR=m64; OD=$M64;
35+
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
36+
QLIBDIR=w64; OD=$W64;
37+
else
38+
echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1;
39+
fi
40+
41+
- export QLIBDIR
42+
- mkdir qhome;
43+
- export QHOME=$(pwd)/qhome;
44+
- export PATH=$QHOME/$QLIBDIR:$PATH;
45+
46+
# Set up q for testing and execute tests on multiple
47+
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
48+
export LD_LIBRARY_PATH=$BUILD_HOME/lib:$LD_LIBRARY_PATH;
49+
export DYLD_LIBRARY_PATH=$BUILD_HOME/lib:$LD_LIBRARY_PATH;
50+
export PATH=$BUILD_HOME/lib:$PATH;
51+
curl -o qhome/q.zip -L $OD;
52+
unzip -d qhome qhome/q.zip;
53+
rm qhome/q.zip;
54+
echo -n $QLIC_KC |base64 --decode > qhome/kc.lic;
55+
else
56+
echo No kdb+, no tests;
57+
fi
58+
59+
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then
60+
export FILE_TAIL="zip";
61+
else
62+
export FILE_TAIL="tgz";
63+
fi
64+
- export FILE_NAME=$FILE_ROOT-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.$FILE_TAIL
65+
66+
# Make binaries for the library as appropriate
67+
- if [[ $BUILD == "True" && $TRAVIS_OS_NAME == "windows" ]]; then
68+
cd cmake && cmake -G "Visual Studio 15 2017 Win64" .. ;
69+
export MSBUILD_PATH="/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/";
70+
export PATH=$MSBUILD_PATH:$PATH;
71+
MSBuild.exe INSTALL.vcxproj //m //nologo //verbosity:normal //p:Configuration=Release //p:Platform=x64;
72+
cd ..;
73+
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
74+
cd cmake && cmake .. -DCMAKE_BUILD_TYPE=Release && make install && cd .. ;
75+
fi
76+
77+
script:
78+
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
79+
q test.q tests/ -q;
80+
fi
81+
- if [[ $TRAVIS_OS_NAME == "windows" && $BUILD == "True" ]]; then
82+
7z a -tzip -r $FILE_NAME ./cmake/$FILE_ROOT/*;
83+
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
84+
tar -zcvf $FILE_NAME -C cmake/$FILE_ROOT .;
85+
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
86+
7z a -tzip $FILE_NAME README.md install.bat LICENSE q examples;
87+
elif [[ $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ]]; then
88+
tar -zcvf $FILE_NAME README.md install.sh LICENSE q examples;
89+
fi
90+
91+
deploy:
92+
provider: releases
93+
api_key: "$GITHUB_APIKEY"
94+
file: "$FILE_NAME"
95+
on:
96+
tags: true
97+
condition: $TRAVIS_OS_NAME = windows || $TRAVIS_OS_NAME = osx || ($TRAVIS_DIST = trusty && $TRAVIS_OS_NAME = linux)
98+
skip_cleanup: 'true'

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Introduction
66

7-
This interface provides a method by which to expose metrics from a kdb+ process or multiple processes to Prometheus for monitoring. This is done via the script `exporter.q` which exposes kdb+ process metrics which can be consumed by Prometheus.
7+
This interface provides a method by which to expose metrics from a kdb+ process or multiple processes to Prometheus for monitoring. This is done via the script `q/exporter.q` which exposes kdb+ process metrics which can be consumed by Prometheus.
88

99
This interface is part of the [_Fusion for kdb+_](https://code.kx.com/v2/interfaces/fusion/) project.
1010

@@ -23,7 +23,7 @@ Visualization and querying can be done through the Prometheus built in expressio
2323
Run kdb+ with the supplied q script. This script will expose metrics on port 8080 which can be monitored by Prometheus
2424

2525
```
26-
q exporter.q -p 8080
26+
q q/exporter.q -p 8080
2727
```
2828

2929
Once running, you can use your web browser to view the currently exposed statistics on the metrics URL e.g. http://localhost:8080/metrics. The metrics exposed will be the metric values at the time at which the URL is requested.
File renamed without changes.

example/README.md examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This demonstration requires a Docker instance capable of running a Unix based co
1010
Start a q session locally on port 8080, running `exporter.q` from this folder via the command
1111

1212
```bash
13-
q ../exporter.q -p 8080
13+
q ../q/exporter.q -p 8080
1414
```
1515

1616
This will expose the metrics associated with this process on port 8080 for consumption by Prometheus.
File renamed without changes.
File renamed without changes.

install.bat

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@echo off
2+
3+
IF "%QHOME%"=="" (
4+
ECHO ERROR: Enviroment variable QHOME is NOT defined
5+
EXIT /B
6+
)
7+
8+
IF NOT EXIST %QHOME%\w64 (
9+
ECHO ERROR: Installation destination %QHOME%\w64 does not exist
10+
EXIT /B
11+
)
12+
13+
14+
IF EXIST q (
15+
ECHO Copying q script to %QHOME%
16+
COPY q\* %QHOME%
17+
IF %ERRORLEVEL% NEQ 0 (
18+
ECHO ERROR: Copy failed
19+
EXIT /B %ERRORLEVEL%
20+
)
21+
)
22+
23+
IF EXIST lib (
24+
ECHO Copying DLL to %QHOME%\w64
25+
COPY lib\* %QHOME%\w64\
26+
IF %ERRORLEVEL% NEQ 0 (
27+
ECHO ERROR: Copy failed
28+
EXIT /B %ERRORLEVEL%
29+
)
30+
)
31+
32+
ECHO Installation complete

install.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
if [ -z "$QHOME" ]
4+
then
5+
echo "ERROR: QHOME environment not set. Installation failed."
6+
exit 1
7+
fi
8+
9+
echo "Detected System"
10+
echo "* OS: $OSTYPE"
11+
echo "* TYPE: $HOSTTYPE"
12+
echo "* MACHINE TYPE: $MACHTYPE"
13+
14+
# DETECT OS TYPE BEING USED
15+
Q_PATH_SEP="/"
16+
Q_HOST_TYPE=""
17+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
18+
Q_HOST_TYPE="l"
19+
elif [[ "$OSTYPE" == "darwin"* ]]; then
20+
# Mac OSX
21+
Q_HOST_TYPE="m"
22+
elif [[ "$OSTYPE" == "cygwin" ]]; then
23+
# POSIX compatibility layer and Linux environment emulation for Windows
24+
Q_HOST_TYPE="w"
25+
Q_PATH_SEP="\\"
26+
elif [[ "$OSTYPE" == "msys" ]]; then
27+
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
28+
Q_HOST_TYPE="w"
29+
Q_PATH_SEP="\\"
30+
elif [[ "$OSTYPE" == "win32" ]]; then
31+
Q_HOST_TYPE="w"
32+
Q_PATH_SEP="\\"
33+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
34+
Q_HOST_TYPE="l"
35+
else
36+
echo "ERROR: OSTYPE $OSTYPE not currently supported by this script"
37+
echo "Please view README.md for installation instructions"
38+
exit 1
39+
fi
40+
41+
# DETECT WHETHER 32 OR 64 BIT
42+
Q_MACH_TYPE=""
43+
if [[ "$HOSTTYPE" == "x86_64" ]]; then
44+
Q_MACH_TYPE="64"
45+
else
46+
Q_MACH_TYPE="32"
47+
fi
48+
49+
Q_SCRIPT_DIR=${QHOME}${Q_PATH_SEP}
50+
Q_SHARED_LIB_DIR="${QHOME}${Q_PATH_SEP}${Q_HOST_TYPE}${Q_SHARED_LIB_DIR}${Q_MACH_TYPE}${Q_PATH_SEP}"
51+
52+
# check destination directory exists
53+
if [ ! -w "$Q_SCRIPT_DIR" ]; then
54+
echo "ERROR: Directory '$Q_SCRIPT_DIR' does not exist"
55+
exit 1
56+
fi
57+
if [ ! -w "$Q_SHARED_LIB_DIR" ]; then
58+
echo "ERROR: Directory '$Q_SHARED_LIB_DIR' does not exist"
59+
exit 1
60+
fi
61+
62+
if [ -d q ]; then
63+
echo "Copying q script to $Q_SCRIPT_DIR ..."
64+
cp q/* $Q_SCRIPT_DIR
65+
if [ $? -ne 0 ]; then
66+
echo "ERROR: copy failed"
67+
exit 1
68+
fi
69+
fi
70+
71+
if [ -d lib ]; then
72+
echo "Copying shared lib to $Q_SHARED_LIB_DIR ..."
73+
cp lib/* $Q_SHARED_LIB_DIR
74+
if [ $? -ne 0 ]; then
75+
echo "ERROR: copy failed"
76+
exit 1
77+
fi
78+
fi
79+
80+
echo "Install complete"
81+
exit 0

exporter.q q/exporter.q

File renamed without changes.

extract.q q/extract.q

File renamed without changes.

0 commit comments

Comments
 (0)