ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/ihost.pl
(Generate patch)

Comparing projects/cms/source/host/ihost-perl/ihost.pl (file contents):
Revision 1.39 by tdb, Mon Nov 19 17:43:00 2001 UTC vs.
Revision 1.43 by tdb, Tue Dec 18 03:51:11 2001 UTC

# Line 47 | Line 47 | $seq_no = 1;
47   $retry_wait = 60;
48  
49   # write our PID to a file
50 < $pidfile = "/var/tmp/ihost.pid";
50 > # use home dir by default
51 > #$pidfile = $ENV{"HOME"};
52 > # or drop it in /var/tmp if we can't find HOME
53 > $pidfile = "/var/tmp" if not defined $pidfile;
54 > $pidfile .= "/.ihost.pid";
55   &write_pid();
56  
57   &tcp_configure();
# Line 271 | Line 275 | sub send_udp_packet() {
275      $ip = inet_ntoa(scalar(gethostbyname(hostname())) || 'localhost') or $ip = 'localhost';
276      
277      # add some extra data to the array
278 <    push(@data, "packet.attributes.seq_no=$seq_no");
279 <    push(@data, "packet.attributes.machine_name=$fqdn");
280 <    push(@data, "packet.attributes.date=$date");
281 <    push(@data, "packet.attributes.type=data");
282 <    push(@data, "packet.attributes.ip=$ip");
278 >    push(@data, "packet.attributes.seq_no $seq_no");
279 >    push(@data, "packet.attributes.machine_name $fqdn");
280 >    push(@data, "packet.attributes.date $date");
281 >    push(@data, "packet.attributes.type data");
282 >    push(@data, "packet.attributes.ip $ip");
283      
284      # sort the data
285 <    @data = sort(@data);
286 <    
285 >    @data = sort(grep(!/^$/, grep(/^packet\./, @data)));
286 >
287      # turn the array into some nice XML
288      my($xml) = &make_xml("", "");
289 <    
289 >
290      my($sock) = new IO::Socket::INET (
291                                        PeerPort => $udp_port,
292                                        PeerAddr => $filter_addr,
# Line 402 | Line 406 | sub write_pid() {
406   sub make_xml() {
407      my($curlevel, $curline) = @_;
408      my($xmltemp) = ""; my($curtag) = ""; my($attributes) = "";
409 <    while(true) {
410 <        $curline = shift(@data) if $curline eq ""; chomp $curline;
409 >    while(1) {
410 >        $curline = shift(@data) if $curline eq "";
411 >        return $xmltemp if not defined $curline;
412 >        chomp $curline;
413 >        # dealing with nest (or attributes)
414          if($curline =~ /^$curlevel([^\.\s]+\.)/) {
415              $curtag=$1;
416 +            if($curline =~ /^$curlevel$curtag([^\.\s]+)\s+(.*)$/) {
417 +                $xmltemp .= &make_xml("$curlevel$curtag", $curline);
418 +            }
419 +            elsif($curline =~ /^$curlevel$curtag(attributes)\.([^\.\s]+)\s+(.*)$/) {
420 +                $attributes .= " $2=\"$3\"";
421 +            }
422 +            else {
423 +                $xmltemp .= &make_xml("$curlevel$curtag", $curline);
424 +            }
425 +            my($nextline) = $data[0]; chomp $nextline if defined $nextline;
426 +            if((defined $nextline) && ($nextline =~ /^$curlevel$curtag/)) {
427 +                $curline = "";
428 +            }
429 +            else {
430 +                $curtag =~ s/(.*)\./$1/;
431 +                $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
432 +                return $xmltemp;
433 +            }
434          }
435 <        if($curline =~ /^$curlevel$curtag([^\.\s]+)\s+(.*)$/) {
436 <            $xmltemp .= "<$1$attributes>$2</$1>";
437 <        }
438 <        elsif($curline =~ /^$curlevel$curtag(attributes)\.([^\.=]+)=(.*)$/) {
439 <            $attributes .= " $2=\"$3\"";
440 <        }
441 <        else {
442 <            $xmltemp .= &make_xml("$curlevel$curtag", $curline);
443 <        }
444 <        my($nextline) = $data[0]; chomp $nextline if defined $nextline;
445 <        $curtag =~ s/(.*)\./$1/;                
446 <        if(defined $nextline && $nextline =~ /^$curlevel$curtag\./) {
422 <            $curline = "";
423 <        }
424 <        else {
425 <            $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
426 <            return $xmltemp;
435 >        # dealing with value
436 >        elsif($curline =~ /^$curlevel([^\.\s]+)\s+(.*)$/) {
437 >            $curtag=$1;
438 >            $xmltemp=$2;          
439 >            my($nextline) = $data[0]; chomp $nextline if defined $nextline;
440 >            if(defined $nextline && ($nextline =~ /^$curlevel$curtag\./ || $nextline =~ /^$curlevel$curtag\s+/)) {
441 >                $curline = "";
442 >            }
443 >            else {
444 >                $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
445 >                return $xmltemp;
446 >            }
447          }
448      }
449   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines