transmission

package module
v0.0.0-...-a7872aa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 6 Imported by: 2

README

Transmission Exporter for Prometheus Build Status

Docker Pulls Go Report Card

Prometheus exporter for Transmission metrics, written in Go.

LOOKING FOR MAINTAINERS

I don't use this exporter anymore and I'd be happy if others would want to take over and maintain it in the future!
Write me a DM via Twitter!

Installation
$ go get github.com/metalmatze/transmission-exporter
Configuration
ENV Variable Description
WEB_PATH Path for metrics, default: /metrics
WEB_ADDR Address for this exporter to run, default: :19091
TRANSMISSION_ADDR Transmission address to connect with, default: http://localhost:9091
TRANSMISSION_USERNAME Transmission username, no default
TRANSMISSION_PASSWORD Transmission password, no default
Docker
docker pull metalmatze/transmission-exporter
docker run -d -p 19091:19091 metalmatze/transmission-exporter
Kubernetes (Prometheus)

A sample kubernetes manifest is available in example/kubernetes

Please run: kubectl apply -f examples/kubernetes/transmission.yml

You should:

  • Attach the config and downloads volume
  • Configure the password for the exporter

Your prometheus instance will start scraping the metrics automatically. (if configured with annotation based discovery). more info

Docker Compose

Example docker-compose.yml with Transmission also running in docker.

transmission:
  image: linuxserver/transmission
  restart: always
  ports:
    - "127.0.0.1:9091:9091"
    - "51413:51413"
    - "51413:51413/udp"
transmission-exporter:
  image: metalmatze/transmission-exporter
  restart: always
  links:
    - transmission
  ports:
    - "127.0.0.1:19091:19091"
  environment:
    TRANSMISSION_ADDR: http://transmission:9091
Development
make

For development we encourage you to use make install instead, it's faster.

Now simply copy the .env.example to .env, like cp .env.example .env and set your preferences. Now you're good to go.

Original authors of the Transmission package

