add grafana

This commit is contained in:
Kevin Muñoz 2024-04-12 08:21:50 -05:00
parent fd90ee19d3
commit 564dcc6e3e
No known key found for this signature in database
GPG Key ID: 3CA0B9DF1BE7CE09
12 changed files with 275 additions and 0 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
*/pkg
*/src
*/.git
grafana/grafana
vaultwarden/vaultwarden
*.tzg
*.tgz

31
grafana/.SRCINFO Normal file
View File

@ -0,0 +1,31 @@
pkgbase = grafana
pkgdesc = Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB
pkgver = 10.4.2
pkgrel = 1
url = https://grafana.com/
install = grafana.install
arch = x86_64
license = AGPL
license = Apache
makedepends = git
makedepends = go
makedepends = npm
makedepends = grunt-cli
makedepends = python
makedepends = nodejs-lts-hydrogen
makedepends = yarn
depends = glibc
depends = freetype2
depends = fontconfig
depends = gsfonts
backup = etc/grafana.ini
source = git+https://github.com/grafana/grafana.git#tag=v10.4.2
source = grafana.service
source = grafana.sysusers
source = grafana.tmpfiles
sha512sums = 45db571c3c5ea92360a81403ef2669d4c7e702e65291afe35d14c4eb8a0ab5110297e8a384be489d7a28a6960d34efd3cee7cc48b9f238672b3811b6afe4018d
sha512sums = 02a597225ee6ba8da9491a94daa33fe681846e2140e02fbb461ff7d39acd4cf99694dc03fb5f2c5ecfd180b09c44a41fe639b121499b4222b67ada57dc60d850
sha512sums = 38b46d953837a7afa5a654dfeef163b210d56cad57d937018531d00cd63b5341d6f9cd777299bdc7a994d0cb7df09b8157aad0f166e76ad47564e1ad6d5441d4
sha512sums = c1724bfc7cbd6a406f17acb661efca0f1e57e2c30cc1841f4cb7ccfc420adc40cc61cb1c023d00444827b2c40e9caa4c2fefbfd503419848c74a0b455b2375ab
pkgname = grafana

84
grafana/PKGBUILD Normal file
View File

