-
Notifications
You must be signed in to change notification settings - Fork 4
/
yacy
executable file
·163 lines (135 loc) · 3.8 KB
/
yacy
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/perl -w
# -*- perl -*-
#
# ==========================================================================
#
# YaCy Monitoring Plugin for Munin
# Copyright (C) 2010 Christophe Nowicki
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
=head1 NAME
yacy - Munin plugin to monitor YaCy distributed search engine network.
=head1 APPLICABLE SYSTEMS
YaCy
=head1 CONFIGURATION
=head1 INTERPRETATION
The plugin shows various YaCy Network stats.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=head1 BUGS
=head1 VERSION
$Id$
=head1 AUTHOR
Christophe 'CSCMEU' Nowicki <cscm dot csquad dot org>
=head1 LICENSE
GPLv2
=cut
BEGIN {
if(!eval "require XML::Smart;") {
die("XML::Smart not found");
}
if(!eval "require LWP;") {
die("LWP not found");
}
}
use XML::Smart;
use strict;
my $host = $ENV{'host'} || 'localhost';
$0 =~ /yacy_(.+)*$/;
my $action = $1;
# Autoconf
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
print "yes\n";
exit;
}
# Suggest
if ($ARGV[0] and $ARGV[0] eq "suggest")
{
print <<EOF;
network_peers
network_documents
network_ppm
network_qpm
local_documents
local_ppm
local_qpm
EOF
exit 0;
}
die("PUDDI PUDDI PUDDI PUDDI PUDDI") unless ($action);
# Config
if ($ARGV[0] and $ARGV[0] eq "config")
{
my $titles = {
network_peers => 'YaCy Network Online Peers',
network_documents => 'YaCy Network Number of Documents',
network_ppm => 'YaCy Network Indexing Speed Pages Per Minutes',
network_qph => 'YaCy Network Query Frequency Queries Per Hour',
local_documents => 'YaCy Local Number of Documents',
local_ppm => 'YaCy Local Indexing Speed Pages Per Minutes',
local_qph => 'YaCy Local Query Frequency Queries Per Hour',
};
print <<EOF;
graph_title $titles->{$action}
graph_info $titles->{$action}
graph_category YaCy
EOF
if ($action =~ /network_(peers|documents)/) {
print <<EOF;
active.label Active
passive.label Passive
potential.label Potential
EOF
} elsif($action =~ /local_documents$/) {
print "documents.label documents\n";
} elsif($action =~ /_ppm$/) {
print "ppm.label Pages Per Minute\n";
} elsif($action =~ /_qph$/) {
print "qph.label Pages Per Hour\n";
} else {
die("PUDDI PUDDI PUDDI PUDDI PUDDI");
}
exit 0;
}
my $xml = XML::Smart->new('http://' . $host . '/Network.xml') or die("PUDDI");
if ($action =~ /network_peers/) {
print <<EOF;
active.value $xml->{peers}{active}{count}
passive.value $xml->{peers}{passive}{count}
potential.value $xml->{peers}{potential}{count}
EOF
} elsif ($action =~ /network_documents/) {
print <<EOF;
active.value $xml->{peers}{active}{links}
passive.value $xml->{peers}{passive}{links}
potential.value $xml->{peers}{potential}{links}
EOF
} elsif ($action =~ /network_ppm/) {
print "ppm.value $xml->{peers}{cluster}{ppm}\n"
} elsif ($action =~ /local_ppm/) {
print "ppm.value $xml->{peers}{your}{ppm}\n"
} elsif ($action =~ /network_qph/) {
print "qph.value $xml->{peers}{cluster}{qph}\n"
} elsif ($action =~ /local_qph/) {
print "qph.value $xml->{peers}{your}{qph}\n"
} elsif ($action =~ /local_documents/) {
print "documents.value $xml->{peers}{your}{links}\n"
} else {
}
# vim:syntax=perl