# seafile-exporter ## Index * [About](#about) * [Features](#features) * [Support](#support) * [Dependencies](#dependencies) * [Setup](#setup) * [Requirements](#requirements) * [Installation](#installation) * [Update](#update) * [Usage](#usage) * [License](#license) * [Credits](#credits) * [Appendix](#appendix) ## About seafile-exporter periodically scrapes some seafile metrics and provides its data via HTTP to Prometheus. ### Features #### Exported metrics These metrics are exported by `seafile-exporter`: | name | description | |----------------------------------------|--------------------------------------------------------------| | seafile_current_connected_devices | Seafile system info: current_connected_devices | | seafile_groups | Seafile system info: groups | | seafile_is_pro | Seafile system info: is_pro | | seafile_license | Seafile license information | | seafile_license_maxusers | Seafile license: maximum users | | seafile_multi_tenancy_enabled | Seafile system info: multi_tenancy_enabled | | seafile_repos | Seafile system info: repos | | seafile_system_info | Seafile server info | | seafile_total_devices | Seafile system info: total_devices | | seafile_total_files | Seafile system info: total_files | | seafile_total_storage | Seafile system info: total_storage | | seafile_up | Indicates if the metrics could be scraped by the exporter. | | seafile_update_available | Seafile server update | | seafile_users | Seafile system info: users | | seafile_users_active | Seafile system info: users_active | ### Support ### Dependencies This application is written in Go and has the following dependencies: * [client_golang](github.com/prometheus/client_golang/prometheus) * [logrus](github.com/sirupsen/logrus) * [viper](github.com/spf13/viper) * [charset](golang.org/x/net/html/charset) ## Setup ### Requirements This application has the following build requirements: * Git * Go ### Installation #### From source To build the application from source, simply run the following commands: ``` git clone https://git.monobear.eu/monobear/seafile-exporter.git cd seafile-exporter go build ``` #### Docker Image The preferred way to use `seafile-exporter` is by running the provided Docker image. It is currently provided on GitHub Container Registry: - [`registry.monobear.eu/monobear/seafile-exporter/seafile-exporter`](https://git.monobear.eu/monobear/seafile-exporter/container_registry) The following tags are available: - `x.y.z` pointing to the release with that version - `latest` pointing to the most recent released version - `master` pointing to the latest build from the default branch #### Scrape configuration The exporter will query seafile every time it is scraped by prometheus. If you want to reduce load on the seafile server you need to change the scrape interval accordingly: ```yml scrape_configs: - job_name: 'seafile' scrape_interval: 90s static_configs: - targets: ['localhost:9338'] ``` ### Update To rebuild the application with the latest Go release, execute the following commands: ``` export GO_VERSION="1.21.3" cd ~ curl --location https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz --output ~/go${GO_VERSION}.linux-amd64.tar.gz tar xzvf ~/go${GO_VERSION}.linux-amd64.tar.gz sudo rm -rf /usr/local/src/go sudo mv ~/go /usr/local/src echo 'PATH=$PATH:/usr/local/src/go/bin:$GOPATH/bin' | sudo tee /etc/profile.d/go.sh source /etc/profile.d/go.sh git clone https://github.com/monofox/seafile-exporter.git cd ./seafile-exporter/ rm -f go\.mod go\.sum sed -i 's@go-version: .*@go-version: ${GO_VERSION}@g' .github/workflows/release.yml go mod init github.com/monofox/seafile-exporter go mod tidy ``` ## Usage The application will load the `config.toml` file located in the same directory if present. Use the `-conf` flag to override the default configuration file name and location. To run the application, simply execute the Go binary. ### Parameters Config parameter | Environment equivalent | Description | Type | Default ------------------------- | ---------------------------------- | ---------------------------------------- | ------- | ---------------------------------------------------- `listen_address` | `SEAFILE_LISTEN_ADDRESS` | address and port to bind | String | 0.0.0.0:9388 `metrics_path` | `SEAFILE_METRICS_PATH` | relative path to expose metrics | String | /metrics `ignore_ssl` | `SEAFILE_IGNORE_SSL` | whether of not to ignore ssl errors | Boolean | false `seafile_scrape_uri` | `SEAFILE_SEAFILE_SCRAPE_URI` | uri to get monit status | String | http://localhost/ `seafile_auth_user` | `SEAFILE_SEAFILE_AUTH_USER` | user for authentication | String | admin `seafile_auth_password` | `SEAFILE_SEAFILE_AUTH_PASSWORD` | password for authentication | String | seafile `seafile_auth_secret` | `SEAFILE_SEAFILE_AUTH_SECRET` | otp secret for authentication, if needed | String | none `seafile_changelog` | `SEAFILE_SEAFILE_CHANGELOG` | URL to seafile changelog | String | https://manual.seafile.com/changelog/changelog-for-seafile-professional-server/ ### Example config ```toml listen_address = "0.0.0.0:9388" metrics_path = "/metrics" ignore_ssl = false seafile_scrape_uri = "https://seafile.cloud.online" seafile_auth_user = "admin@user.online" seafile_auth_password = "very-secret-password" seafile_auth_secret = "otp-secret" ``` ## License Distributed under the MIT License. See `LICENSE` file for more information. ## Contact Project: [seafile-exporter](https://git.monobear.eu/monobear/seafile-exporter)