Tobias Blom (https://github.com/tubbebubbe/transmission)
Long Nguyen (https://github.com/longnguyen11288/go-transmission)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByDate

type ByDate []Torrent

ByDate implements the sort Interface to sort by Date

func (ByDate) Len

func (t ByDate) Len() int

func (ByDate) Less

func (t ByDate) Less(i, j int) bool

func (ByDate) Swap

func (t ByDate) Swap(i, j int)

type ByID

type ByID []Torrent

ByID implements the sort Interface to sort by ID

func (ByID) Len

func (t ByID) Len() int

func (ByID) Less

func (t ByID) Less(i, j int) bool

func (ByID) Swap

func (t ByID) Swap(i, j int)

type ByName

type ByName []Torrent

ByName implements the sort Interface to sort by Name

func (ByName) Len

func (t ByName) Len() int

func (ByName) Less

func (t ByName) Less(i, j int) bool

func (ByName) Swap

func (t ByName) Swap(i, j int)

type ByRatio

type ByRatio []Torrent

ByRatio implements the sort Interface to sort by Ratio

func (ByRatio) Len

func (t ByRatio) Len() int

func (ByRatio) Less

func (t ByRatio) Less(i, j int) bool

func (ByRatio) Swap

func (t ByRatio) Swap(i, j int)

type Client

type Client struct {
	URL string

	User *User
	// contains filtered or unexported fields
}

Client connects to transmission via HTTP

func New

func New(url string, user *User) *Client

New create new transmission torrent

func (*Client) GetSession

func (c *Client) GetSession() (*Session, error)

GetSession gets the current session from transmission

func (*Client) GetSessionStats

func (c *Client) GetSessionStats() (*SessionStats, error)

GetSessionStats gets stats on the current & cumulative session

func (*Client) GetTorrents

func (c *Client) GetTorrents() ([]Torrent, error)

GetTorrents get a list of torrents

type File

type File struct {
	BytesCompleted int64  `json:"bytesCompleted"`
	Length         int64  `json:"length"`
	Name           string `json:"name"`
}

File is a file contained inside a torrent

type FileStat

type FileStat struct {
	BytesCompleted int64 `json:"bytesCompleted"`
	Priority       int   `json:"priority"`
	Wanted         bool  `json:"wanted"`
}

FileStat describe a file's priority & if it's wanted

type Peer

type Peer struct {
	Address            string  `json:"address"`
	ClientIsChoked     bool    `json:"clientIsChoked"`
	ClientIsInterested bool    `json:"clientIsInterested"`
	ClientName         string  `json:"clientName"`
	FlagStr            string  `json:"flagStr"`
	IsDownloadingFrom  bool    `json:"isDownloadingFrom"`
	IsEncrypted        bool    `json:"isEncrypted"`
	IsIncoming         bool    `json:"isIncoming"`
	IsUTP              bool    `json:"isUTP"`
	IsUploadingTo      bool    `json:"isUploadingTo"`
	PeerIsChoked       bool    `json:"peerIsChoked"`
	PeerIsInterested   bool    `json:"peerIsInterested"`
	Port               int     `json:"port"`
	Progress           float64 `json:"progress"`
	RateToClient       int     `json:"rateToClient"`
	RateToPeer         int     `json:"rateToPeer"`
}

Peer of a torrent

type Session

type Session struct {
	AltSpeedDown    int  `json:"alt-speed-down"`
	AltSpeedEnabled bool `json:"alt-speed-enabled"`
	//Alt_speed_time_begin   int    `json:"alt-speed-time-begin"`
	//Alt_speed_time_day     int    `json:"alt-speed-time-day"`
	//Alt_speed_time_enabled bool   `json:"alt-speed-time-enabled"`
	//Alt_speed_time_end     int    `json:"alt-speed-time-end"`
	AltSpeedUp int `json:"alt-speed-up"`
	//Blocklist_enabled       bool   `json:"blocklist-enabled"`
	//Blocklist_size          int    `json:"blocklist-size"`
	//Blocklist_url           string `json:"blocklist-url"`
	CacheSizeMB int `json:"cache-size-mb"`
	//Config_dir                   string `json:"config-dir"`
	//Dht_enabled                  bool   `json:"dht-enabled"`
	DownloadDir          string `json:"download-dir"`
	DownloadDirFreeSpace int64  `json:"download-dir-free-space"`
	DownloadQueueEnabled bool   `json:"download-queue-enabled"`
	DownloadQueueSize    int    `json:"download-queue-size"`
	//Encryption                 string `json:"encryption"`
	//Idle_seeding_limit           int    `json:"idle-seeding-limit"`
	//Idle_seeding_limit_enabled   bool   `json:"idle-seeding-limit-enabled"`
	IncompleteDir string `json:"incomplete-dir"`
	//Incomplete_dir_enabled       bool   `json:"incomplete-dir-enabled"`
	//Lpd_enabled                  bool   `json:"lpd-enabled"`
	PeerLimitGlobal     int `json:"peer-limit-global"`
	PeerLimitPerTorrent int `json:"peer-limit-per-torrent"`
	//Peer_port                 int    `json:"peer-port"`
	//Peer_port_random_on_start bool   `json:"peer-port-random-on-start"`
	//Pex_enabled               bool   `json:"pex-enabled"`
	//Port_forwarding_enabled   bool   `json:"port-forwarding-enabled"`
	//Queue_stalled_enabled     bool   `json:"queue-stalled-enabled"`
	//Queue_stalled_minutes     int    `json:"queue-stalled-minutes"`
	//Rename_partial_files      bool   `json:"rename-partial-files"`
	//RPC_version               int    `json:"rpc-version"`
	//RPC_version_minimum          int    `json:"rpc-version-minimum"`
	//Script_torrent_done_enabled  bool   `json:"script-torrent-done-enabled"`
	//Script_torrent_done_filename string `json:"script-torrent-done-filename"`
	SeedQueueEnabled      bool    `json:"seed-queue-enabled"`
	SeedQueueSize         int     `json:"seed-queue-size"`
	SeedRatioLimit        float64 `json:"seedRatioLimit"`
	SeedRatioLimited      bool    `json:"seedRatioLimited"`
	SpeedLimitDown        int     `json:"speed-limit-down"`
	SpeedLimitDownEnabled bool    `json:"speed-limit-down-enabled"`
	SpeedLimitUp          int     `json:"speed-limit-up"`
	SpeedLimitUpEnabled   bool    `json:"speed-limit-up-enabled"`
	//Start_added_torrents         bool   `json:"start-added-torrents"`
	//Trash_original_torrent_files bool   `json:"trash-original-torrent-files"`
	//Utp_enabled                  bool   `json:"utp-enabled"`
	Version string `json:"version"`
}

Session information about the current transmission session

type SessionCommand

type SessionCommand struct {
	Method  string  `json:"method,omitempty"`
	Session Session `json:"arguments,omitempty"`
	Result  string  `json:"result,omitempty"`
}

SessionCommand is the root command to interact with Transmission via RPC

type SessionStateStats

type SessionStateStats struct {
	DownloadedBytes int64 `json:"downloadedBytes"`
	UploadedBytes   int64 `json:"uploadedBytes"`
	FilesAdded      int64 `json:"filesAdded"`
	SecondsActive   int64 `json:"secondsActive"`
	SessionCount    int64 `json:"sessionCount"`
}

SessionStateStats contains current or cumulative session stats

type SessionStats

type SessionStats struct {
	DownloadSpeed      int64             `json:"downloadSpeed"`
	UploadSpeed        int64             `json:"uploadSpeed"`
	ActiveTorrentCount int               `json:"activeTorrentCount"`
	PausedTorrentCount int               `json:"pausedTorrentCount"`
	TorrentCount       int               `json:"torrentCount"`
	CumulativeStats    SessionStateStats `json:"cumulative-stats"`
	CurrentStats       SessionStateStats `json:"current-stats"`
}

SessionStats contains information about the current & cumulative session

type SessionStatsCmd

type SessionStatsCmd struct {
	SessionStats `json:"arguments"`
	Result       string `json:"result"`
}

SessionStatsCmd is the root command to interact with Transmission via RPC

type Torrent

type Torrent struct {
	ID                 int           `json:"id"`
	Name               string        `json:"name"`
	Status             int           `json:"status"`
	Added              int           `json:"addedDate"`
	LeftUntilDone      int64         `json:"leftUntilDone"`
	Eta                int           `json:"eta"`
	UploadRatio        float64       `json:"uploadRatio"`
	RateDownload       int           `json:"rateDownload"`
	RateUpload         int           `json:"rateUpload"`
	DownloadDir        string        `json:"downloadDir"`
	IsFinished         bool          `json:"isFinished"`
	PercentDone        float64       `json:"percentDone"`
	SeedRatioMode      int           `json:"seedRatioMode"`
	HashString         string        `json:"hashString"`
	Error              int           `json:"error"`
	ErrorString        string        `json:"errorString"`
	Files              []File        `json:"files"`
	FilesStats         []FileStat    `json:"fileStats"`
	TrackerStats       []TrackerStat `json:"trackerStats"`
	Peers              []Peer        `json:"peers"`
	PeersConnected     int           `json:"peersConnected"`
	PeersGettingFromUs int           `json:"peersGettingFromUs"`
	TotalSize          int           `json:"totalSize"`
	UploadedEver       int           `json:"uploadedEver"`
}

Torrent represents a transmission torrent

type TorrentArguments

type TorrentArguments struct {
	Fields       []string              `json:"fields,omitempty"`
	Torrents     []Torrent             `json:"torrents,omitempty"`
	Ids          []int                 `json:"ids,omitempty"`
	DeleteData   bool                  `json:"delete-local-data,omitempty"`
	DownloadDir  string                `json:"download-dir,omitempty"`
	MetaInfo     string                `json:"metainfo,omitempty"`
	Filename     string                `json:"filename,omitempty"`
	TorrentAdded TorrentArgumentsAdded `json:"torrent-added"`
}

TorrentArguments specifies the TorrentCommand in more detail

type TorrentArgumentsAdded

type TorrentArgumentsAdded struct {
	HashString string `json:"hashString"`
	ID         int64  `json:"id"`
	Name       string `json:"name"`
}

TorrentArgumentsAdded specifies the torrent to get added data from

type TorrentCommand

type TorrentCommand struct {
	Method    string           `json:"method,omitempty"`
	Arguments TorrentArguments `json:"arguments,omitempty"`
	Result    string           `json:"result,omitempty"`
}

TorrentCommand is the root command to interact with Transmission via RPC

type TrackerStat

type TrackerStat struct {
	Announce              string `json:"announce"`
	AnnounceState         int    `json:"announceState"`
	DownloadCount         int    `json:"downloadCount"`
	HasAnnounced          bool   `json:"hasAnnounced"`
	HasScraped            bool   `json:"hasScraped"`
	Host                  string `json:"host"`
	ID                    int    `json:"id"`
	IsBackup              bool   `json:"isBackup"`
	LastAnnouncePeerCount int    `json:"lastAnnouncePeerCount"`
	LastAnnounceResult    string `json:"lastAnnounceResult"`
	LastAnnounceStartTime int    `json:"lastAnnounceStartTime"`
	LastAnnounceSucceeded bool   `json:"lastAnnounceSucceeded"`
	LastAnnounceTime      int    `json:"lastAnnounceTime"`
	LastAnnounceTimedOut  bool   `json:"lastAnnounceTimedOut"`
	LastScrapeResult      string `json:"lastScrapeResult"`
	LastScrapeStartTime   int    `json:"lastScrapeStartTime"`
	LastScrapeSucceeded   bool   `json:"lastScrapeSucceeded"`
	LastScrapeTime        int    `json:"lastScrapeTime"`
	LastScrapeTimedOut    bool   `json:"lastScrapeTimedOut"`
	LeecherCount          int    `json:"leecherCount"`
	NextAnnounceTime      int    `json:"nextAnnounceTime"`
	NextScrapeTime        int    `json:"nextScrapeTime"`
	Scrape                string `json:"scrape"`
	ScrapeState           int    `json:"scrapeState"`
	SeederCount           int    `json:"seederCount"`
	Tier                  int    `json:"tier"`
}

TrackerStat has stats about the torrent's tracker

type User

type User struct {
	Username string
	Password string
}

User to authenticate with Transmission

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL