--- projects/cms/source/host/ihost-perl/ihost.pl 2001/12/18 06:07:00 1.45 +++ projects/cms/source/host/ihost-perl/ihost.pl 2002/03/21 17:57:13 1.47 @@ -8,7 +8,7 @@ # a typical Unix/Linux box. # # $Author: tdb $ -# $Id: ihost.pl,v 1.45 2001/12/18 06:07:00 tdb Exp $ +# $Id: ihost.pl,v 1.47 2002/03/21 17:57:13 tdb Exp $ #------------------------------------------------------------ $| = 1; @@ -34,6 +34,7 @@ use vars qw ( $pidfile $retry_wait $ostype + $key @data ); @@ -61,6 +62,7 @@ $pidfile .= "/.ihost.pid"; &write_pid(); &tcp_configure(); +&send_tcp_heartbeat(); &send_udp_packet(); $last_udp_time = time; @@ -286,6 +288,7 @@ sub send_udp_packet() { push(@data, "packet.attributes.date $date"); push(@data, "packet.attributes.type data"); push(@data, "packet.attributes.ip $ip"); + push(@data, "packet.attributes.key $key"); # sort the data @data = sort(grep(!/^$/, grep(/^packet\./, @data))); @@ -374,6 +377,9 @@ sub send_tcp_heartbeat() { return; } + print $sock "KEY\n"; + $key = <$sock>; + print $sock "ENDHEARTBEAT\n"; $response = <$sock>; if (!$response eq "OK\n") { @@ -451,5 +457,15 @@ sub make_xml() { return $xmltemp; } } + # dealing with a null value + elsif($curline =~ /^$curlevel([^\.\s]+)$/) { + # simply adding a space makes the above elsif deal with it :) + # just level with an empty tag in the XML + $curline .= " "; + } + # failing all that, skip the line + else { + $curline = ""; + } } }