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
Get Updates on the Splunk Community!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...