SHARE
TWEET

Untitled

a guest May 31st, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import splunk.auth
  2. import splunk.rest
  3. import json
  4.  
  5. # Authenticate
  6. session_key = splunk.auth.getSessionKey(username='admin', password='changeme')
  7.  
  8. # Get lookup transforms
  9. server_response, server_content = splunk.rest.simpleRequest('/services/data/transforms/lookups?count=0&output_mode=json', sessionKey=session_key)
  10.  
  11. if server_response['status'] != '200':
  12.     raise Exception("Server response indicates that the request failed")
  13.  
  14. transforms_content = json.loads(server_content)
  15. transforms = transforms_content['entry']
  16.  
  17. # Filter down output to those that use CSV files
  18. lookup_transforms = filter(lambda x: 'filename' in x['content'], transforms)
  19.  
  20. # Print the number of CSV files found
  21. print len(lookup_transforms)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top