Changeset 1325

Show
Ignore:
Timestamp:
01/26/08 19:04:28 (8 months ago)
Author:
dana
Message:

Updated page.php to emit simple but nice html instead of plain text

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/wifidog/cron/page.php

    r1286 r1325  
    5555      $last_heartbeat = strtotime($nodeObject->getLastHeartbeatTimestamp()); 
    5656$time = time(); 
     57    $downtime = round((time() - $last_heartbeat)/60, 0); 
     58    $paged_addresses = ""; 
    5759 
    5860      if ($time - $last_heartbeat > 60*$minutes) {//If hostpot is down for longuer than the requested average interval 
     
    7880                  $mail->setRecipientEmail($officer->getEmail()); 
    7981                  $mail->setMessageSubject($minutes . " - " . $network->getName()." "._("node")." ".$nodeObject->getName()); 
     82                  $mail->setHighPriority(true); 
    8083                  $mail->setMessageBody(sprintf(_("Node %s (%s) has been down for %d minutes (since %s)"), $nodeObject->getName(), $nodeObject->getId(), $minutes, date("r", $last_heartbeat))); 
    8184                  $mailRetval = $mail->send(); 
    8285                  $usersMsg .= sprintf("%s: %s", $officer->getUsername(), $mailRetval?_("Success"):_("Failed sending mail"))."\n"; 
    83  
    8486              } 
    8587              $msg = sprintf("Node %s has been DOWN for %d minutes, we mailed the following %d user(s):\n%s", $nodeObject->getName(), ($time-$last_heartbeat)/60, count($usersToPage), $usersMsg) ; 
     
    99101      throw new Exception(_("No deployed nodes could not be found in the database")); 
    100102 
     103      echo "<html>\n<head>\n"; 
     104      echo "<title>Node Monitoring System</title>\n</head>\n"; 
     105      echo "<style>\n"; 
     106      echo "table {border: 1px solid black;}\n"; 
     107      echo "td {padding: 4px;}\n"; 
     108      echo "tr {border: 1px solid black;}\n"; 
     109      echo ".alert {background: #ffaaaa;}\n"; 
     110      echo "</style>"; 
     111      echo "<body>\n"; 
     112      echo "<p>Current server time: " . date("r") . "</p>"; 
     113      echo "<table>\n<tr><th>Node</th><th>Last Heartbeat</th><th>Last IP Address</th><th>Status Message</th></tr>\n"; 
    101114      foreach ($nodes_results as $node_row) 
    102115      { 
    103           $nodeObject = Node :: getObject($node_row['node_id']); 
    104           #echo $nodeObject->getName(); 
    105           #echo " - "; 
    106           #echo $nodeObject->getLastHeartbeatTimestamp(); 
    107           #echo " - "; 
     116        $nodeObject = Node :: getObject($node_row['node_id']); 
     117          echo "<tr><td>"; 
     118          echo $nodeObject->getName(); 
     119          echo "</td><td>"; 
     120          echo $nodeObject->getLastHeartbeatTimestamp(); 
     121          echo "</td><td>"; 
     122          echo $nodeObject->getLastHeartbeatIP(); 
     123          echo "</td>"; 
    108124          try { 
    109125              page_if_down_since($nodeObject, 43200);//A month 
     
    113129              page_if_down_since($nodeObject, 30);//30 min 
    114130              page_if_down_since($nodeObject, 5);//5 min 
     131              echo "<td>ok</td>"; 
    115132          } catch (Exception $e) { 
    116133              # Do nothing, we cronned this 
    117               echo $e->getMessage(); 
     134              echo "<td class=\"alert\">"; 
     135              echo $e->getMessage() . "<br>"; 
     136              echo "</td>"; 
    118137          } 
    119           #echo "<br>"; 
    120           #echo "<hr>"; 
    121           #echo "\n"; 
     138          echo "</tr>\n"; 
    122139      } 
     140      echo "</table></body></html>\n"; 
    123141  } catch (Exception $e) { 
    124142      echo $e; 
    125143  } 
    126  
    127144  /* 
    128145   * Local variables: 
     
    132149   * End: 
    133150   */ 
    134  
    135151   ?>