Developing for Splunk Enterprise

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 (4)
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. 

 

View solution in original post

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, an upvote would be appreciated.
0 Karma
Register for .conf21 Now! Go Vegas or Go Virtual!

How will you .conf21? You decide! Go in-person in Las Vegas, 10/18-10/21, or go online with .conf21 Virtual, 10/19-10/20.