Splunk Dev

Problem with splunk and python commands in unix

asimmons1
New Member
splunkmonitormessage= subprocess.Popen(["sudo", "/opt/splunkforwarder/bin/splunk", "add monitor", path], stdin=subprocess.PIPE, stdout=subprocess.PIPE)

is throwing an error:

Command error: The subcommand
'/opt/logs/node_Default_Node.log'
is not valid for command 'add
monitor'. Data forwarding
configuration management tools.

Commands:
enable local-index [-parameter ] ...
disable local-index [-parameter ] ...
display local-index
add [forward-server|search-server] server
remove [forward-server|search-server] server
list [forward-server|search-server]

Objects:
forward-server a Splunk forwarder to forward data to be
indexed
search-server a Splunk server to forward searches
local-index a local search index on the Splunk server

sudo /opt/splunkforwarder/bin/splunk add monitor /opt/logs/node_Default_Node.log

works comepletely fine

What am I doing wrong?

Ive also tried str(path) in the python

Tags (3)
0 Karma

asimmons1
New Member

stackoverflow.com/a/24203342/3700086

answer found here

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...