GithubHelp home page GithubHelp logo

prtg / pythonminiprobe Goto Github PK

View Code? Open in Web Editor NEW
72.0 13.0 51.0 2.26 MB

MiniProbe for PRTG Network Monitor written in Python

License: BSD 3-Clause "New" or "Revised" License

Python 98.86% Shell 1.10% Smarty 0.04%

pythonminiprobe's Introduction

Important

From now on this project is completely deprecated and only here for reference!
Some time ago the Python Mini Probe project was rebooted and moved over to Gitlab. Come over and check it out! - Konstantin Wolff, Paessler AG 23/11/2020

PythonMiniProbe

With the current version of PRTG, you can use the Mini Probe interface with your custom code to implement solutions to special scenarios that you might have in your network. Please note that there are major changes planned to the underlying API in PRTG. Therefore, any code you write now will likely need to be changed later, so it can be used for future versions of PRTG. Further news about changing interfaces will be provided here as soon as there are more detailed plans available.

Current Status: BETA

MiniProbe POC for PRTG Network Monitor written in Python which accesses the MiniProbe Interface on the PRTG Core Server.

Build Status

Build Status

IMPORTANT: Major changes in this branch. Please see Migration Howto below! Installation

  • set up your PRTG server to use HTTPS (other connection methods not allowed at the moment)
  • allow MiniProbes to connect (Setup -> Probes -> Allow MiniProbes to connect)
  • make sure you can reach the PRTG web interface from the machine the mini probe should run on (e.g. wget https://YOUR_PRTG_SERVER)
    • This is tested during the setup
  • Install python-dev and build-essential (or at least gcc) packages
  • Install pip as outlined here https://pip.pypa.io/en/latest/installing.html (pre Python 2.7.9)
  • Download either zip or clone repository
  • run command 'sudo python setup.py install' which will install all necessary packages
  • run command 'sudo python setup.py configure' which will bring up the configuration dialogue

The miniprobe should now be started. You should also be able to start/stop the same using the command

sudo service prtgprobe start

or

sudo service prtgprobe stop

Migration Guide

  • Copy away file probe.conf
  • Stop the mini probe process
  • Delete the files /etc/init.d/probe and /etc/logrotate.d/probe (filenames might be prtgprobe as well)
  • Remove the /probe folder
  • Install python-dev and build-essential (or at least gcc) packages
  • Install pip as outlined here https://pip.pypa.io/en/latest/installing.html (pre Python 2.7.9)
  • Download either zip or clone repository
  • Run command 'sudo python setup.py install' which will install all necessary packages and will run the configuration
  • [optional] Run 'install.sh' to skip the 4 steps above
  • Copy the gid line from your old probe.conf to the new probe.conf at /probe/miniprobe/probe.conf
  • Start the mini probe process, the mini probe will connect with the previous GID and continue monitoring IMPORTANT: If replacing the new probe.conf with the old one, make sure the line 'subprocs:10' is present in the file!

Prerequisites

Debian based system (tested on Ubuntu, Debian, Raspbian)
Python 2.7+ (preferred 2.9) Needed modules are installed using the setup.py install phase:
Module list deprecated as pip will resolve dependencies!

Installation of DS18B20

Requirements:

  • DS18B20
  • 4.7K Ohm resistor

Setup:

  • Solder the resister between pin 2 and 3 of the DS18B20. If the flat part of the DS18B20 is facing you, then pin 2 and 3 are located at the right hand side starting from the middle.
  • Place pin 1 on pin 6 on the Raspberry.
  • Place pin 2 on pin 7 on the Raspberry.
  • Place pin 3 on pin 1 on the Raspberry.
  • Run the installscript of the probe and answer Yes to the question if you want to use the Raspberry Pi temperature sensor.
  • The installscript will now make a change to the raspberry boot process to include a special library and will then reboot the Raspberry. After the reboot, run the installer again and answer the same question again. It will now, if everything is correct, detect your DS18B20 using its own unique serial number. Just confirm that this is correct by pressing any key on your keyboard.

Current available sensors

  • CPU Load (for probe only)
  • CPU Temperature (for probe only)
  • Disk Space (for probe only)
  • DNS for the following records: A, AAAA, CNAME, SRV, SOA, NS, MX, PTR
  • External IP to get the external and internal ip for the probe
  • HTTP
  • Linux Updates to check for the number of available updates (for probe only)
  • Memory (for probe only)
  • NMAP to get available systems to monitor (currently using ping only)
  • Ping to check if a host/system is up
  • Port to check if a specific port is available
  • Probe Health for overal probe health, combines several other sensors into 1
  • SNMP Custom to monitor a system using SNMP OID
  • SNMP Traffic to monitor traffic on the probe

Debugging

To enable debugging, open the file probe.conf and replace the line

debug:

with

debug:True

This will enable detailed logging to folder "logs" which is as sub folder of the miniprobe folder. For further debugging, please stop the miniprobe process as outlined above. Navigate to the folder the file "probe.py" can be found then run following command "python probe.py". On major errors you will get the details and traceback directly on the console.

Changelog

=======

12-02-16

  • Status update on future of Mini Probe API

23-07-2015

MAJOR CHANGES:

  • added Python 3 compatibility

MINOR CHANGES:

  • code cleanup in preparation for further capsuling
  • adjusted travis config to run nose tests for python 3

11-06-2015

MAJOR CHANGES:

  • restructuring project layout accoriding to pip compliance
  • removed included modules
  • added support for pip/reqirements.txt
  • for installation, see above "Installation for this branch"
  • added tests folder for future unit tests
  • dropped probe_installer.py, code moved to setup.py
  • added release

07-05-2015

  • Finished the DNS Sensor for all dns types currently available in a Windows Probe
  • Added an APT sensor to check for available updates on the system

04-05-2015

  • Added dns sensor with support for A MX and SOA Records
  • Set the log message "Running Sensor: ..." to a debug message
  • Added the dnspython module for the dns sensor

10-03-2015

  • Added support for internal QA

24-02-2015

  • Added support for multiprocessing, now sensors are spawned as subprocesses (merged branch experimental with master)
  • fixed some indentation stuff (tabs instead of whitespaces)
  • fixed function get_config_key in probe_installer.py as key was set to None type all the time, fixed some sensors to put return data in the queue rather than simply returning it.
  • other minor fixes resp. code cleanup
  • preparation for a workflow (no direct commits to master any more)

14-02-2015

  • Added full support for the DS18B20 and a lot of cleanup and fixes
  • Also added the boot/config.txt fix for the DS18B20 that is needed on the RPi
  • Removed the no longer needed W1ThermSensor module from the repo as the Raspbian Image for raspberry already includes everything needed

02-02-2015

  • Installer cleanup and preparation for reading current config
  • Fix typo :(
  • Installer cleanup continued, added uninstall option to the installer, debug option added during installation
  • added W1ThermSensor module to the repo

26-01-2015

  • Merge pull request #2 from eagle00789/master -- Fixed Update-rd.d command -- Removed duplicate defined baseinterval check -- Fixed a bug in the installer that created the config file before any values where asked -- Added ping check for PRTG Server availability with possibility to still continue -- Added several checks and moved some code around to a function.

19-01-2015

  • added optional debug information

08-01-2015

  • fix for issue 1

05-11-2014

  • updated module requests

10-10-2014

  • dropped own logging -- now using python built in logging function (you might delete the file logger.py if existant) -- created file miniprobe.py which offers base functionality, probe.py now only does the work -- various changes and code cleanup -- added script templates for the probe_installer.py in folder /scripts -- changed version number to reflect YY.QQ.Release

28-08-2014

  • added module retry

26-08-2014

  • Updated module requests -- from now it is not necessary to use weakened security in the PRTG web server. There will be a one time warning if you are using a self signed certificate which can be ignored.
  • added VERSION.txt file -- the version number is built up from Year.Quarter.Buildnumber
  • moved Python version check to the beginning of the script
  • big code cleanup
  • applied PEP 8 rules to the code, some other refactoring). To be continued... (Probably tomorrow)

17-07-2014

  • Changed readme file, adjusted setup.py

07-07-2014

  • Fixed typos
  • Added check for logs folder

27-06-2014

  • Updated documentation
  • Merge Remote-tracking branch

26-06-2014

  • Updated Readme
  • Changed line separators
  • Initial Commit
  • Changed readme file
  • deleted readme

25-06-2014

  • Initial commit

pythonminiprobe's People

Contributors

eagle00789 avatar konstantinpae avatar rtuk 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

pythonminiprobe's Issues

snmpcustomsensor

Hallo

Der snmpcustomsensor funktioniert leider bei mir nicht wie gewünscht.
Auf dem Core Server wird nur SNMP Rexuest failed angezeigt. Auf der Probe selber steht im log folgende Zeile: 05/13/2015 22:22:30 - ERROR - Ooops Something went wrong with 'mpsnmpcustom' sensor 2208. Error: NoSuchInstance instance has no attribute 'trunc'
Der SNMP Tester liefert mir aber für die entsprechende OID einen Wert. Leider habe ich keine Kenntnisse in Python, dass ich es selber lösen könnte.
Danke für eine Antwort.

Freundliche Grüsse
Stefan Brunner

direct write access

since i am creating so many new features and fixes for the Python MiniProbe, i was wondering if i can get direct write access to the repository. it would make both our lives much easier since you just monitor my changes and my changes are directly available to everyone from the official repository.
I have many more features planned for the Python MiniProbe like:
snmp proxy (redirect a snmp request to another device on the remote network)
wmi proxy (same as above, but then for wmi)
and some others which i am still working out on paper...

Error on monitoring disk space

Hi,

just installed PMP on my RPi2 running latest Raspbian. The setup went smoothly but I get an error message in the logs plus an alarm on the PRTG server. The error message popping up is as follows:

02/26/2016 11:07:37 - ERROR - Ooops Something went wrong with 'mpdiskspace' sensor 3200. Error: invalid literal for int( ) with base 10: '1K-Bl\xc3\xb6cke'

Could you help me on this one?

Serveradress not saved in probe.conf, when not available at setup

You have to enter the FQDN or IP of PRTG server installation during the setup. If that server is not pingable when entered, a message comes up "not reachable, add anyway?", say yes but it will not be saved in the probe.conf file.
You have to enter it manually afterwards (it says none in the configfile)

Improving sensor "apt"

Hello,

thank you for providing the PythonMiniProbe! Its really helpfull for us to monitor linux-systems with PRTG. Keep up the great work!

We want to use the "apt"-sensor on systems with the default language "german" but this wont work.
The reason is, that the sensor "apt" uses "apt-get -s dist-upgrade | grep 'newly inst'" to determine the line with all information about available updates - in other language "newly installed" is simply translated to the setted language.

Maybe - as easy way for the beginning - you should just use "locale" to check the current setted language and throw an error? Or just search for the line "* upgraded, * newly installed, * to remove and * not upgraded." - whent this line is not in the output the sensor should fail.

At the moment the sensor shows no error - for a security relevant sensor not the best output when not working ;-)

