diff --git a/plugins/other/yacy b/plugins/other/yacy new file mode 100755 index 00000000..80ade903 --- /dev/null +++ b/plugins/other/yacy @@ -0,0 +1,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 + +=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 < '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 <{$action} +graph_info $titles->{$action} +graph_category YaCy +EOF + if ($action =~ /network_(peers|documents)/) { + print <new('http://' . $host . '/Network.xml') or die("PUDDI"); + +if ($action =~ /network_peers/) { + print <{peers}{active}{count} +passive.value $xml->{peers}{passive}{count} +potential.value $xml->{peers}{potential}{count} +EOF +} elsif ($action =~ /network_documents/) { + print <{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