def create_audit_entry(email, username, access, command, client_ip=nil)
      begin
        hostname = `hostname`.strip
      rescue Exception => e
        hostname = 'localhost'
      end

      case access
        when :scp then
          summary  = 'SSH file copy'
          detail   = "User copied files copied (scp) to/from host."
        when :sftp then
          summary  = 'SSH interactive file transfer'
          detail   = "User initiated an SFTP session."
        when :command
          summary  = 'SSH command'
          detail   = "User invoked an interactive program."
        when :shell
          summary  = 'SSH interactive login'
          detail   = "User connected and invoked a login shell."
      end

      detail += "\nLogin:     #{username}@#{hostname}" if username
      detail += "\nClient IP: #{client_ip}" if client_ip
      detail += "\nCommand:   #{command}" if command

      log_detail = detail.gsub("\n", '; ')
      Log.info("#{summary} - #{log_detail}")

      options = {
        :name => 'audit_create_entry',
        :user_email => email,
        :summary => summary,
        :detail => detail,
        :category => RightScale::EventCategories::CATEGORY_SECURITY
      }
      send_command(options, false, AUDIT_REQUEST_TIMEOUT)

      true
    rescue Exception => e
      Log.error("#{e.class.name}:#{e.message}")
      Log.error(e.backtrace.join("\n"))
      false
    end
def create_audit_entry(email, username, access, command, client_ip=nil)
      begin
        hostname = `hostname`.strip
      rescue Exception => e
        hostname = 'localhost'
      end

      case access
        when :scp then
          summary  = 'SSH file copy'
          detail   = "User copied files copied (scp) to/from host."
        when :sftp then
          summary  = 'SSH interactive file transfer'
          detail   = "User initiated an SFTP session."
        when :command
          summary  = 'SSH command'
          detail   = "User invoked an interactive program."
        when :shell
          summary  = 'SSH interactive login'
          detail   = "User connected and invoked a login shell."
      end

      detail += "\nLogin:     #{username}@#{hostname}" if username
      detail += "\nClient IP: #{client_ip}" if client_ip
      detail += "\nCommand:   #{command}" if command

      log_detail = detail.gsub("\n", '; ')
      Log.info("#{summary} - #{log_detail}")

      options = {
        :name => 'audit_create_entry',
        :user_email => email,
        :summary => summary,
        :detail => detail,
        :category => RightScale::EventCategories::CATEGORY_SECURITY
      }
      send_command(options, false, AUDIT_REQUEST_TIMEOUT)

      true
    rescue Exception => e
      Log.error("#{e.class.name}:#{e.message}")
      Log.error(e.backtrace.join("\n"))
      false
    end
Create an audit entry to record this user's access. The entry is created
 asynchronously and this method never raises exceptions even if the
 request fails or times out. Thus, this is "best-effort" auditing and
 should not be relied upon!

 === Parameters
 email(String):: the user's email address
 username(String):: the user's email address
 access(Symbol):: mode of access; one of :scp, :sftp, :command or :shell
 command(String):: exact command that is being executed via SSH
 client_ip(String):: origin IP address

 === Return
 Returns true on success, false otherwise