What do you think?

MDADM sensor to PRTG

Hello,

Is it possible to use mdadm.py only on PRTG, if yes what modification to do?

because unfortunately there is no sensor for mdadm ..

I would like a mdadm sensor that runs on a linux connected in SSH to PRTG.

thank you in advance
Regards

Error stating incompatible software versions between Probe and Core

I ran into trouble connecting a RPi (Raspbian Linux) to a PRTG Core server. The connection itself works, but the handshake seems to fail due to incompatible software versions.

Logfile output:

05/21/2015 11:51:59 - INFO - Starting new HTTPS connection (1): x.x.x.x
05/21/2015 11:52:05 - ERROR - ('Connection aborted.', BadStatusLine("\x01ctOK\xaf:F\xb7\x00\x00\x00\xa3\x00\x00\x00Handshake zwischen Probe und Core fehlgeschlagen! Inkompatible Softwareversionen von Probe und Core k\xf6nnten daf\xfcr verantwortlich sein. Bitte updaten Sie die Probe.\x01\x00\x00\x00\xff\xff\xff\xff\xd8\xbd\xda'-\x94\xe4@",))

Software versions:

PRTG Network Monitor 15.2.16.2229
PythonMiniProbe 15.2.2

Help would be much appreciated.

Best regards

Install script assigns wrong file permissions

