From fd0b2c8248ca993d9dc49a9053a93e4b11f59b1f Mon Sep 17 00:00:00 2001 From: Dmitry Sergeev Date: Wed, 15 May 2024 18:16:27 +0400 Subject: [PATCH] WIP --- .github/workflows/build.yaml | 10 +++++++++- Dockerfile | 14 +++++++++++--- README.md | 32 +------------------------------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cdf5658..fec1ad4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -60,7 +60,15 @@ jobs: go-version: 1.22 - name: build run: | - CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -o artifacts/custom-exporter-${{ matrix.arch }} . + export CGO_ENABLED=0 + export GOOS=linux + export GOARCH=${{ matrix.arch }} + if [[ "${{ matrix.arch }}" == "arm7" ]]; then + export GOARM=7 + export GOARCH=arm + fi + go build -ldflags="-s -w" -o artifacts/custom-exporter-${{ matrix.arch }} . + - name: Upload release id: upload-release-asset uses: actions/upload-release-asset@main diff --git a/Dockerfile b/Dockerfile index 1939926..8bf15ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,17 @@ COPY ./pkg ./pkg ARG TARGETPLATFORM RUN echo "Building BUILDPLATFORM: '${BUILDPLATFORM}', TARGETPLATFORM: '$TARGETPLATFORM'"; -RUN GOOS=$(echo $TARGETPLATFORM | cut -d / -f1) \ - GOARCH=$(echo $TARGETPLATFORM | cut -d / -f2) \ - CGO_ENABLED=0 go build -ldflags="-s -w" -o ./custom-exporter . +RUN + export GOOS=$(echo $TARGETPLATFORM | cut -d / -f1); \ + export GOARCH=$(echo $TARGETPLATFORM | cut -d / -f2); \ + if [ "$GOARCH" = "arm" ]; then \ + export GOARCH="arm"; \ + export GOARM=$(echo $TARGETPLATFORM | cut -d / -f3 | sed 's/v//'); + fi; \ + export CGO_ENABLED=0; \ + echo "Building for $GOOS/$GOARCH/$GOARM"; \ + go build -ldflags="-s -w" -o ./custom-exporter . + FROM scratch COPY --from=build /app/custom-exporter /custom-exporter diff --git a/README.md b/README.md index a083f17..e989942 100644 --- a/README.md +++ b/README.md @@ -1,31 +1 @@ -# custom-exporter - -## Overview -This project is a tool for monitoring system processes in Linux. It uses the `procfs` library to read process information from the Linux proc file system and provides metrics about the number and types of processes running on the system. - -## Installation -To install this project, you need to have Go installed on your system. Then you can clone this repository and build the project with `go build`. - -## Usage -After building the project, you can run it with `./projectname`. It will print the total number of processes and the number of processes in each state. - -## Collectors -Collectors are functions that gather the metrics. In this project, there are two collectors: - -- `countProcesses`: This collector counts the total number of processes. -- `countProcessTypes`: This collector counts the number of processes in each state. - -## Configuration -There is no configuration needed for this project. It reads the process information directly from the proc file system. - -## Metrics -The metrics provided by this project are: - -- `total_processes`: The total number of processes running on the system. -- `processes_by_state`: The number of processes in each state. The states are represented as strings, such as "R" for running, "S" for sleeping, etc. - -## Contributing -If you want to contribute to this project, please open a pull request with your changes. - -## License -This project is licensed under the MIT License. See the LICENSE file for details. \ No newline at end of file +# custom-exporter \ No newline at end of file