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

(Ive also tried str(path))

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 completely fine

What am I doing wrong?

1 Answer 1

2

Pass "add" and "monitor" as separate arguments:

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

It's how the shell would naturally pass it, so that's what it expects.

Sign up to request clarification or add additional context in comments.

1 Comment

Ugh, I knew it would have been something simple and stupid I was doing wrong. Thanks, man.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.