print "Changing File Permissions"
os.chmod('%s/probe.py' % probe_path, 755)
os.chmod('/etc/init.d/probe.sh', 755)
755 is interpreted as decimal and not octal as intended. Use 0755 (py2) or 0o755 (py3) or decimal 493

Custom script on a state trigger

Hy,

it's possible to execute custom script on a state trigger ?

Exemple :
If a sensor state change to "critical"
if a ping sensor change to unreachable
...

regards ;)

Uninstall - HowTo?

How would I completely uninstall PythonMiniProbe from a Linux system?

Sensor with custom script

Hi Konstantin,

are there any plans on a sensor that can execute custom scripts; similar to the windows probe?

Uninstall

Hi,

just a short question: How do I cleanly uninstall the software from a (RPi) device?

Thanks in advance!

Disk Space and External IP sensors failed

PythonMiniProbe installed on Ubuntu 14.04LTS.Installation went smoothly.

The following sensors are working: CPU Load, Memory, Probe Health.
The following sensors failed: DIsk Space, External IP

Debug log shows the following:

07/03/2016 20:34:57 - INFO - Starting new HTTPS connection (1): 192.168.1.121
07/03/2016 20:34:57 - INFO - tasks request successfully sent to PRTG Core Server at 192.168.1.121:443.
07/03/2016 20:34:57 - DEBUG - Connecting to 192.168.1.121:443
07/03/2016 20:34:57 - DEBUG - Status Code: 200 | Message: [{"sensorid":"2016","kind":"mpcpuload","host":"127.0.0.1"},{"sensorid":"2017","kind":"mpmemory","host":"127.0.0.1"},{"sensorid":"2018","kind":"mpdiskspace","host":"127.0.0.1"},{"sensorid":"2019","maxtemp":"45","kind":"mpprobehealth","host":"127.0.0.1","celfar":"C"},{"sensorid":"2020","kind":"mpexternalip","host":"127.0.0.1"}]
07/03/2016 20:34:57 - INFO - Task success.
07/03/2016 20:34:57 - DEBUG - Task success. HTTP Status 200, Message: [{"sensorid":"2016","kind":"mpcpuload","host":"127.0.0.1"},{"sensorid":"2017","kind":"mpmemory","host":"127.0.0.1"},{"sensorid":"2018","kind":"mpdiskspace","host":"127.0.0.1"},{"sensorid":"2019","maxtemp":"45","kind":"mpprobehealth","host":"127.0.0.1","celfar":"C"},{"sensorid":"2020","kind":"mpexternalip","host":"127.0.0.1"}]
07/03/2016 20:34:57 - DEBUG - JSON response: [{u'sensorid': u'2016', u'kind': u'mpcpuload', u'host': u'127.0.0.1'}, {u'sensorid': u'2017', u'kind': u'mpmemory', u'host': u'127.0.0.1'}, {u'sensorid': u'2018', u'kind': u'mpdiskspace', u'host': u'127.0.0.1'}, {u'sensorid': u'2019', u'kind': u'mpprobehealth', u'maxtemp': u'45', u'host': u'127.0.0.1', u'celfar': u'C'}, {u'sensorid': u'2020', u'kind': u'mpexternalip', u'host': u'127.0.0.1'}]
07/03/2016 20:34:57 - DEBUG - {u'sensorid': u'2016', u'kind': u'mpcpuload', u'host': u'127.0.0.1'}
07/03/2016 20:34:57 - DEBUG - Spawning sensor mpcpuload.
07/03/2016 20:34:57 - DEBUG - Running sensor: mpcpuload
07/03/2016 20:34:57 - DEBUG - {u'sensorid': u'2017', u'kind': u'mpmemory', u'host': u'127.0.0.1'}
07/03/2016 20:34:57 - DEBUG - Spawning sensor mpmemory.
07/03/2016 20:34:57 - DEBUG - Running sensor: mpmemory
07/03/2016 20:34:57 - DEBUG - {u'sensorid': u'2018', u'kind': u'mpdiskspace', u'host': u'127.0.0.1'}
07/03/2016 20:34:57 - DEBUG - Spawning sensor mpdiskspace.
07/03/2016 20:34:57 - ERROR - Ooops Something went wrong with 'mpdiskspace' sensor 2018. Error: invalid literal for int() with base 10: 'TB'
07/03/2016 20:34:57 - DEBUG - {u'sensorid': u'2019', u'kind': u'mpprobehealth', u'maxtemp': u'45', u'host': u'127.0.0.1', u'celfar': u'C'}
07/03/2016 20:34:57 - DEBUG - Spawning sensor mpprobehealth.
07/03/2016 20:34:57 - DEBUG - Current Health: 100 percent
07/03/2016 20:34:57 - DEBUG - Running sensor: mpprobehealth
07/03/2016 20:34:57 - DEBUG - {u'sensorid': u'2020', u'kind': u'mpexternalip', u'host': u'127.0.0.1'}
07/03/2016 20:34:57 - DEBUG - Spawning sensor mpexternalip.
07/03/2016 20:34:57 - DEBUG - Running sensor: mpexternalip
07/03/2016 20:34:57 - DEBUG - IP-Address: [{'kind': 'Custom', 'name': 'IP-Address', 'ShowTable': 0, 'ShowChart': 0, 'value': 1, 'customunit': '', 'mode': 'integer'}]
07/03/2016 20:34:57 - ERROR - Ooops Something went wrong with 'mpexternalip' sensor 2020. Error: [Errno 19] No such device
07/03/2016 20:34:57 - INFO - Starting new HTTPS connection (1): 192.168.1.121
07/03/2016 20:34:57 - INFO - data request successfully sent to PRTG Core Server at 192.168.1.121:443.
07/03/2016 20:34:57 - DEBUG - Connecting to 192.168.1.121:443
07/03/2016 20:34:57 - DEBUG - Status Code: 200 | Message: Done
07/03/2016 20:34:57 - INFO - Data success.
07/03/2016 20:34:57 - DEBUG - Data success. Details: HTTP Status 200, Message: Done

Reconnecting after prtg-server restart / unreachable

When the PRTG-Mainserver is unreachable (maybe for 20, 30 Seconds due a reboot after an update or so) the miniprobe disconnects and never reconnects. We have to manually restart all miniprobes. Is this an known issue?

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.