Getting Data In

How to add Python modules into Splunk environment for network path monitoring?

Varsha995
Loves-to-Learn

Hi All,

I am trying to monitor files and folders in network path using a basic (only the outline) Python script shown below. My Splunk environment is currently having Python version 2.7.  On running this script - getting an error like "no module named requests"/ "no module named time".

Fairly new into Splunk, so not sure how to integrate modules into the environment. Also Pip install requests command also failing with error. Could you please help with the workaround for the same. Thanks in advance! 🙂

import requests
import os
import time
#path of network directory
path =(input())
x = os.listdir(path)
creation_time = os.path.getctime(path)
local_time = time.ctime(creation_time)
print("Creation Time:", local_time)

# to read lines of text as a list
with open(path) as f:
    line=f.readlines()
print(line)

#Number of files or folders in network directory:

num = len(x)
print("Number of files/folders in directory:", num)
 
Labels (1)
Tags (3)
0 Karma
Get Updates on the Splunk Community!

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...

4 Ways the Splunk Community Helps You Prepare for .conf25

.conf25 is right around the corner, and whether you’re a first-time attendee or a seasoned Splunker, the ...