@ -0,0 +1,84 @@
# Maintainer: Sébastien "Seblu" Luttringer
# Contributor: Carsten Feuls <archlinux@carstenfeuls.de>
# Contributor: Gilles Hamel <hamelg at laposte dot net>
pkgname=grafana
pkgver=10.4.2
pkgrel=1
pkgdesc='Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB'
url='https://grafana.com/'
arch=('x86_64')
license=('AGPL' 'Apache')
depends=('glibc' 'freetype2' 'fontconfig' 'gsfonts')
makedepends=('git' 'go' 'npm' 'grunt-cli' 'python' 'nodejs-lts-hydrogen' 'yarn')
backup=('etc/grafana.ini')
source=("git+https://github.com/grafana/grafana.git#tag=v$pkgver"
'grafana.service'
'grafana.sysusers'
'grafana.tmpfiles'
)
install=$pkgname.install
sha512sums=('45db571c3c5ea92360a81403ef2669d4c7e702e65291afe35d14c4eb8a0ab5110297e8a384be489d7a28a6960d34efd3cee7cc48b9f238672b3811b6afe4018d'
'02a597225ee6ba8da9491a94daa33fe681846e2140e02fbb461ff7d39acd4cf99694dc03fb5f2c5ecfd180b09c44a41fe639b121499b4222b67ada57dc60d850'
'38b46d953837a7afa5a654dfeef163b210d56cad57d937018531d00cd63b5341d6f9cd777299bdc7a994d0cb7df09b8157aad0f166e76ad47564e1ad6d5441d4'
'c1724bfc7cbd6a406f17acb661efca0f1e57e2c30cc1841f4cb7ccfc420adc40cc61cb1c023d00444827b2c40e9caa4c2fefbfd503419848c74a0b455b2375ab')
prepare() {
cd $pkgname
# apply patch from the source array (should be a pacman feature)
local filename
for filename in "${source[@]}"; do
if [[ "$filename" =~ \.patch$ ]]; then
echo "Applying patch ${filename##*/}"
patch -p1 -N -i "$srcdir/${filename##*/}"
fi
done
# set arch linux paths
sed -ri 's,^(\s*data\s*=).*,\1 /var/lib/grafana,' conf/defaults.ini
sed -ri 's,^(\s*plugins\s*=).*,\1 /var/lib/grafana/plugins,' conf/defaults.ini
sed -ri 's,^(\s*provisioning\s*=).*,\1 /var/lib/grafana/conf/provisioning,' conf/defaults.ini
sed -ri 's,^(\s*logs\s*=).*,\1 /var/log/grafana,' conf/defaults.ini
}
build() {
cd grafana
echo 'Generate golang'
make gen-go
echo 'building the backend'
export CGO_LDFLAGS="${LDFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -modcacherw"
go run build.go setup
go run build.go build
echo 'building the frontend'
export NPM_CONFIG_PREFIX="$srcdir/npm"
export PATH+=":$NPM_CONFIG_PREFIX/bin"
export NODE_OPTIONS="--max-old-space-size=16000" # Increase to 8 GB
yarn install || cat /tmp/*/build.log
NODE_ENV=production yarn run build
}
package() {
install -Dm644 grafana.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/grafana.conf"
install -Dm644 grafana.sysusers "$pkgdir/usr/lib/sysusers.d/grafana.conf"
install -Dm644 grafana.service "$pkgdir/usr/lib/systemd/system/grafana.service"
cd $pkgname
install -Dsm755 bin/linux-amd64/grafana "$pkgdir/usr/bin/grafana"
install -Dsm755 bin/linux-amd64/grafana-server "$pkgdir/usr/bin/grafana-server"
install -Dsm755 bin/linux-amd64/grafana-cli "$pkgdir/usr/bin/grafana-cli"
install -Dm640 -o207 -g207 conf/sample.ini "$pkgdir/etc/$pkgname.ini"
install -Dm644 conf/defaults.ini "$pkgdir/usr/share/$pkgname/conf/defaults.ini"
install -dm755 "$pkgdir/usr/share/grafana/"
for i in public tools; do
cp -r "$i" "$pkgdir/usr/share/grafana/$i"
done
# Remove unit tests
rm -r "$pkgdir/usr/share/grafana/public/test"
}
# vim:set ts=2 sw=2 et:

22
grafana/grafana.install Normal file
View File

@ -0,0 +1,22 @@
#/bin/sh
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
if (( "$(vercmp $2 2.6.0-3)" < 0 )); then
echo '==> Configuration moved to /etc/grafana.ini'
fi
if (( "$(vercmp $2 4.4.3-1)" < 0 )); then
echo '==> Grafana now uses static UID/GID 207'
echo '==> Trying to update your previous UID/GID'
if ! { usermod -u 207 grafana && groupmod -g 207 grafana &&
chown -R 207:207 /var/{lib,log}/grafana; }; then
echo '==> Automatic GID/UID change failed. Do it manually!'
echo '==> usermod -g 207 grafana && groupmod -u 207 grafana && chown -R 207:207 /var/l{ib,og}/grafana'
fi
echo '==> Check the ownership of your files!'
fi
return 0
}
# vim:set ts=2 sw=2 et:

23
grafana/grafana.service Normal file
View File

@ -0,0 +1,23 @@
[Unit]
Description=Grafana service
After=network.target postgresql.service mariadb.service mysqld.service
[Service]
User=grafana
Group=grafana
WorkingDirectory=/usr/share/grafana
ExecStart=/usr/bin/grafana-server --config=/etc/grafana.ini
LimitNOFILE=10000
TimeoutStopSec=20
SuccessExitStatus=0 2
NoNewPrivileges=yes
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
[Install]
WantedBy=multi-user.target

1
grafana/grafana.sysusers Normal file
View File

@ -0,0 +1 @@
u grafana 207 - /var/lib/grafana

2
grafana/grafana.tmpfiles Normal file
View File

@ -0,0 +1,2 @@
d /var/lib/grafana 0750 grafana grafana -
d /var/log/grafana 0750 grafana grafana -

25
telegraf/.SRCINFO Normal file
View File

@ -0,0 +1,25 @@
pkgbase = telegraf
pkgdesc = Plugin-driven server agent for reporting metrics into InfluxDB
pkgver = 1.30.1
pkgrel = 1
url = http://influxdb.org/
install = telegraf.install
arch = i686
arch = x86_64
arch = armv6h
arch = armv7h
arch = aarch64
license = MIT
makedepends = go
makedepends = git
depends = glibc
options = !lto
backup = etc/telegraf/telegraf.conf
source = https://github.com/influxdata/telegraf/archive/v1.30.1/telegraf-v1.30.1.tar.gz
source = telegraf.install
source = telegraf.service
b2sums = 90701b2b09cd924288ef6593faa79a0ec099ead05211852cc8b617b35c3b319a403a0a1517ed3d09639b146b07abcc73a2fd3dba4045cfb5ce768ae06bec1b81
b2sums = a6b2fd7a688ef5a23539c1256380a6389e6fa474312ad9dee5cc77bcfabe92910a8913ffcf599c940a93bb3a5c89e01f3bedad4176f4d57dd33a68e0499c30bd
b2sums = d5a6845cb1ddb07f0cac20215c15d059f0c18aa43a7b549e7e738e58b8686b4db26b71426aafc8e682d6fd6f676fc0f468f53ea61968c4184feaaa22a23f5bc5
pkgname = telegraf

6
telegraf/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*
!.gitignore
!PKGBUILD
!.SRCINFO
!telegraf.install
!telegraf.service

57
telegraf/PKGBUILD Normal file
View File

@ -0,0 +1,57 @@
# Maintainer: "Amhairghin" Oscar Garcia Amor (https://ogarcia.me)
# Contributor: Nicolas Leclercq <nicolas.private@gmail.com>
# Contributor: Adam S Levy <adam@aslevy.com>
pkgname=telegraf
pkgver=1.30.1
pkgrel=1
pkgdesc='Plugin-driven server agent for reporting metrics into InfluxDB'
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64')
url='http://influxdb.org/'
license=('MIT')
depends=('glibc')
makedepends=('go' 'git')
options=('!lto')
backup=('etc/telegraf/telegraf.conf')
install="${pkgname}.install"
source=("https://github.com/influxdata/${pkgname}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz"
"${pkgname}.install"
"${pkgname}.service")
b2sums=('90701b2b09cd924288ef6593faa79a0ec099ead05211852cc8b617b35c3b319a403a0a1517ed3d09639b146b07abcc73a2fd3dba4045cfb5ce768ae06bec1b81'
'a6b2fd7a688ef5a23539c1256380a6389e6fa474312ad9dee5cc77bcfabe92910a8913ffcf599c940a93bb3a5c89e01f3bedad4176f4d57dd33a68e0499c30bd'
'd5a6845cb1ddb07f0cac20215c15d059f0c18aa43a7b549e7e738e58b8686b4db26b71426aafc8e682d6fd6f676fc0f468f53ea61968c4184feaaa22a23f5bc5')
prepare() {
cd "${pkgname}-${pkgver}"
mkdir -p build/
}
build() {
cd "${pkgname}-${pkgver}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
_LDFLAGS="-X main.goos=$(go env GOOS) -X main.goarch=$(go env GOARCH) -X main.version=${pkgver} -X main.branch=tag-${pkgver} -X main.commit=tag-${pkgver}"
go build -o build -ldflags="${_LDFLAGS}" "./cmd/telegraf"
}
package() {
# binary
install -D -m755 "${srcdir}/${pkgname}-${pkgver}/build/telegraf" \
"${pkgdir}/usr/bin/telegraf"
# configuration files
install -dD -m755 "${pkgdir}/etc/telegraf/telegraf.d"
"${srcdir}/${pkgname}-${pkgver}/build/telegraf" -sample-config > \
"${pkgdir}/etc/telegraf/telegraf.conf"
# license
install -Dm644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# service
install -D -m644 "${srcdir}/${pkgname}.service" \
"${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
}

View File

@ -0,0 +1,4 @@
post_remove() {
echo "Remember that the following directory isn't removed."
echo " -> /etc/telegraf"
}

19
telegraf/telegraf.service Normal file
View File

@ -0,0 +1,19 @@
[Unit]
Description=Plugin-driven server agent for reporting metrics into InfluxDB
After=network.target
[Service]
Type=notify
User=telegraf
Group=telegraf
DynamicUser=yes
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=mixed
TimeoutStopSec=5
LimitMEMLOCK=8M:8M
[Install]
WantedBy=multi-user.target