Exemplo n.º 1
0
  def Layout(self, request, response):
    """Manage content pane depending on passed in query parameter."""

    client_id = request.REQ.get("client_id")
    if client_id:
      client_id = rdfvalue.ClientURN(client_id)
      client = aff4.FACTORY.Open(client_id, token=request.token)

      self.last_crash = None
      crash = client.Get(client.Schema.LAST_CRASH)
      if crash:
        time_since_crash = rdfvalue.RDFDatetime().Now() - crash.timestamp
        if time_since_crash < self.MAX_TIME_SINCE_CRASH:
          self.last_crash = FormatLastSeenTime(crash.timestamp)

      self.disk_full = GetLowDiskWarnings(client)

      ping = client.Get(client.Schema.PING)
      if ping:
        age = ping
      else:
        age = 0

      # Also check for proper access.
      aff4.FACTORY.Open(client.urn.Add("fs"), token=request.token)

      self.icon = OnlineStateIcon(age).RawHTML(request)
      self.last_seen_msg = FormatLastSeenTime(age)

      ip = client.Get(client.Schema.CLIENT_IP)
      (status, description) = utils.RetrieveIPInfo(ip)
      self.ip_icon = IPStatusIcon(status).RawHTML(request)
      self.ip_description = description

    return super(StatusRenderer, self).Layout(request, response)
Exemplo n.º 2
0
 def testIPInfo(self):
     for ip, result in [
         ("", utils.IPInfo.UNKNOWN),
         ("192.168.0.1", utils.IPInfo.INTERNAL),
         ("10.0.0.7", utils.IPInfo.INTERNAL),
         ("69.50.225.155", utils.IPInfo.EXTERNAL),
     ]:
         rdf_ip = rdfvalue.RDFString(ip)
         info, _ = utils.RetrieveIPInfo(rdf_ip)
         self.assertEqual(info, result)
Exemplo n.º 3
0
    def Layout(self, request, response):
        """Manage content pane depending on passed in query parameter."""

        client_id = request.REQ.get("client_id")
        if client_id:
            client = aff4.FACTORY.Open(client_id, token=request.token)
            ping = client.Get(client.Schema.PING)
            if ping:
                age = ping
            else:
                age = 0

            # Also check for proper access.
            aff4.FACTORY.Open(client.urn.Add("fs"), token=request.token)

            self.icon = OnlineStateIcon(age).RawHTML(request)
            self.last_seen_msg = FormatLastSeenTime(age)

            ip = client.Get(client.Schema.CLIENT_IP)
            (status, description) = utils.RetrieveIPInfo(ip)
            self.ip_icon = IPStatusIcon(status).RawHTML(request)
            self.ip_description = description

        return super(StatusRenderer, self).Layout(request, response)