/[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.1 by logarno, Tue Nov 25 00:45:03 2003 UTC revision 1.2 by logarno, Mon Dec 1 23:43:26 2003 UTC
# Line 1  Line 1 
1    # Author : Arnaud Desmons (adesmons@mandrakesoft.com)
 # Author : Charles LONGEAU (chl@tuxfamily.org)  
 #  
2  #  #
3  # Copyright (C) 2002 Charles LONGEAU (chl@tuxfamily.org)  # Copyright (C) 2002 Charles LONGEAU (chl@tuxfamily.org)
4    #                    Arnaud Desmons (adesmons@mandrakesoft.com)
5  #  #
6  # This program is free software; you can redistribute it and/or modify  # This program is free software; you can redistribute it and/or modify
7  # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
# Line 18  Line 17 
17  # along with this program; if not, write to the Free Software  # along with this program; if not, write to the Free Software
18  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19    
20  # Libconf Template : xinetd  # Libconf Template : nagios
21  #  #
22  # This templates is used to parse xinetd style configuration files.  # This templates is used to parse nagios style configuration files.
23  #  #
24    
25  package Libconf;  package Libconf;
26    
27  $templates{nagios} = {  $templates{nagios} = {
28                             rules => [                             rules => [
                                      q(  
                                        if ($in =~ s/^\s*{\s*$//) {  
                                            $matched = 1;  
                                        }  
                                       ),  
29                                       q(                                       q(
30                                         if ($in =~ s/^\s*}\s*$//) {                                         if ($in =~ s/^\s*}\s*$//) {
31                                             $atom->{type} = 'ENDSECTION';                                             $atom->{type} = 'ENDSECTION';
# Line 39  $templates{nagios} = { Line 33  $templates{nagios} = {
33                                         }                                         }
34                                        ),                                        ),
35                                       q(                                       q(
36                                         if ($in =~ s/^\s*define\s*(\S+?){?\s*$//) {                                         if ($in =~ s/^\s*define\s+(\S+)\s*{\s*$//) {
37                                             $atom->{type} = 'SECTION';                                             $atom->{type} = 'SECTION';
38                                             $atom->{section_name} = $1;                                             $atom->{section_name} = $1;
39                                             $keep_atom = 1;                                             $atom->{sections} = [ ];
40                                             $out->{line_continued} = 1;                                             $out->{current_sections} = [ { name => $1 } ];
                                            $out->{current_section} = { name => $1 };  
                                            $keep_atom = 1;  
41                                             $matched = 1;                                             $matched = 1;
42                                         }                                         }
43                                       ),                                       ),
# Line 59  $templates{nagios} = { Line 51  $templates{nagios} = {
51                                             $atom->{type} = 'KEY_VALUE';                                             $atom->{type} = 'KEY_VALUE';
52                                             $atom->{key} = $1;                                             $atom->{key} = $1;
53                                             $atom->{value} = [split(/\s*,\s*/, $3)];                                             $atom->{value} = [split(/\s*,\s*/, $3)];
54                                             $out->{current_section} and $atom->{sections} = [ $out->{current_section} ];                                             $atom->{sections} = [ @{$out->{current_sections}} ];
55                                             $matched = 1;                                             $matched = 1;
56                                         }                                         }
57                                       ),                                       )
                                      q(  
                                        if ($in =~ s/^\s*(include(dir)?)\s+(.*)\s*$//) {  
                                            $atom->{type} = 'INCLUDE';  
                                            $atom->{key} = $1;  
                                            $atom->{value} = $3;  
                                            $matched = 1;  
                                        }  
                                      ),  
58                                      ],                                      ],
59                             comments => [ ['#'] ],                             comments => [ ['#'] ],
60                             comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"),                             comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"),
61                             output => {                             output => {
62                                        KEY_VALUE => q(                                        KEY_VALUE => q(
63                                              my ($key, $value) = ($atom->{key}, $atom->{value});                                            my ($key, $value) = ($atom->{key}, join(', ', @{$atom->{value}}));
64                                              return qq($key = $value\n);                                            $output_indentation = $out->{current_indentation} ||= 1;
65                                        ),                                            $output_text = qq($key $value);
                                       INCLUDE => q(  
                                             my ($key, $value) = ($atom->{key}, $atom->{value});  
                                             return qq($key $value\n);  
66                                        ),                                        ),
67                                        SECTION => q(                                        SECTION => q(
68                                              return qq($atom->{section_name}\n{\n);                                            $output_indentation = 0;
69                                              $output_text = qq(define $atom->{section_name} \{);
70                                              $out->{current_indentation} = 1;
71                                        ),                                        ),
72                                        ENDSECTION => q(                                        ENDSECTION => q(
73                                              return qq(}\n);                                            $output_indentation = 0;
74                                              $output_text = qq(\});
75                                              $out->{current_indentation} = 1;
76                                        ),                                        ),
77                                       },                                       },
78                             edit_atom => q(                             edit_atom => q(

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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