/[libconf]/libconf/perl-Libconf/templates/nagios_template.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/templates/nagios_template.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dams, Wed Dec 3 00:43:11 2003 UTC revision 1.4 by dams, Wed Dec 3 02:08:38 2003 UTC
# Line 51  $templates{nagios} = { Line 51  $templates{nagios} = {
51                                        ),                                        ),
52                                       q(                                       q(
53                                         if ($in =~ s/^\s*(\S+)\s+(.*)\s*$//) {                                         if ($in =~ s/^\s*(\S+)\s+(.*)\s*$//) {
54                                             $atom->{type} = 'KEY_VALUE';                                             $atom->{type} = 'KEY_LIST';
55                                             $atom->{key} = $1;                                             $atom->{key} = $1;
56                                             $atom->{value} = [split(/\s*,\s*/, $2)];                                             $atom->{list} = [split(/\s*,\s*/, $2)];
57                                             $atom->{sections} = [ @{$out->{current_sections}} ];                                             $atom->{sections} = [ @{$out->{current_sections}} ];
58                                             $matched = 1;                                             $matched = 1;
59                                         }                                         }
# Line 61  $templates{nagios} = { Line 61  $templates{nagios} = {
61                                      ],                                      ],
62                             comments => [ ['#'] ],                             comments => [ ['#'] ],
63                             output => {                             output => {
64                                        KEY_VALUE => q(                                        KEY_LIST => q(
65                                            my ($key, $value) = ($atom->{key}, join(', ', @{$atom->{value}}));                                            my ($key, $value) = ($atom->{key}, join(', ', @{$atom->{list}}));
66                                            $output_indentation = $out->{current_indentation} ||= 1;                                            $output_indentation = $out->{current_indentation} ||= 1;
67                                            $output_text = qq($key $value);                                            $output_text = qq($key $value);
68                                        ),                                        ),
# Line 88  $templates{nagios} = { Line 88  $templates{nagios} = {
88                                             }                                             }
89                                             @{@{$out->{atoms}}[$index]}{keys(%args)} = values(%args)                                             @{@{$out->{atoms}}[$index]}{keys(%args)} = values(%args)
90                                           ),                                           ),
91                              find_atom_pos => q(
92                                                 $first_atom ||= 0;
93                                                 $last_atom ||= @{$out->{atoms}}-1;
94                                                 my @res;
95                                                 foreach my $pos ($first_atom..$last_atom) {
96                                                     my $atom = $out->{atoms}->[$pos];
97                                                     my $flag = 1;
98                                                     foreach (keys(%args)) {
99                                                         if ($_ eq 'sections') {
100                                                             $atom->{sections}[0]{name} eq $args{sections}->[0]{name} or $flag = 0;
101                                                         } elsif ($_ eq 'list') {
102                                                             foreach my $i (0..@{$args{$_}}-1) {
103                                                                 $atom->{$_}->[$i] eq $args{$_}->[$i] or $flag = 0;
104                                                             }
105                                                         } else {
106                                                             $atom->{$_} eq $args{$_} or $flag = 0;
107                                                         }
108                                                     }
109                                                     $flag and push(@res, $pos);
110                                                 }
111                                                 wantarray ? @res : $res[-1];
112                                               ),
113                            };                            };
114    
115  1  1

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26