summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <william.hubbs@sony.com>2019-01-11 18:41:56 -0600
committerWilliam Hubbs <williamh@gentoo.org>2019-01-11 18:48:21 -0600
commitafb543bed5d409f5ed2fd847a846ea702754b70a (patch)
treedc626cc5be58f0dd7e5a8c6f76d2f4f755574dac /app-metrics/github-exporter/files
parentprofiles: Unmask Perl 5.28 (diff)
downloadgentoo-afb543bed5d409f5ed2fd847a846ea702754b70a.tar.gz
gentoo-afb543bed5d409f5ed2fd847a846ea702754b70a.tar.bz2
gentoo-afb543bed5d409f5ed2fd847a846ea702754b70a.zip
app-metrics/github-exporter: Export github statistics to prometheus
Copyright: Sony Interactive Entertainment Inc. Package-Manager: Portage-2.3.51, Repoman-2.3.12 Signed-off-by: William Hubbs <williamh@gentoo.org>
Diffstat (limited to 'app-metrics/github-exporter/files')
-rw-r--r--app-metrics/github-exporter/files/github-exporter.confd14
-rw-r--r--app-metrics/github-exporter/files/github-exporter.initd53
2 files changed, 67 insertions, 0 deletions
diff --git a/app-metrics/github-exporter/files/github-exporter.confd b/app-metrics/github-exporter/files/github-exporter.confd
new file mode 100644
index 000000000000..35368901c8f1
--- /dev/null
+++ b/app-metrics/github-exporter/files/github-exporter.confd
@@ -0,0 +1,14 @@
+# settings for github-exporter
+
+# I will list the required variables here, but there are several more.
+# Please see the README for all of them.
+
+# LISTEN_PORT specifies the port the exporter will use. Below is the default.
+# LISTEN_PORT=9171
+
+# ORGS should contain a list of github organizations you wish to monitor.
+# ORGS="org1,org2"
+
+# REPOS should contain a list of github repos you want tomonitor.
+# If neither ORGS nor REPOS is set, the exporter will refuse to run.
+# REPOS="user1/repo1,user2/repo2"
diff --git a/app-metrics/github-exporter/files/github-exporter.initd b/app-metrics/github-exporter/files/github-exporter.initd
new file mode 100644
index 000000000000..45ea133260af
--- /dev/null
+++ b/app-metrics/github-exporter/files/github-exporter.initd
@@ -0,0 +1,53 @@
+#!/sbin/openrc-run
+
+description="github exporter for Prometheus"
+command=/usr/bin/github-exporter
+command_background=yes
+command_user=${RC_SVCNAME}:${RC_SVCNAME}
+pidfile=/var/run/github-exporter.pid
+error_log="/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"
+output_log="/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"
+
+depend() {
+ after net
+}
+
+start_pre() {
+ local env_args
+ if [ -z "${ORGS}" ] && [ -z "${REPOS}" ]; then
+ eerror "ORGS and / or REPOS must be set."
+ return 1
+ fi
+ if [ -n "${GITHUB_TOKEN}" ] && [ -n "${GITHUB_TOKEN_FILE}" ]; then
+ eerror "Please set only one of GITHUB_TOKEN or GITHUB_TOKEN_FILE"
+ return 1
+ fi
+ if [ -n "${API_URL}" ]; then
+ env_args="${env_args} -e API_URL=${API_URL}"
+ fi
+ if [ -n "${GITHUB_TOKEN}" ]; then
+ env_args="${env_args} -e GITHUB_TOKEN=${GITHUB_TOKEN}"
+ elif [ -n "${GITHUB_TOKEN_FILE}" ]; then
+ env_args="${env_args} -e GITHUB_TOKEN_FILE=${GITHUB_TOKEN_FILE}"
+ fi
+ if [ -z "${LISTEN_PORT}" ]; then
+ env_args="${env_args} -e LISTEN_PORT=9171"
+ else
+ env_args="${env_args} -e LISTEN_PORT=${LISTEN_PORT}"
+ fi
+ if [ -n "${LOG_LEVEL}" ]; then
+ env_args="${env_args} -e LOG_LEVEL=${LOG_LEVEL}"
+ fi
+ if [ -n "${METRICS_PATH}" ]; then
+ env_args="${env_args} -e METRICS_PATH=${METRICS_PATH}"
+ fi
+ if [ -n "${ORGS}" ]; then
+ env_args="${env_args} -e ORGS=${ORGS}"
+ fi
+ if [ -n "${REPOS}" ]; then
+ env_args="${env_args} -e REPOS=${REPOS}"
+ fi
+ start_stop_daemon_args="${start_stop_daemon_args} ${env_args}"
+ supervise_daemon_args="${supervise_daemon_args} ${env_args}"
+ return 0
+}