Giter Club home page Giter Club logo

pihole_influx's Introduction

About ๐Ÿ‘‹

GitHub User's stars

Summary

Technologist and Senior DevOps Architect and Consultant. Innovator, Engineer and Crypto Advocate. Deeply rooted in all things tech since the late 90's.



Twitter Follow @c_bergeron christopherbergeron1 bergeron cbergeron

pihole_influx's People

Contributors

chrisbergeron avatar rarosalion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pihole_influx's Issues

Service don't work

Hello,
Config : Debian 10
The script work when i do :
sudo python pihole_influx.py or python pihole_influx.py
but when i try to start service, he don't work :/
My Service
`[Unit]
Description=PiHole Influx - Send pihole stats to influxdb for Grafana
After=multi-user.target

[Service]
User=root
Type=idle
ExecStart=/usr/bin/python /opt/pihole_influx.py

[Install]
WantedBy=multi-user.target`

oct. 23 20:32:54 vm-ubuntu18-grafana systemd[1]: Started PiHole Influx - Send pihole stats to influxdb for Grafana.
oct. 23 20:33:04 vm-ubuntu18-grafana python3[14208]: Traceback (most recent call last):
oct. 23 20:33:04 vm-ubuntu18-grafana python3[14208]:   File "/opt/pihole_influx.py", line 11, in <module>
oct. 23 20:33:04 vm-ubuntu18-grafana python3[14208]:     from influxdb import InfluxDBClient
oct. 23 20:33:04 vm-ubuntu18-grafana python3[14208]: ModuleNotFoundError: No module named 'influxdb'
oct. 23 20:33:04 vm-ubuntu18-grafana systemd[1]: pihole-influx.service: Main process exited, code=exited, status=1/FAILURE
oct. 23 20:33:04 vm-ubuntu18-grafana systemd[1]: pihole-influx.service: Failed with result 'exit-code'.
oct. 23 20:53:03 vm-ubuntu18-grafana systemd[1]: /lib/systemd/system/pihole-influx.service:8: Executable path is not absolute: python3 /opt/pihole_influx.py > /tmp/piho

I install INFLUX DB with :
pip install influxdb

Installing collected packages: pytz, six, python-dateutil, msgpack, urllib3, chardet, certifi, idna, requests, influxdb
Successfully installed certifi-2020.6.20 chardet-3.0.4 idna-2.10 influxdb-5.3.0 msgpack-0.6.1 python-dateutil-2.8.1 pytz-2020.1 requests-2.24.0 six-1.15.0 urllib3-1.25.11

And pip3 install influxdb
Installing collected packages: msgpack, six, python-dateutil, pytz, certifi, urllib3, idna, chardet, requests, influxdb
Successfully installed certifi-2020.6.20 chardet-3.0.4 idna-2.10 influxdb-5.3.0 msgpack-0.6.1 python-dateutil-2.8.1 pytz-2020.1 requests-2.24.0 six-1.15.0 urllib3-1.25.11

But : ModuleNotFoundError: No module named 'influxdb'
Help me please :'(

README update

I think it would be great if you write that you need to have influxdb for python installed, otherwise it will not work.

Thanks for a really great script

Issue running script

I am having trouble with this and cannot figure out the issue. I am currently running the script on my Grafana server which also runs the InfluxDB. I modified the script to point to my PiHole and ran it but keep getting the below error. Could someone help me out please? TIA

File "./pihole_influx.py", line 59, in
send_msg(domains_being_blocked, dns_queries_today, ads_percentage_today, ads_blocked_today)
File "./pihole_influx.py", line 45, in send_msg
client.write_points(json_body)
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 391, in write_points
tags=tags)
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 436, in _write_points
expected_response_code=204
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 278, in write
headers=headers
File "/usr/lib/python2.7/dist-packages/influxdb/client.py", line 234, in request
timeout=self._timeout
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 454, in request
prep = self.prepare_request(req)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 388, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 293, in prepare
self.prepare_url(url, params)
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 347, in prepare_url
raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: 192.168.1.103:piholestats

