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.11 by pjm2, Thu Feb 1 09:10:52 2001 UTC vs.
Revision 1.12 by pjm2, Thu Feb 1 09:24:54 2001 UTC

# Line 2 | Line 2
2  
3   # -----------------------------------------------------------
4   # Perl i-scream Host.
5 + # http://www.i-scream.org.uk
6   #
7   # An all-in-one script to act as an i-scream host on
8   # a typical Unix/Linux box.  You may adapt the data-gathering
# Line 71 | Line 72 | while (1) {
72  
73   exit(0);
74  
75 +
76 + #-----------------------------------------------------------------------
77 + # tcp_configure
78 + # Establishes a TCP connection to the specified i-scream filter manager.
79 + # The host then requests details from the server, such as the intervals
80 + # at which to send UDP packets.
81 + #-----------------------------------------------------------------------
82   sub tcp_configure() {
83      
84      my($sock) = new IO::Socket::INET(
# Line 85 | Line 93 | sub tcp_configure() {
93          exit(1);
94      }
95  
96 <    # Now run through the configuration process.
96 >    # Now run through the configuration process...
97      my($response);
98      
99      print $sock "STARTCONFIG\n";
# Line 155 | Line 163 | sub tcp_configure() {
163      close($sock);
164  
165      print "Configuration finished sucessfully!\n";
166 +    
167 +    return;
168   }
169  
170 +
171 +
172 +
173 + #-----------------------------------------------------------------------
174 + # send_udp_packet
175 + # Sends a UDP packet to an i-scream filter.
176 + # The packet contains XML markup describing some of the machine's state.
177 + # Receipt of UDP packets is not guaranteed.
178 + #-----------------------------------------------------------------------
179   sub send_udp_packet() {
180  
181      my(@statgrab) = `./statgrab.pl`;
# Line 191 | Line 210 | sub send_udp_packet() {
210  
211      # Build the XML packet this way, as we can clearly
212      # see the structure and contents... I like this ;-)
213 +    # [Note that the server rejects UDP packets that are
214 +    # larger than 8196 bytes]
215      my($xml) = <<EOF;
216      
217   <packet seq_no="$seq_no" machine_name="$machine_name" date="$date" type="data" ip="$ip">
# Line 238 | Line 259 | sub send_udp_packet() {
259  
260   EOF
261  
262 +    # Make the packet smaller by stripping out newlines and leading spaces.
263      $xml =~ s/\n\s*//g;
264      
265      my($sock) = new IO::Socket::INET (
# Line 250 | Line 272 | EOF
272      close($sock);
273      $seq_no++;
274      print "-";
275 +    
276 +    return;
277   }
278  
279 +
280 +
281 +
282 + #-----------------------------------------------------------------------
283 + # send_tcp_heartbeat
284 + # Establishes a TCP connection to an i-scream filter.
285 + # The heartbeat is used as a guaranteed "I'm alive" delivery mechanism.
286 + #-----------------------------------------------------------------------
287   sub send_tcp_heartbeat() {
288  
289      my($sock) = new IO::Socket::INET(
# Line 319 | Line 351 | sub send_tcp_heartbeat() {
351      
352      close($sock);
353      print "^";
354 +    
355 +    return;
356   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines