--- site/cmd.php~	2005-04-27 01:47:35.000000000 +0100
+++ site/cmd.php	2005-06-14 11:44:31.000000000 +0100
@@ -85,9 +85,9 @@
 					" and host_id <= " .
 					$_SERVER["argv"][2] . ") ORDER by host_id");
 		}else{
-			print "ERROR: Invalid Arguments.  The first argument must be less than or equal to the first.\n";
-			print "USAGE: CMD.PHP [[first_host] [second_host]]\n";
-			cacti_log("ERROR: Invalid Arguments.  This rist argument must be less than or equal to the first.");
+			print "ERROR: Invalid Arguments.  The first argument must be less than or equal to the second.\n";
+			print "USAGE: CMD.PHP [first_host second_host]\n";
+			cacti_log("ERROR: Invalid Arguments.  The first argument must be less than or equal to the second.");
 		}
 	}else{
 		cacti_log("ERROR: Invalid Number of Arguments.  You must specify 0 or 2 arguments.",$print_data_to_stdout);
@@ -130,14 +130,19 @@
 	foreach ($polling_items as $item) {
 		$current_host = $item["hostname"];
 
+		$host_id = $item["host_id"];
+
+		if(empty($host_id)){
+			cacti_log("WARNING: skipping poller_item with local_data_id " . $item["local_data_id"] . " as its host_id is empty", true);
+			continue;
+		}
+
 		if ($current_host != $last_host) {
 			$new_host = true;
 			$host_down = false;
 		}
 
-		$host_id = $item["host_id"];
-
-		if (($new_host) && (!empty($host_id))) {
+		if ($new_host) {
 			$ping->host["hostname"]       = $item["hostname"];
 			$ping->host["snmp_community"] = $item["snmp_community"];
 			$ping->host["snmp_version"]   = $item["snmp_version"];
@@ -153,7 +158,7 @@
 				$ping_availability = read_config_option("availability_method");
 			}
 
-			/* for this host, get it's current status for spike detection and set default spike value */
+			/* for this host, get its current status for spike detection and set default spike value */
 			//$pre_host_status = $hosts[$host_id]["status"];
 			$set_spike_kill = FALSE;
 
