forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,478 additions
and
0 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,113 @@ | ||
name: Build and Release package | ||
on: | ||
push: | ||
# Pattern matched against refs/tags | ||
tags: | ||
- "**" # Push events to every tag including hierarchical tags like v1.0/beta | ||
|
||
jobs: | ||
create_release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
steps: | ||
- name: Create release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref_name }} | ||
run: | | ||
gh release create "${{ github.ref_name }}" \ | ||
--repo="$GITHUB_REPOSITORY" \ | ||
--title="${{ github.ref_name }}" \ | ||
--generate-notes | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
|
||
- name: Install dependencies | ||
run: sudo apt -y install rubygems && sudo gem install fpm && sudo apt install binutils && sudo apt-get install rpm -y | ||
|
||
- name: Clear build directory | ||
run: rm -rf ./build/ | ||
|
||
- name: Build | ||
run: NIGHTLY=vmonitor make package include_packages="freebsd_amd64.tar.gz linux_amd64.tar.gz amd64.deb x86_64.rpm" | ||
# run: NIGHTLY=vmonitor make package include_packages="freebsd_amd64.tar.gz linux_amd64.tar.gz amd64.deb x86_64.rpm linux_arm64.tar.gz arm64.deb aarch64.rpm freebsd_i386.tar.gz i386.deb linux_i386.tar.gz i386.rpm" | ||
|
||
- name: Install Windows dependencies | ||
run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest | ||
|
||
- name: Debug | ||
run: | | ||
export PATH=${PATH}:~/go/bin | ||
export PATH=${PATH}:`go env GOPATH`/bin | ||
echo $PATH | ||
ls -al ./cmd/telegraf/ | ||
rm -rf ./cmd/telegraf/*.syso | ||
goversioninfo -skip-versioninfo | ||
- name: Build Windows package | ||
run: | | ||
export PATH=${PATH}:~/go/bin | ||
export PATH=${PATH}:`go env GOPATH`/bin | ||
echo $PATH | ||
NIGHTLY=vmonitor make package include_packages="windows_amd64.zip" | ||
# NIGHTLY=vmonitor make package include_packages="windows_i386.zip windows_amd64.zip windows_arm64.zip" | ||
|
||
- name: Debug | ||
run: ls -al ./cmd/telegraf/ && ls -al ./build/dist/ | ||
|
||
- name: Upload files to a GitHub release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref_name }} | ||
run: for file in ./build/dist/*; do gh release upload "${{ github.ref_name }}" "$file" --repo="$GITHUB_REPOSITORY"; done | ||
|
||
############## build and upload image | ||
- name: Log in to the GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Log in to the vCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: vcr.vngcloud.vn | ||
username: ${{ secrets.VCR_USER_PRO }} | ||
password: ${{ secrets.VCR_PASSWORD_PRO }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
ARG_VERSION=${{ github.ref_name }} | ||
ARG_GITHUB_REPOSITORY=${{ github.repository }} | ||
context: ./docker | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.ref_name }} | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }} | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.ref_name }} | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }} | ||
# labels: ${{ steps.metadata.outputs.labels }} | ||
|
||
- name: Build and push Docker image Alpine | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
ARG_VERSION=${{ github.ref_name }} | ||
ARG_GITHUB_REPOSITORY=${{ github.repository }} | ||
context: ./docker/alpine | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.ref_name }}-alpine | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}-alpine | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.ref_name }}-alpine | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}-alpine | ||
# labels: ${{ steps.metadata.outputs.labels }} |
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,75 @@ | ||
name: CI | ||
on: push | ||
|
||
env: | ||
TMP_RELEASE: 1.31.0-1.0.0 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
|
||
- name: Install dependencies | ||
run: sudo apt -y install rubygems && sudo gem install fpm && sudo apt install binutils && sudo apt-get install rpm -y | ||
|
||
- name: Clear build directory | ||
run: rm -rf ./build/ | ||
|
||
- name: Debug | ||
run: ls -al ./cmd/telegraf/ | ||
|
||
- name: Build | ||
run: NIGHTLY=vmonitor make package include_packages="linux_amd64.tar.gz amd64.deb" | ||
|
||
- name: Debug | ||
run: ls -al ./cmd/telegraf/ && ls -al ./build/dist/ | ||
|
||
- name: Upload files to a GitHub release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ env.TMP_RELEASE }} | ||
run: for file in ./build/dist/*; do gh release upload "${{ env.TMP_RELEASE }}" "$file" --repo="$GITHUB_REPOSITORY" --clobber; done | ||
|
||
############## build and upload image | ||
- name: Log in to the GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Log in to the vCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: vcr.vngcloud.vn | ||
username: ${{ secrets.VCR_USER_PRO }} | ||
password: ${{ secrets.VCR_PASSWORD_PRO }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
ARG_VERSION=${{ env.TMP_RELEASE }} | ||
ARG_GITHUB_REPOSITORY=${{ github.repository }} | ||
context: ./docker | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }} | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }} | ||
# labels: ${{ steps.metadata.outputs.labels }} | ||
|
||
- name: Build and push Docker image Alpine | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: | | ||
ARG_VERSION=${{ env.TMP_RELEASE }} | ||
ARG_GITHUB_REPOSITORY=${{ github.repository }} | ||
context: ./docker/alpine | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/telegraf:${{ github.sha }}-alpine | ||
vcr.vngcloud.vn/81-vmp-public/telegraf:${{ github.sha }}-alpine | ||
# labels: ${{ steps.metadata.outputs.labels }} |
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,17 @@ | ||
name: golangci-lint | ||
on: push | ||
|
||
jobs: | ||
golangci: | ||
name: lint-codebase | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.22" | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.52.2 | ||
args: --timeout 15m0s --verbose --out-${NO_FUTURE}format tab |
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 @@ | ||
name: govulncheck | ||
on: push | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Scan for Vulnerabilities in Code | ||
uses: golang/govulncheck-action@v1 | ||
with: | ||
go-version-input: 1.22.4 | ||
go-package: ./... |
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,31 @@ | ||
FROM buildpack-deps:bullseye-curl | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends iputils-ping snmp procps lm-sensors libcap2-bin && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ARG ARG_VERSION | ||
ENV TELEGRAF_VERSION $ARG_VERSION | ||
|
||
ARG ARG_GITHUB_REPOSITORY | ||
ENV GITHUB_REPOSITORY $ARG_GITHUB_REPOSITORY | ||
|
||
RUN echo ${TELEGRAF_VERSION} | ||
|
||
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) ARCH='amd64';; \ | ||
arm64) ARCH='arm64';; \ | ||
armhf) ARCH='armhf';; \ | ||
armel) ARCH='armel';; \ | ||
*) echo "Unsupported architecture: ${dpkgArch}"; exit 1;; \ | ||
esac && \ | ||
wget --no-verbose https://github.com/${GITHUB_REPOSITORY}/releases/download/${TELEGRAF_VERSION}/telegraf_nightly_${ARCH}.deb && \ | ||
dpkg -i telegraf_nightly_${ARCH}.deb && \ | ||
rm -f telegraf_nightly_${ARCH}.deb* | ||
|
||
EXPOSE 8125/udp 8092/udp 8094 | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["telegraf"] |
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,40 @@ | ||
FROM alpine:3.17 | ||
|
||
RUN echo 'hosts: files dns' >> /etc/nsswitch.conf | ||
RUN apk add --no-cache iputils ca-certificates net-snmp-tools procps lm_sensors tzdata su-exec libcap && \ | ||
update-ca-certificates | ||
|
||
ARG ARG_VERSION | ||
ENV TELEGRAF_VERSION $ARG_VERSION | ||
|
||
ARG ARG_GITHUB_REPOSITORY | ||
ENV GITHUB_REPOSITORY $ARG_GITHUB_REPOSITORY | ||
|
||
RUN ARCH= && \ | ||
case "$(apk --print-arch)" in \ | ||
x86_64) ARCH='amd64';; \ | ||
aarch64) ARCH='arm64';; \ | ||
*) echo "Unsupported architecture: $(apk --print-arch)"; exit 1;; \ | ||
esac && \ | ||
set -ex && \ | ||
mkdir ~/.gnupg; \ | ||
echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf; \ | ||
apk add --no-cache --virtual .build-deps wget gnupg tar && \ | ||
wget --no-verbose https://github.com/${GITHUB_REPOSITORY}/releases/download/${TELEGRAF_VERSION}/telegraf-nightly_linux_${ARCH}.tar.gz && \ | ||
mkdir -p /usr/src /etc/telegraf && \ | ||
tar -C /usr/src -xzf telegraf-nightly_linux_${ARCH}.tar.gz && \ | ||
mv /usr/src/telegraf*/etc/telegraf/telegraf.conf /etc/telegraf/ && \ | ||
mkdir /etc/telegraf/telegraf.d && \ | ||
cp -a /usr/src/telegraf*/usr/bin/telegraf /usr/bin/ && \ | ||
gpgconf --kill all && \ | ||
rm -rf *.tar.gz* /usr/src /root/.gnupg && \ | ||
apk del .build-deps && \ | ||
addgroup -S telegraf && \ | ||
adduser -S telegraf -G telegraf && \ | ||
chown -R telegraf:telegraf /etc/telegraf | ||
|
||
EXPOSE 8125/udp 8092/udp 8094 | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["telegraf"] |
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,15 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "$(echo "$1" | cut -c1)" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec su-exec telegraf "$@" | ||
fi |
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,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ $EUID -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec setpriv --reuid telegraf --init-groups "$@" | ||
fi |
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
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
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
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,5 @@ | ||
//go:build !custom || outputs || outputs.vngcloud_vmonitor | ||
|
||
package all | ||
|
||
import _ "github.com/influxdata/telegraf/plugins/outputs/vngcloud_vmonitor" // register plugin |
Oops, something went wrong.