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

PRTG Network Monitor

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

Free Download

Top Tags


View all Tags

Network Drive Access Problem through Python Custom Sensor

Votes:

0

Your Vote:

Up

Down

I am trying to develop a custom sensor using the advanced python script sensor. The script should list the folders and files of a subdirectory located at a network shared windows folder. The folder is mapped as a network drive in the prtg server.

The script works correctly when executed from a cmd window on the prtg server but when executed from the sensor it can not find/access the network shared folder.

I have tried using the mapped drive and also unc paths but with no luck.

I have configured the sensor to run on the local probe using the Administrator Windows user (the same that the cmd uses).

bellow you can find the base script I am using:

# -*- coding: utf-8 -*-

import json
import sys
import os
from prtg.sensor.result import CustomSensorResult
from prtg.sensor.units import ValueUnit

if __name__ == "__main__":
    try:
        # data = json.loads(sys.argv[1])


        path_temp = "\\\\HOST\\folder\\path"
        #path_temp = "Z:\\folder\\path" 
        #print(path_temp+" "+str(os.path.exists(path_temp))+" "+os.getlogin())
        
        
        csr = CustomSensorResult(text=path_temp+" "+str(os.path.exists(path_temp))+" "+os.getlogin())



        print(csr.json_result)



    except Exception as e:
        csr = CustomSensorResult(text="Python Script execution error")
        csr.error = "Python Script execution error: %s" % str(e)
        print(csr.json_result)

Result from cmd:

{"prtg": {"text": "Z:\\workswift True Administrator", "result": [{"Channel": "Percentage", "Value": 87, "Unit": "Percent", "SpeedSize": "One", "VolumeSize": "One", "SpeedTime": "Second", "Mode": "Absolute", "LimitMaxError": "90", "LimitMode": 1, "LimitMinError": "10", "LimitErrorMsg": "Percentage too high"}, {"Channel": "Response Time", "Value": 4711, "Unit": "TimeResponse", "SpeedSize": "One", "VolumeSize": "One", "SpeedTime": "Second", "Mode": "Absolute"}]}}

Result from PRTG Sersor

{"prtg": {"text": "Z:\\workswift False Administrator", "result": [{"Channel": "Percentage", "Value": 87, "Unit": "Percent", "SpeedSize": "One", "VolumeSize": "One", "SpeedTime": "Second", "Mode": "Absolute", "LimitMaxError": "90", "LimitMode": 1, "LimitMinError": "10", "LimitErrorMsg": "Percentage too high"}, {"Channel": "Response Time", "Value": 4711, "Unit": "TimeResponse", "SpeedSize": "One", "VolumeSize": "One", "SpeedTime": "Second", "Mode": "Absolute"}]}}

the difference is that when run from prtg the os.path.exists(path_temp) resolves to False but not true.

PRTG VERSION: latest Python Version: PRTGs Installation: Windows Server 2016

Thank you in advance

file-monitoring files network-mapped-drives network-shared-folder python python-script-advanced-sensor

Created on Dec 4, 2020 2:03:50 PM by  bakis (0) 1

Last change on Dec 7, 2020 5:08:44 AM by  Sven Roggenhofer [Paessler Technical Support]



1 Reply

Accepted Answer

Votes:

1

Your Vote:

Up

Down

I think the main issue is that no credentials are passed; Have you found this already?

Created on Dec 7, 2020 9:21:01 AM by  Stephan Linke [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.