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.1 by pjm2, Fri Jan 26 17:09:29 2001 UTC vs.
Revision 1.9 by pjm2, Mon Jan 29 16:51:50 2001 UTC

# Line 1 | Line 1
1 < #!/usr/local/bin/perl -w
1 > #!/usr/bin/perl -w
2  
3   # -----------------------------------------------------------
4   # Perl i-scream Host.
# Line 48 | Line 48 | $seq_no = 1;
48   $last_udp_time = time;
49   $last_tcp_time = time;
50   while (1) {
51 <    if (time >= $last_udp_time + $udp_update_time) {
51 >    my($time) = time;
52 >    if ($time >= $last_udp_time + $udp_update_time) {
53          &send_udp_packet();
54 <        $last_udp_time = time;
54 >        $last_udp_time = $time;
55      }
56 <    if (time >= $last_tcp_time + $tcp_update_time) {
56 >    if ($time >= $last_tcp_time + $tcp_update_time) {
57          &send_tcp_heartbeat();
58 <        $last_tcp_time = time;
58 >        $last_tcp_time = $time;
59      }
60 <    `sleep 1`;
60 >    my($next_udp) = $udp_update_time - $time + $last_udp_time;
61 >    my($next_tcp) = $tcp_update_time - $time + $last_tcp_time;
62 >    my($delay);
63 >    if ($next_udp < $next_tcp) {
64 >        $delay = $next_udp
65 >    }
66 >    else {
67 >        $delay = $next_tcp;
68 >    }
69 >    `sleep $delay`;
70   }
71  
72   exit(0);
# Line 88 | Line 98 | sub tcp_configure() {
98      chop $response;
99      $last_modified = $response;
100      
101 <    print "Config last modified: ". scalar localtime $last_modified . "\n";
101 >    print "Config last modified: ". (scalar localtime $last_modified/1000) . "\n";
102  
103      print $sock "FILELIST\n";
104      $response = <$sock>;
# Line 107 | Line 117 | sub tcp_configure() {
117      chop $response;
118      $tcp_update_time = $response;
119      
120 <    print "UDP packet period: $udp_update_time seconds.\nTCP heartbeat period: $tcp_update_time.\n";
120 >    print "UDP packet period: $udp_update_time seconds.\nTCP heartbeat period: $tcp_update_time seconds.\n";
121  
122      print $sock "ENDCONFIG\n";
123      $response = <$sock>;
# Line 169 | Line 179 | sub send_udp_packet() {
179      $disk_info .= "</disk>";
180  
181      my($hostname) = hostname();
182 <    $hostname =~ s/^([^\.]*?)/$1/;
183 <    my($domainname) = `cat /etc/resolv.conf`;
184 <    $domainname =~ s/domain\s*([^\s]*?)/$1/;
182 >    $hostname =~ s/\..*$//g;
183 >    `cat /etc/resolv.conf` =~ /domain\s+([^\s]+)/;
184 >    my($domainname) = $1;
185      my($machine_name) = "$hostname.$domainname";
186      my($ip) = inet_ntoa(scalar(gethostbyname($hostname)) || 'localhost');
187  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines