Skip to content

Commit

Permalink
Updated Readme / Added ansible-playbook and other deployment things
Browse files Browse the repository at this point in the history
  • Loading branch information
localleon committed Jan 24, 2019
1 parent 7379403 commit b7f7e48
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

config.yaml
./octoprint-exporter/octoprint-exporter
*.bin
*.retry
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# octoprint-exporter
OctoPrint Exporter for Prometheus written in Golang
### OctoPrint Exporter for Prometheus written in Golang

-- WORK-IN-PROGRESS
## Metrics
Metrics are exposed under :9112/metrics and start with the prefix "octoprint" . The Metrics are a replicate from the octoprint API

# Plattform
#### octoprint_status
0 == Unknown
1 == Operational
2 == Printing from SD
3 == Printing

## Deploying
1. Use Ansible
- Run build.sh to create binarys or download them from the releases page
- Change host and username in ansible-deploy.yaml (Ansible-Playbook)
- Run ``` ansible-playbook ./ansible-deploy.yaml ``` (tested on CentOS and Raspbian)
- Add scrape Job to your prometheus server and you're done
2. Do it yourself
- Copy the binary and the example-config file to your remote server
- Copy the systemd-service file to /etc/systemd/system/
- Use ```systemctl``` to enable the Service


## Contributing
- Pull-requests and bug reports wanted !

## Plattform
Currently tested on:
- linux/amd64
- linux/arm

### Credits / Libarys used
https://mholt.github.io/json-to-go/ -- Used to create Go Structs out of JSON
## Credits / Libarys used
https://mholt.github.io/json-to-go/ -- Used to create Go Structs out of JSON

## Author
Copyright localleon(c) 2019
46 changes: 46 additions & 0 deletions ansible-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- hosts: monitoring.virt.lan
remote_user: pi
become: yes
become_method: sudo

vars:
build_path: ./octoprint-exporter-linux-arm.bin
service_path: ./octoprint-exporter.service
config_path: ./config.yaml

tasks:
- name: Creates directory
file:
path: /opt/octoprint/
state: directory

- name: copying binary to remote
copy:
src: "{{build_path}}"
dest: "/opt/octoprint/octoprint.bin"
owner: root
group: root
mode: 0755

- name: copying config file to remote
copy:
src: "{{config_path}}"
dest: "/opt/octoprint/config.yaml"

- name: copying systemd-service file to remote
copy:
src: "{{service_path}}"
dest: "/etc/systemd/system/octoprint-exporter.service"

- name: just force systemd to reread configs
systemd:
daemon_reload: yes

- name: enable service octoprint-service and restart
systemd:
name: octoprint-exporter
enabled: yes
state: restarted


2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
listen : ":9112" # Port for the http Server to listen on
probetime: 15 # How often the Metrics are updated
apikey : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # Your Octoprint API Key found in the WebInterface
apikey : "677C7AD5049948EC84C2A14D75C317CB" # Your Octoprint API Key found in the WebInterface
octopi : "octopi.local"
18 changes: 18 additions & 0 deletions octoprint-exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Octoprint Prometheus Exporter
ConditionPathExists=/opt/octoprint/octoprint.bin
After=network.target

[Service]
Type=simple
User=root
Group=root

Restart=on-failure
RestartSec=30

WorkingDirectory=/opt/octoprint/
ExecStart=/opt/octoprint/octoprint.bin --config=/opt/octoprint/config.yaml

[Install]
WantedBy=multi-user.target

0 comments on commit b7f7e48

Please sign in to comment.