--- watchdog.module.orig	2007-01-23 14:07:33.000000000 -0500
+++ watchdog.module	2007-03-28 13:01:39.000000000 -0500
@@ -1,5 +1,5 @@
 <?php
-// $Id: watchdog.module,v 1.165.2.1 2007/01/23 19:07:33 dries Exp $
+// $Id$
 
 /**
  * @file
@@ -95,6 +95,15 @@ function watchdog_form_overview() {
     '#options' => $names,
     '#default_value' => $_SESSION['watchdog_overview_filter']
   );
+  $form['filterip'] = array(
+    '#type' => 'textfield',
+    '#title' => t("Filter by machine hostname"),
+    '#size' => 15,
+    '#maxlength' => 15,
+    '#default_value' => $_SESSION['watchdog_overview_filterip'],
+    '#prefix' => "<br />",
+    '#suffix' => "<br />"
+  );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Filter'));
   $form['#redirect'] = FALSE;
 
@@ -117,14 +126,25 @@ function watchdog_overview() {
     array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'),
     array('data' => t('Message'), 'field' => 'w.message'),
     array('data' => t('User'), 'field' => 'u.name'),
+    array('data' => t('Machine'), 'field' => 'w.hostname'),
     array('data' => t('Operations'))
   );
 
-  $sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid";
+  $sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.link, u.name, w.hostname FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid";
   $tablesort = tablesort_sql($header);
+  $filterip = $_SESSION['watchdog_overview_filterip'];
   $type = $_SESSION['watchdog_overview_filter'];
-  if ($type != 'all') {
-    $result = pager_query($sql ." WHERE w.type = '%s'". $tablesort, 50, 0, NULL, $type);
+  if (!empty($filterip) || $type != 'all') {
+    $sql .= " WHERE " . (!empty($filterip) ? "w.hostname = '%s'" : "") . ((!empty($filterip) && $type != 'all') ? " AND " : "") . ($type != 'all' ? "w.type = '%s'" : "");
+    if(!empty($filterip) && $type != 'all') {
+      $result = pager_query($sql . $tablesort, 50, 0, NULL, $filterip, $type);
+    }
+    elseif (!empty($filterip)) {
+      $result = pager_query($sql . $tablesort, 50, 0, NULL, $filterip);
+    }
+    elseif ($type != 'all') {
+      $result = pager_query($sql . $tablesort, 50, 0, NULL, $type);
+    }
   }
   else {
     $result = pager_query($sql . $tablesort, 50);
@@ -139,6 +159,7 @@ function watchdog_overview() {
         format_date($watchdog->timestamp, 'small'),
         l(truncate_utf8($watchdog->message, 56, TRUE, TRUE), 'admin/logs/event/'. $watchdog->wid, array(), NULL, NULL, FALSE, TRUE),
         theme('username', $watchdog),
+        $watchdog->hostname,
         $watchdog->link,
       ),
       // Attributes for tr
@@ -189,6 +210,7 @@ function theme_watchdog_form_overview($f
 
 function watchdog_form_overview_submit($form_id, $form_values) {
   $_SESSION['watchdog_overview_filter'] = $form_values['filter'];
+  $_SESSION['watchdog_overview_filterip'] = $form_values['filterip'];
 }
 
 /**
@@ -230,7 +252,7 @@ function watchdog_event($id) {
       ),
       array(
         array('data' => t('Hostname'), 'header' => TRUE),
-        $watchdog->hostname,
+        "<a href='" . variable_get('whois_service','http://www.whois.sc/') . "$watchdog->hostname' title='" . t("WHOIS") . "'>$watchdog->hostname</a>"
       ),
     );
     $attributes = array('class' => 'watchdog-event');
