New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Where do I find the script to monitor server room temperature on a budget?

Votes:

0

Your Vote:

Up

Down

Where do I find the script to the blog article "How to monitor server room temperature on a budget?"

environment http-push-data-advanced python

Created on May 9, 2017 9:09:34 AM by  Torsten Lindner [Paessler Support]



3 Replies

Votes:

0

Your Vote:

Up

Down

Here you'll find the according Python-script, which will send environmental data to a HTTP Push Data Advanced Sensor in your PRTG Installation from this Blog Article.

#Written for Python3
# ___ ___ _____ ___
#| _ \ _ \_   _/ __|
#|  _/   / | || (_ |
#|_| |_|_\ |_| \___|
# Environmental Monitor via RaspberryPi
# ================================
# This script will monitor environmental values in a server room, with a Raspberry PI
#
#
# Version History
# ----------------------------
# 05/05/2017    1.0      initial release
# # # # # # # # # # # # # # # # # # # # # # # # # #

import time
import requests
from envirophat import weather, light


prtg_host = 'YOUR_PRTG_PROBE_HOST'
prtg_host_port = 'HTTP_PUSH_DATA_SENSOR_PORT'
prtg_sensor_token = 'HTTP_PUSH_DATA_SENSOR_TOKEN'
interval = 60


def get_values():
    temperature = weather.temperature()
    pressure = round(weather.pressure(), 2)
    amblight = light.light()

    json_response = {
        "prtg": {
            "result": [
                {
                    "channel": "temperature",
                    "float": 1,
                    "value": temperature
                },
                {
                    "channel": "pressure",
                    "float": 1,
                    "value": pressure
                },
                {
                    "channel": "ambient light",
                    "float": 1,
                    "value": amblight
                }
            ]
        }
    }
    return json_response


try:
    while True:
        try:
            json_response = get_values()
            # print output for debugging
            # print(json_response)
            json_string = str(json_response)
            json_string = str.replace(json_string, '\'', '\"')
            prtg_request_URL = 'http://' + prtg_host + ':' + prtg_host_port + '/' + prtg_sensor_token + '?content=' + json_string
            # print(prtg_request_URL)
            request = requests.get(prtg_request_URL)
            # print(request.status_code)
        except:
            pass
        time.sleep(interval)

except KeyboardInterrupt:
    pass

Please note that our support only covers PRTG itself and the sensors that come with it out of the box. All scripts and custom sensors within our knowledge base, script world and from support are provided "as is". That means that we cannot provide assistance in modifying scripts to suit the needs/environment of the customer, as it is too time intensive for both sides.

Created on May 9, 2017 9:26:59 AM by  Torsten Lindner [Paessler Support]

Last change on May 24, 2017 7:48:41 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

How do you actually add this script to the Raspberry Pi?

I have a Pi with the envirophat all installed. But how do I add this script? It is a vital part of the instructions missing from these instructions;

https://blog.paessler.com/how-to-monitor-server-room-temperature-with-prtg-on-a-budget

Created on Jun 18, 2019 1:46:24 PM by  chris11122 (0)



Votes:

0

Your Vote:

Up

Down

Copy the script to any path on the Pi and use cron to execute it every 5 minutes. That's it.

Created on Jun 19, 2019 10:52:19 AM by  Torsten Lindner [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.