Although influxdb exists pihole_influx complains

When starting up pihole_influx it says:

2022-12-02 15:53:06,113 - pihole_influx - INFO - Querying 1 pihole servers: ['https://pihole.xxxxxxx.nl']
2022-12-02 15:53:06,113 - pihole_influx - INFO - Logging to InfluxDB server 10.0.0.10:8086
2022-12-02 15:53:06,114 - pihole_influx - DEBUG - Connecting to 10.0.0.10
2022-12-02 15:53:06,124 - pihole_influx - INFO - Database pihole not found. Will attempt to create it.
2022-12-02 15:53:06,131 - pihole_influx - INFO - Attempting to contact https://pihole.xxxxx.nl with URL https://pihole.xxxxxx.nl/admin/api.php
2022-12-02 15:53:10,303 - pihole_influx - DEBUG - [{'measurement': 'piholestats.https://pihole_xxxxxx_nl', 'tags': {'host': 'https://pihole.dickpluim.nl'}, 'fields': {'domains_being_blocked': 1174496, 'dns_queries_today': 58188, 'ads_percentage_today': 8.561903, 'ads_blocked_today': 4982}}]
2022-12-02 15:53:10,337 - pihole_influx - INFO - Waiting 600

But database pihole does exist, so that is strange.

When I check influx it show series created by pihole_influx.

Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> show databases
name: databases
name
----
_internal
telegraf
hass
pihole
> use pihole
Using database pihole
> show series
key
---
pihole,host=first_one
pihole,host=pihole
pihole,host=second_one
piholestats.https://pihole_xxxxxx_nl,host=https://pihole.xxxxxx.nl
piholestats.pihole_xxxxxxxx_nl,host=pihole.xxxxxxx.nl

What can cause this?

Docker first launch fail

Hello,

I Cloned the repository, configured docker-compose.yml file and runned docker-compose up -d

[12:01] tiloup@PiHome:~/docker/pihole_influx$ docker-compose up -d
Creating network "pihole_influx_default" with the default driver
Building pihole_influx
Sending build context to Docker daemon  127.5kB

Step 1/5 : FROM python:3.7-alpine
3.7-alpine: Pulling from library/python
07389e51ea05: Pulling fs layer
72e5f05db4b6: Pulling fs layer
2d6e075f4308: Pulling fs layer
432829893fdc: Pulling fs layer
d3a5b264ed41: Pulling fs layer
d3a5b264ed41: Waiting
432829893fdc: Waiting
72e5f05db4b6: Verifying Checksum
72e5f05db4b6: Download complete
07389e51ea05: Verifying Checksum
07389e51ea05: Download complete
432829893fdc: Verifying Checksum
432829893fdc: Download complete
07389e51ea05: Pull complete
d3a5b264ed41: Verifying Checksum
d3a5b264ed41: Download complete
2d6e075f4308: Verifying Checksum
2d6e075f4308: Download complete
72e5f05db4b6: Pull complete
2d6e075f4308: Pull complete
432829893fdc: Pull complete
d3a5b264ed41: Pull complete
Digest: sha256:2a8106a531608ca5fd6e3be781701542819f6f91c34504bc86556287a0ea687c
Status: Downloaded newer image for python:3.7-alpine
 ---> 50f5d0967d62
Step 2/5 : RUN pip install --no-cache-dir influxdb
 ---> Running in 0ec51901221f
Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time
PermissionError: [Errno 1] Operation not permitted                                                                                                                     
                                                                                                                                                                       
Current thread 0xb6fc3390 (most recent call first):                                                                                                                    
The command '/bin/sh -c pip install --no-cache-dir influxdb' returned a non-zero code: 132                                                                             
ERROR: Service 'pihole_influx' failed to build  

Any Idea on how to work it out ?

My set up : Raspberry pi 4 on Raspbian Buster running pihole as classic unix install and docker with grafana and infllux (among other things)

Thanks in advance !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.