Splunk Dev

Unable to run Pyhton script which came default with Cybereason app

Reddi694325
Path Finder

Reddi694325_0-1616254180384.png

 

When I ran the python script the above error throwing as shown in the screen shot. Installed python3 on the environment.  Could some help me with the same. 

 

Labels (3)
0 Karma
1 Solution

Reddi694325
Path Finder

Hi team, 

Finally cracked it. 

 

Step -1

Might have to add environment variables for Splunk and check whether are you able to run Splunk command globally. 

Step -2 

Import the proper module related to the script. 

Example:- 
The below screen shot indicates the error. 

Reddi694325_0-1616302900730.png

to resolve the above issue below module need to import 

from splunk.appserver.mrsparkle.lib.util import make_splunkhome_path

Post importing the module the issue resolved 

Thanks & Regards,

Reddi. 

 

View solution in original post

0 Karma

Reddi694325
Path Finder

Reddi694325_0-1616259108731.png

Hi richgalloway,

 

I ran it but no positive sign. I am unable to understand where am I missing

0 Karma

Vardhan
Contributor

Hi @Reddi694325 ,

 

you are running the command in /opt/splunk/bin   .But the script was exist in  /opt/splunk/etc/apps/cybearreasonforsplunk/bin directory.

Run the command in /opt/splunk/etc/apps/cybearreasonforsplunk/bin/splunk cmd python cybereason.py 

And see whether its works or not.

0 Karma

Reddi694325
Path Finder

Reddi694325_0-1616262833758.png

 

Hi Vardhan,

In the previous case I ran in both the places like from Splunk_Home/bin and from App/Bin. For better understanding  I ran the command as you suggested and the screenshot is pasted here. Kindly check and help me with the same. 

Thanks In Advance.

Thanks & Regards,

Reddy.

0 Karma

Reddi694325
Path Finder

Hi team, 

Finally cracked it. 

 

Step -1

Might have to add environment variables for Splunk and check whether are you able to run Splunk command globally. 

Step -2 

Import the proper module related to the script. 

Example:- 
The below screen shot indicates the error. 

Reddi694325_0-1616302900730.png

to resolve the above issue below module need to import 

from splunk.appserver.mrsparkle.lib.util import make_splunkhome_path

Post importing the module the issue resolved 

Thanks & Regards,

Reddi. 

 

0 Karma

Reddi694325
Path Finder

Hi,

The issue got resolved by adding Splunk home path in environment variables. But another problem started as shown below. 

 

[root@Searchhead2 bin]# vi cybereason.py
[root@Searchhead2 bin]# splunk cmd python cybereason.py
Traceback (most recent call last):
File "cybereason.py", line 25, in <module>
_SPLUNK_HOME = make_splunkhome_path([""])
NameError: name 'make_splunkhome_path' is not defined
[root@Searchhead2 bin]#

 

Could some one let me know what is the error related to. 

I understood like we need to define make_splunk_home_path. But don't know where to define. 

 

Kindly help me with the same. 

 

Thanks & Regards,

Reddi

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There's no need to install Python 3 because it comes with Splunk Enterprise.  Be sure to run the scripts that come with apps in the Splunk environment.

splunk cmd python cybereason.py
---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...