@@ -0,0 +1,1987 @@
+import sys%0Aimport os%0Aimport time%0A%0A# Includes the %22common%22 folder that comes from GitHub%0Asys.path.append(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'common'))%0Aimport bit9api%0A%0Abit9 = bit9api.bit9Api(%0A    %22https://bit9.server.xyz%22,  # Replace with actual Bit9 server URL%0A    token=%22api_token%22,  # Replace with actual Bit9 user token for VT integration%0A    ssl_verify=False  # Don't validate server's SSL certificate. Set to True unless using self-signed cert on IIS%0A)%0A%0A# Set the desired debug properties here. Documentation for this can be found here: https://github.com/carbonblack/bit9platform/tree/master/bit9PlatformAPI/docs%0AkernelTrace = 4%0AdebugLevel = 6%0AdebugDuration = 1%0A%0A# Find all computers with the specified name that are connected%0Acomps = bit9.search('v1/computer', %5B'name:DOMAIN%5CNAME', 'connected:true'%5D)%0A%0A# Iterate through each computer that was found and perform the specified actions%0Afor c in comps: %0A    print(%22Changing debug level for computer %25s (IP: %25s)%22 %25 (c%5B'name'%5D, c%5B'ipAddress'%5D))%0A    c%5B'kernelDebugLevel'%5D = kernelTrace%0A    c%5B'debugLevel'%5D = debugLevel%0A    c%5B'debugDuration'%5D = debugDuration%0A    bit9.update('v1/computer', c,'','changeDiagnostics=true')%0A%0A# Sleep for the debugDuration%0A# In order to account for some delay in setting the debugging, multiplying the debugDuration (which is in minutes) by 70 to move it into seconds and add some overhead%0AdebugDurationSeconds = debugDuration * 70%0Aprint('Sleeping for %25s seconds to let the debugging happen' %25 debugDurationSeconds)%0Afor i in range(debugDurationSeconds,0,-1):%0A    time.sleep(1)%0A    sys.stdout.write(str(i)+' ')%0A    sys.stdout.flush()%0A%0A# # Iterate through each computer again and trigger a diagnostic upload%0A# comps = bit9.search('v1/computer', %5B'name:domain%5Cexample', 'connected:true'%5D)%0Afor c in comps:%0A    print(%22Triggering diagnostic upload for computer %25s (IP: %25s)%22 %25 (c%5B'name'%5D, c%5B'ipAddress'%5D))%0A    c%5B'debugFlags'%5D = 0x01%0A    bit9.update('v1/computer', c,'','changeDiagnostics=true')%0A

Add create_diagnostics example