11#!/usr/bin/env python
2- #Copyright (c) 2014, Paessler AG <[email protected] > 3- #All rights reserved.
4- #Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
2+ # Copyright (c) 2014, Paessler AG <[email protected] > 3+ # All rights reserved.
4+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
55# following conditions are met:
6- #1. Redistributions of source code must retain the above copyright notice, this list of conditions
6+ # 1. Redistributions of source code must retain the above copyright notice, this list of conditions
77# and the following disclaimer.
8- #2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
8+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
99# and the following disclaimer in the documentation and/or other materials provided with the distribution.
10- #3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
10+ # 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
1111# or promote products derived from this software without specific prior written permission.
1212
13- #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
13+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
1414# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1515# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
1616# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2020# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2121
2222
23- ### PRTG Python Miniprobe
24- ### Miniprobe needs at least Python 2.7 because of "importlib"
25- ### If older python version is used you will have to install "importlib"
23+ # PRTG Python Miniprobe
24+ # Miniprobe needs at least Python 2.7 because of "importlib"
25+ # If older python version is used you will have to install "importlib"
2626
2727# import general modules
2828import sys
4646 import multiprocessing
4747except Exception as e :
4848 print e
49- #sys.exit()
5049
5150# Implemented for internal testing only. Not for public usage!
5251http = False
@@ -94,8 +93,6 @@ def main():
9493 data_announce = mini_probe .create_parameters (config , announce_json , 'announce' )
9594 logging .debug ("Announce Data: %s" % data_announce )
9695 json_history = []
97- timeout = False
98-
9996 while not announce :
10097 try :
10198 # announcing the probe and all sensors
@@ -107,8 +104,7 @@ def main():
107104 logging .info ("ANNOUNCE request successfully sent to PRTG Core Server at %s:%s."
108105 % (config ["server" ], config ["port" ]))
109106 logging .debug ("Connecting to %s:%s" % (config ["server" ], config ["port" ]))
110- logging .debug ("Status Code: %s | Message: %s" % (request_announce .status_code ,
111- request_announce .text ))
107+ logging .debug ("Status Code: %s | Message: %s" % (request_announce .status_code , request_announce .text ))
112108 request_announce .close ()
113109 except requests .exceptions .Timeout :
114110 logging .error ("ANNOUNCE Timeout: " + str (data_announce ))
@@ -137,8 +133,8 @@ def main():
137133 logging .debug (request_task .text )
138134 try :
139135 json_response = request_task .json ()
140- except Exception as e :
141- logging .info ("Error: %s! Server returned: %s" % (e , request_task .text ))
136+ except Exception as ex :
137+ logging .info ("Error: %s! Server returned: %s" % (ex , request_task .text ))
142138 request_task .close ()
143139 gc .collect ()
144140 task = True
@@ -147,8 +143,8 @@ def main():
147143 logging .debug ("task_url: " + url_task + "\n task_data: " + str (task_data ))
148144 except requests .exceptions .Timeout :
149145 logging .error ("TASK Timeout: " + str (task_data ))
150- logging .debug ("Timeout encountered. Need to write more code to handle timeoutzzzzz: %s" % json_history )
151- timeout = True
146+ logging .debug ("Timeout encountered. Need to write more code to handle timeoutzzzzz: %s"
147+ % json_history )
152148 except Exception as announce_error :
153149 logging .error (announce_error )
154150 time .sleep (int (config ['baseinterval' ]) / 2 )
@@ -178,13 +174,14 @@ def main():
178174 while len (json_payload_data ) < len (element ):
179175 out = out_queue .get ()
180176 json_payload_data .append (out )
181- except Exception as e :
182- logging .error (e )
177+ except Exception as ex :
178+ logging .error (ex )
183179 pass
184180
185181 url_data = mini_probe .create_url (config , 'data' , http )
186182 try :
187- request_data = requests .post (url_data , data = json .dumps (json_payload_data ), verify = False , timeout = 30 )
183+ request_data = requests .post (url_data , data = json .dumps (json_payload_data ),
184+ verify = False , timeout = 30 )
188185 logging .info ("DATA request successfully sent to PRTG Core Server at %s:%s. Status: %s"
189186 % (config ["server" ], config ["port" ], request_data .status_code ))
190187 logging .debug ("data_url: " + url_data + "\n data_data: " + str (json_payload_data ))
0 commit comments