def ipconnections(target, **kwargs):
 if (not target):
  raise Exception('Invalid target for ipconnections()')
 output_file = NamedTemporaryFile()
 cmd = ['sudo', '/usr/sbin/dtrace', '-C']
 if ('timeout' in kwargs):
  cmd += [('-DANALYSIS_TIMEOUT=%d' % kwargs['timeout'])]
 cmd += ['-s', path_for_script('ipconnections.d')]
 cmd += ['-o', output_file.name]
 if ('args' in kwargs):
  line = ('%s %s' % (sanitize_path(target), ' '.join(kwargs['args'])))
  cmd += ['-c', line]
 else:
  cmd += ['-c', sanitize_path(target)]
 with open(os.devnull, 'w') as f:
  handler = Popen(cmd, stdout=f, stderr=f)
 for entry in filelines(output_file):
  if ('## ipconnections.d done ##' in entry.strip()):
   break
  (yield _parse_single_entry(entry.strip()))
 output_file.close()

def ipconnections ( target , ** kwargs ) : if ( not target ) : raise Exception ( 'Invalid target for ipconnections()' ) output_file = NamedTemporaryFile ( ) cmd = [ 'sudo' , '/usr/sbin/dtrace' , '-C' ] if ( 'timeout' in kwargs ) : cmd += [ ( '-DANALYSIS_TIMEOUT=%d' % kwargs [ 'timeout' ] ) ] cmd += [ '-s' , path_for_script ( 'ipconnections.d' ) ] cmd += [ '-o' , output_file . name ] if ( 'args' in kwargs ) : line = ( '%s %s' % ( sanitize_path ( target ) , ' ' . join ( kwargs [ 'args' ] ) ) ) cmd += [ '-c' , line ] else : cmd += [ '-c' , sanitize_path ( target ) ] with open ( os . devnull , 'w' ) as f : handler = Popen ( cmd , stdout = f , stderr = f ) for entry in filelines ( output_file ) : if ( '## ipconnections.d done ##' in entry . strip ( ) ) : break ( yield _parse_single_entry ( entry . strip ( ) ) ) output_file . close ( )
returns a list of ip connections made by the target .