Hi @harishsplunk7 Just for anyone catching up, to confirm you specifically want to script the diag pushing, whilst this is available with --upload on the diag command it isnt possible to do this no...
See more...
Hi @harishsplunk7 Just for anyone catching up, to confirm you specifically want to script the diag pushing, whilst this is available with --upload on the diag command it isnt possible to do this non-interactively because of the password request. Ive been doing some more digging on this on my local instance, the CLI uses python's getpass to request your password for the support portal/splunk.com interactively and to my knowledge its not possible to pipe/inject into this using anything like stdin, however I did find the python calls which actually do the upload. Here is an example Python script which I believe may work for you, Ive not had chance to test it entirely yet, only in sections: import sys, os, glob
sys.path.append("/opt/splunk/lib/python3.9/site-packages")
from splunk.clilib import info_gather
# Locate latest diag file in SPLUNK_HOME
SPLUNK_HOME = os.environ.get("SPLUNK_HOME", "/opt/splunk")
diag_files = sorted(glob.glob(os.path.join(SPLUNK_HOME, "diag-*.tar.gz")))
if not diag_files:
raise FileNotFoundError("No diag file found")
diag_file = diag_files[-1]
class CustomOptions:
def __init__(self, upload_user, upload_password, case_number, upload_description):
self.upload_user = upload_user
self.upload_password = upload_password
self.case_id = case_number
self.upload_description = upload_description
self.upload_uri="https://api.splunk.com"
options = CustomOptions(
upload_user="your_username",
upload_password="your_password",
case_number="1234567",
upload_description="Automated diag upload",
)
result = info_gather.upload_to_splunkcom(diag_file, options)
print("Upload result:", result) Did this answer help you? If so, please consider: Adding karma to show it was useful Marking it as the solution if it resolved your issue Commenting if you need any clarification Your feedback encourages the volunteers in this community to continue contributing