Skip to content

Commit aa171f1

Browse files
committed
Merge branch 'master' into experimental
Conflicts: VERSION.txt probe_installer.py sensors/port.py sensors/snmpcustom.py sensors/snmptraffic.py -> resolved
2 parents d649ecb + 061f308 commit aa171f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2185
-1010
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pyc
2+
*.log
3+
*.conf

README.md

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PythonMiniProbe
22
===============
33

4-
Current Status: EARLY BETA
4+
Current Status: BETA
55
MiniProbe POC for PRTG Network Monitor written in Python which accesses the MiniProbe Interface on the PRTG Core Server.
66

77
Prerequisites
@@ -11,21 +11,33 @@ Python 2.7+
1111
Needed modules are delivered with the probe package:
1212
- pyasn1 (https://pypi.python.org/pypi/pyasn1/0.1.7)
1313
- pysnmp (https://pypi.python.org/pypi/pysnmp/4.2.5)
14-
- requests (https://pypi.python.org/pypi/requests/2.3.0)
14+
- requests (https://pypi.python.org/pypi/requests/2.5.1)
1515

1616
Installation
1717
------------
1818
- set up your PRTG server to use HTTPS (other connection methods not allowed at the moment)
1919
- allow MiniProbes to connect (Setup -> Probes -> Allow MiniProbes to connect)
2020
- 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)
21+
- This is tested during the setup
2122
- copy the miniprobe folder to your linux machine
22-
- make the file "probe_installer.py" executable (e.g. "chmod 755 probe_installer.py")
23-
- within the folder you placed the probe.py file create another folder called "logs" (mkdir logs)
2423
- run the probe installer (e.g. "python probe_installer.py")
25-
- when asked for a username by the installer script, please choose "root" for now
2624

2725
The miniprobe should now be started. You should also be able to start/stop the same using the command /etc/init.d/probe.sh start resp. /etc/init.d/probe.sh stop
2826

27+
Instalation of DS18B20
28+
----------------------
29+
Requirements:
30+
- DS18B20
31+
- 4.7K Ohm resistor
32+
33+
Setup:
34+
- Solder the resister between pin 2 and 3 of the DS18B20 (when the flat part of the DS18B20 is facing ou, then pin 2 and 3 is from the middle pin to the right)
35+
- place Pin 1 on pin 6 on the Raspberry
36+
- place Pin 2 on pin 7 on the Raspberry
37+
- place Pin 3 on pin 1 on the Raspberry
38+
- Run the installscript of the probe and answer Yes to the question if you want to use the Raspberry Pi temperature sensor.
39+
- The installscript will now make a change to the raspberry boot process to include a special library and it will reboot the Raspberry. After the reboot, run the installer again and answer the same question again. It will now (if all is correct) detect your DS18B20 (using it's own unique serial number) and just confirm that this is correct by presing <Return> on your keyboard.
40+
2941
Debugging
3042
---------
3143

@@ -38,3 +50,90 @@ with
3850
debug:True
3951

4052
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.
53+
54+
Changelog
55+
=========
56+
14-02-2015
57+
----------
58+
- Added full support for the DS18B20 and a lot of cleanup and fixes
59+
- Also added the boot/config.txt fix for the DS18B20 that is needed on the RPi
60+
- Removed the no longer needed W1ThermSensor module from the repo
61+
as the Raspbian Image for raspberry already includes everything needed
62+
63+
02-02-2015
64+
----------
65+
- Installer cleanup and preparation for reading current config
66+
- Fix typo :(
67+
- Installer cleanup continued, added uninstall option to the installer, debug option added during installation
68+
- added W1ThermSensor module to the repo
69+
70+
26-01-2015
71+
----------
72+
- Merge pull request #2 from eagle00789/master
73+
-- Fixed Update-rd.d command
74+
-- Removed duplicate defined baseinterval check
75+
-- Fixed a bug in the installer that created the config file before any values where asked
76+
-- Added ping check for PRTG Server availability with possibility to still continue
77+
-- Added several checks and moved some code around to a function.
78+
79+
19-01-2015
80+
----------
81+
- added optional debug information
82+
83+
08-01-2015
84+
----------
85+
- fix for issue 1
86+
87+
05-11-2014
88+
----------
89+
- updated module requests
90+
91+
10-10-2014
92+
----------
93+
- dropped own logging
94+
-- now using python built in logging function (you might delete the file logger.py if existant)
95+
-- created file miniprobe.py which offers base functionality, probe.py now only does the work
96+
-- various changes and code cleanup
97+
-- added script templates for the probe_installer.py in folder /scripts
98+
-- changed version number to reflect YY.QQ.Release
99+
100+
28-08-2014
101+
----------
102+
- added module retry
103+
104+
26-08-2014
105+
----------
106+
- Updated module requests
107+
-- 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.
108+
- added VERSION.txt file
109+
-- the version number is built up from Year.Quarter.Buildnumber
110+
- moved Python version check to the beginning of the script
111+
- big code cleanup
112+
- applied PEP 8 rules to the code, some other refactoring). To be continued... (Probably tomorrow)
113+
114+
17-07-2014
115+
----------
116+
- Changed readme file, adjusted setup.py
117+
118+
07-07-2014
119+
----------
120+
- Fixed typos
121+
- Added check for logs folder
122+
123+
27-06-2014
124+
----------
125+
- Updated documentation
126+
- Merge Remote-tracking branch
127+
128+
26-06-2014
129+
----------
130+
- Updated Readme
131+
- Changed line separators
132+
- Initial Commit
133+
- Changed readme file
134+
- deleted readme
135+
136+
25-06-2014
137+
----------
138+
- Initial commit
139+

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.4.7 experimental
1+
15.1.2

miniprobe.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
import importlib
3131
import gc
3232
import logging
33-
33+
import subprocess
34+
import os
3435

3536
# import own modules
3637
sys.path.append('./')
@@ -52,7 +53,8 @@ def __init__(self):
5253
logging.basicConfig(
5354
filename="./logs/probe.log",
5455
filemode="a",
55-
level=logging.DEBUG,
56+
# level=logging.DEBUG,
57+
level=logging.INFO,
5658
format="%(asctime)s - %(levelname)s - %(message)s",
5759
datefmt='%m/%d/%Y %H:%M:%S'
5860
)
@@ -136,4 +138,13 @@ def build_announce(self, sensor_list):
136138
sensors_avail = []
137139
for sensor in sensor_list:
138140
sensors_avail.append(sensor.get_sensordef())
139-
return sensors_avail
141+
return sensors_avail
142+
143+
@staticmethod
144+
def clean_mem():
145+
"""Ugly brute force method to clean up Mem"""
146+
subprocess.call("sync", shell=False)
147+
os.popen("sysctl vm.drop_caches=1")
148+
os.popen("sysctl vm.drop_caches=2")
149+
os.popen("sysctl vm.drop_caches=3")
150+

probe.py

100644100755
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import gc
3232
import logging
3333
import socket
34+
import warnings
35+
from requests.packages.urllib3 import exceptions
3436

3537
# import own modules
3638
sys.path.append('./')
@@ -44,7 +46,6 @@
4446
print e
4547
#sys.exit()
4648

47-
4849
def main():
4950
"""
5051
Main routine for MiniProbe (Python)
@@ -57,6 +58,14 @@ def main():
5758
announce = False
5859
# read configuration file (existence check done in probe_controller.py)
5960
config = mini_probe.read_config('./probe.conf')
61+
if config['debug'] == "True":
62+
config['debug'] = True
63+
else:
64+
config['debug'] = False
65+
if config['cleanmem'] == "True":
66+
config['cleanmem'] = True
67+
else:
68+
config['cleanmem'] = False
6069
# Doing some startup logging
6170
logging.info("PRTG Small Probe '%s' starting on '%s'" % (config['name'], socket.gethostname()))
6271
logging.info("Connecting to PRTG Core Server at %s:%s" % (config['server'], config['port']))
@@ -72,7 +81,9 @@ def main():
7281
while not announce:
7382
try:
7483
# announcing the probe and all sensors
75-
request_announce = requests.get(url_announce, params=data_announce, verify=False)
84+
with warnings.catch_warnings():
85+
warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
86+
request_announce = requests.get(url_announce, params=data_announce, verify=False)
7687
announce = True
7788
logging.info("ANNOUNCE request successfully sent to PRTG Core Server at %s:%s."
7889
% (config["server"], config["port"]))
@@ -99,7 +110,12 @@ def main():
99110
while not task:
100111
json_payload_data = []
101112
try:
102-
request_task = requests.get(url_task, params=task_data, verify=False)
113+
with warnings.catch_warnings():
114+
warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
115+
request_task = requests.get(url_task, params=task_data, verify=False)
116+
if config['debug']:
117+
logging.debug(request_task.headers)
118+
logging.debug(request_task.text)
103119
json_response = request_task.json()
104120
request_task.close()
105121
gc.collect()
@@ -172,8 +188,7 @@ def main():
172188

173189
if config['cleanmem']:
174190
# checking if the clean memory option has been chosen during install then call the method to flush mem
175-
from utils import Utils
176-
Utils.clean_mem()
191+
mini_probe.clean_mem()
177192
sys.exit()
178193

179194
if __name__ == "__main__":

0 commit comments

Comments
 (0)