Changeset ae5283c7e99faf2b995945c770a82f65747b3616

Show
Ignore:
Timestamp:
03/23/07 13:54:07 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1174658047 +0000
git-parent:

[8346efda0e37e40bff49471d4d54cbc63a58ba53]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1174658047 +0000
Message:

add configuration to the XML dump

git-svn-id: https://labs.omniti.com/resmon/trunk@33 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Module.pm

    rd1c8830 rae5283c  
    6262  } 
    6363  return ($arg->{laststatus}, $arg->{lastmessage}); 
     64} 
     65sub config_as_hash { 
     66  my $self = shift; 
     67  my $conf = {}; 
     68  while(my ($key, $value) = each %$self) { 
     69    if(! ref $value) { 
     70      # only stash scalars here. 
     71      $conf->{$key} = $value; 
     72    } 
     73  } 
     74  return $conf; 
    6475} 
    6576#### Begin actual monitor functions #### 
  • lib/Resmon/Status.pm

    r8346efd rae5283c  
    5151  # unlock 
    5252} 
     53sub xml_kv_dump { 
     54  my $info = shift; 
     55  my $indent = shift || 0; 
     56  my $rv = ''; 
     57  while(my ($key, $value) = each %$info) { 
     58    $rv .= " " x $indent; 
     59    if(ref $value eq 'HASH') { 
     60      $rv .= "<$key>\n"; 
     61      $rv .= xml_kv_dump($value, $indent + 2); 
     62      $rv .= " " x $indent; 
     63      $rv .= "</$key>\n"; 
     64    } 
     65    else { 
     66      $rv .= "<$key>$value</$key>\n"; 
     67    } 
     68  } 
     69  return $rv; 
     70} 
    5371sub xml_info { 
    5472  my ($module, $service, $info) = @_; 
    5573  my $rv = ''; 
    5674  $rv .= "  <ResmonResult module=\"$module\" service=\"$service\">\n"; 
    57   while(my ($key, $value) = each %$info) { 
    58     $rv .= "    <$key>$value</$key>\n"; 
    59   } 
     75  $rv .= xml_kv_dump($info, 4); 
    6076  $rv .= "  </ResmonResult>\n"; 
    6177  return $rv; 
  • resmon

    rdf48341 rae5283c  
    7878        eval { ($check_rv, $check_mess) = $monobj->handler(); }; 
    7979      } 
    80       my $results = { last_runtime_seconds => tv_interval($starttime) }; 
     80      my $results = { 
     81        configuration => $monobj->config_as_hash(), 
     82        last_runtime_seconds => tv_interval($starttime), 
     83      }; 
    8184      if($@) { 
    8285        $results->{state} = 'BAD';