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.36 by tdb, Wed Nov 14 16:41:30 2001 UTC vs.
Revision 1.40 by tdb, Mon Nov 19 22:31:18 2001 UTC

# Line 33 | Line 33 | use vars qw (
33               $fqdn
34               $pidfile
35               $retry_wait
36 <             @statgrab
36 >             @data
37              );
38  
39   if (@ARGV != 2) {
# Line 257 | Line 257 | sub tcp_configure() {
257   #-----------------------------------------------------------------------
258   sub send_udp_packet() {
259  
260 <    @statgrab = `./statgrab.pl`;
260 >    my($plugins_dir) = "plugins";
261      
262 +    opendir PLUGINS, $plugins_dir;
263 +    my(@plugins) = readdir PLUGINS;
264 +    foreach my $plugin (@plugins) {
265 +        push @data, `$plugins_dir/$plugin` if -x "$plugins_dir/$plugin" && -f "$plugins_dir/$plugin";
266 +    }
267 +    
268      # get some extra data
269      my($date) = time;
270      my($ip);
271      $ip = inet_ntoa(scalar(gethostbyname(hostname())) || 'localhost') or $ip = 'localhost';
272      
273      # add some extra data to the array
274 <    push(@statgrab, "packet.attributes.seq_no=$seq_no");
275 <    push(@statgrab, "packet.attributes.machine_name=$fqdn");
276 <    push(@statgrab, "packet.attributes.date=$date");
277 <    push(@statgrab, "packet.attributes.type=data");
278 <    push(@statgrab, "packet.attributes.ip=$ip");
274 >    push(@data, "packet.attributes.seq_no=$seq_no");
275 >    push(@data, "packet.attributes.machine_name=$fqdn");
276 >    push(@data, "packet.attributes.date=$date");
277 >    push(@data, "packet.attributes.type=data");
278 >    push(@data, "packet.attributes.ip=$ip");
279      
280 +    # sort the data
281 +    @data = sort(@data);
282 +    
283      # turn the array into some nice XML
284      my($xml) = &make_xml("", "");
285      
# Line 388 | Line 397 | sub write_pid() {
397  
398   #-----------------------------------------------------------------------
399   # make_xml
400 < # Turns an array of statgrab data into an XML string.
400 > # Turns an array of plugins data into an XML string.
401   #-----------------------------------------------------------------------
402   sub make_xml() {
403      my($curlevel, $curline) = @_;
404      my($xmltemp) = ""; my($curtag) = ""; my($attributes) = "";
405 <    while(true) {
406 <        $curline = shift(@statgrab) if $curline eq ""; chomp $curline;
405 >    while(1) {
406 >        $curline = shift(@data) if $curline eq ""; chomp $curline;
407          if($curline =~ /^$curlevel([^\.\s]+\.)/) {
408              $curtag=$1;
409          }
# Line 407 | Line 416 | sub make_xml() {
416          else {
417              $xmltemp .= &make_xml("$curlevel$curtag", $curline);
418          }
419 <        my($nextline) = $statgrab[0]; chomp $nextline if defined $nextline;
419 >        my($nextline) = $data[0]; chomp $nextline if defined $nextline;
420          $curtag =~ s/(.*)\./$1/;                
421 <        if(defined $nextline && $nextline =~ /^$curlevel$curtag\./) {
421 >        if((defined $nextline) && ($nextline =~ /^$curlevel$curtag\./)) {
422              $curline = "";
423          }
424          else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines