Varken/README.md

116 lines
4.5 KiB
Markdown
Raw Normal View History

2018-04-17 09:53:57 -07:00
# Grafana Scripts
2018-02-09 23:49:01 -08:00
Repo for api scripts written (both pushing and pulling) to aggregate data into influxdb for grafana
2018-04-17 09:53:57 -07:00
Requirements /w install links: [Grafana](http://docs.grafana.org/installation/), [Python3](https://www.python.org/downloads/), [InfluxDB](https://docs.influxdata.com/influxdb/v1.5/introduction/installation/)
2018-10-29 17:16:31 -07:00
<center><img width="800" src="https://i.imgur.com/av8e0HP.png"></center>
2018-04-17 09:53:57 -07:00
## Quick Setup
2018-08-06 10:41:31 -07:00
1. Install requirements `pip3 install -r requirements.txt`
1. Make a copy of `configuration.example.py` to `configuration.py`
2. Make the appropriate changes to `configuration.py`
1. Create your plex database in influx
2018-04-17 09:53:57 -07:00
```sh
user@server: ~$ influx
> CREATE DATABASE plex
> quit
```
2018-08-06 10:41:31 -07:00
1. After completing the [getting started](http://docs.grafana.org/guides/getting_started/) portion of grafana, create your datasource for influxdb. At a minimum, you will need the plex database.
1. Install `grafana-cli plugins install grafana-worldmap-panel`
1. Click the + on your menu and click import. Using the .json provided in this repo, paste it in and customize as you like.
2018-10-20 09:09:50 -07:00
### Docker
Repo is included in [si0972/grafana-scripts](https://github.com/si0972/grafana-scripts-docker)
<details><summary>Example</summary>
<p>
```
docker create \
--name=grafana-scripts \
-v <path to data>:/Scripts \
-e plex=true \
-e PGID=<gid> -e PUID=<uid> \
si0972/grafana-scripts:latest
```
</p>
</details>
2018-08-06 10:41:31 -07:00
## Scripts
2018-08-07 13:41:03 -07:00
### `sonarr.py`
Gathers data from Sonarr and pushes it to influxdb.
2018-08-06 10:41:31 -07:00
```
Script to aid in data gathering from Sonarr
optional arguments:
-h, --help show this help message and exit
--missing Get all missing TV shows
--missing_days MISSING_DAYS
2018-08-06 14:30:25 -07:00
Get missing TV shows in past X days
2018-08-06 10:41:31 -07:00
--upcoming Get upcoming TV shows
--future FUTURE Get TV shows on X days into the future. Includes today.
i.e. --future 2 is Today and Tomorrow
--queue Get TV shows in queue
2018-08-06 10:41:31 -07:00
```
- Notes:
2018-08-07 13:41:03 -07:00
- You cannot stack the arguments. ie. `sonarr.py --missing --queue`
- One argument must be supplied
### `radarr.py`
Gathers data from Radarr and pushes it to influxdb
2018-08-06 10:41:31 -07:00
```
Script to aid in data gathering from Radarr
optional arguments:
-h, --help show this help message and exit
--missing Get missing movies
--missing_avl Get missing available movies
--queue Get movies in queue
```
- Notes:
2018-08-07 13:41:03 -07:00
- You cannot stack the arguments. ie. `radarr.py --missing --queue`
- One argument must be supplied
- `--missing_avl` Refers to how Radarr has determined if the movie should be available to download. The easy way to determine if the movie will appear on this list is if the movie has a <span style="color:red">RED "Missing"</span> tag associated with that movie. <span style="color:blue">BLUE "Missing"</span> tag refers to a movie that is missing but is not available for download yet. These tags are determined by your "Minimum Availability" settings for that movie.
### `ombi.py`
Gathers data from Ombi and pushes it to influxdb
2018-08-06 10:41:31 -07:00
```
Script to aid in data gathering from Ombi
optional arguments:
-h, --help show this help message and exit
--total Get the total count of all requests
--counts Get the count of pending, approved, and available requests
```
2018-08-07 13:41:03 -07:00
- Notes:
- You cannot stack the arguments. ie. `ombi.py --total --counts`
- One argument must be supplied
2018-08-06 10:41:31 -07:00
2018-08-07 13:41:03 -07:00
### `tautulli.py`
Gathers data from Tautulli and pushes it to influxdb. On initial run it will download the geoip2 DB and use it for locations.
2018-08-06 10:41:31 -07:00
2018-04-17 09:53:57 -07:00
## Notes
2018-04-17 10:00:30 -07:00
To run the python scripts crontab is currently leveraged. Examples:
```sh
### Modify paths as appropriate. python3 is located in different places for different users. (`which python3` will give you the path)
### to edit your crontab entry, do not modify /var/spool/cron/crontabs/<user> directly, use `crontab -e`
### Crontabs require an empty line at the end or they WILL not run. Make sure to have 2 lines to be safe
### It is bad practice to run any cronjob more than once a minute. For timing help: https://crontab.guru/
2018-08-06 10:41:31 -07:00
* * * * * /usr/bin/python3 /path-to-grafana-scripts/ombi.py --total
2018-04-17 10:00:30 -07:00
* * * * * /usr/bin/python3 /path-to-grafana-scripts/tautulli.py
* * * * * /usr/bin/python3 /path-to-grafana-scripts/radarr.py --queue
* * * * * /usr/bin/python3 /path-to-grafana-scripts/sonarr.py --queue
2018-08-06 10:41:31 -07:00
*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/radarr.py --missing
*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/sonarr.py --missing
2018-04-17 10:00:30 -07:00
*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/sickrage.py
```