# To check if host is alive in a defined port ....
# $_[0] is the host alias
# $_[1] if is true print title
sub check_host {

  local $aliasHost=$_[0];
  local $grpalias;
  local $grpname;
  local $title;
  local $port;
  local $hosts_status;

  if ( !%h_hosts ) { %h_hosts=&list_hosts(); };
  if (defined($h_hosts{$_[0]}) ) { 
      if ( !%h_grphosts ) { %h_grphosts=&list_grphosts(); };
  } else {
      return "";
  }
  $grpalias=$h_hosts{$_[0]}->{'grpalias'};
  $grpname=$h_grphosts{$grpalias}->{'name'};
  $title="$h_hosts{$_[0]}->{name} [$grpname] ($h_hosts{$_[0]}->{ipname})";
  if ( $_[1] eq "true" ) { print "<tr><td>$title</td></tr>\n"; }
  if ( $DebugFile ) { print DebugFile "$title \n"; }
  $host_status=&text('responding_on',$h_hosts{$_[0]}->{portalive});
  &check_socket($h_hosts{$item}->{ipname}, $h_hosts{$_[0]}->{portalive}, $rv->{'fh'}, \$host_status);
  &webmin_log("$h_hosts{$_[0]}->{ipname} socket","ipalive","title=>$title||status=>$hosts_status||port=>$h_hosts{$_[0]}->{portalive}",$h_hosts{$_[0]});
  if ( $DebugFile ) { print DebugFile "$hosts_status \n"; }
  return $hosts_status;
}
