Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
identw committed May 15, 2024
1 parent 19f76b0 commit fd0b2c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 35 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
# custom-exporter

0 comments on commit fd0b2c8

Please sign in to comment.