File: munin-doc

package info (click to toggle)
munin 2.999.14-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 10,036 kB
  • sloc: perl: 31,052; sh: 12,473; java: 1,924; python: 852; makefile: 336; ruby: 232; awk: 169; xml: 45; sql: 11
file content (111 lines) | stat: -rwxr-xr-x 3,096 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/perl
#
# This script provides the basis for a plugin documentation system for
# munin.  Please see "man perlpod" for the reference manual to writing
# pod files.
#
# This is a very thin veneer for re-using perldoc for our own purposes.
#
# ---
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# ---
#

require 5;

use strict;
use warnings;
use Pod::Perldoc;
use File::Find;
use Munin::Common::Defaults;

my @found = ();		# Found plugin path names, by priority

my @myargv = @ARGV;	# Save the ARGV we want for ourselves.

my ($plugin) = @myargv; # First argument is a plugin name

die "munindoc: Please name a plugin\n" unless $plugin;

my $plugin_re = quotemeta($plugin);

@ARGV=();

# Dirs in which to look for $plugin.pod and $plugin files.
my @DIRS = ("$Munin::Common::Defaults::MUNIN_LIBDIR/plugins",
	    "$Munin::Common::Defaults::MUNIN_CONFDIR/plugins");

File::Find::find({wanted => \&wanted_pod}, @DIRS);
File::Find::find({wanted => \&wanted_basename}, @DIRS);

# print "Found: ",join(", ",@found),"\n";
# exit 0;

die "munindoc: Could not find plugin\n" if (scalar(@found) == 0);

# pick only the first match
# -F  Arguments are file names, not modules
push(@ARGV, '-F', $found[0]);

exit( Pod::Perldoc->run() );

sub wanted_pod {
#    print "Want pod: $File::Find::name\n";
    /^$plugin_re\.pod$/so && push(@found,$File::Find::name);
}

sub wanted_basename {
#    print "Want basename: $File::Find::name\n";
    $_ eq $plugin && push(@found,$File::Find::name);
}

__END__

=head1 NAME

munindoc - Munin documentation

=head1 DESCRIPTION

This program displays Munin documentation, esp. plugin documentation.
Note that not all plugins are documented yet.

Most Munin commands (such as munin-run, and munindoc itself) is only
documented through the usual Unix man command.

=head1 PLUGIN DOCUMENTATION

The plugin documentation should include basic usage information,
anything you want to know about configuration, and how to interpret
the output.

Additional information typically found is usually the name of the
plugin author, licensing and "magic markers" which controls plugin
auto configuration (done by munin-node-configure).

If you want to document a plugin you can take a look at
http://munin-monitoring.org/wiki/munindoc for details on how to do it.

But all the work is handed off to the perldoc command once we have
located the Munin documentation files.

=head1 AUTHOR

  Copyright (C) 2008-2009 Nicolai Langfeldt, Linpro AS

=head1 LICENSE

GPLv2