AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.145.178.14
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/978/cwd/usr/share/munin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /proc/978/cwd/usr/share/munin/munin-async
#! /usr/bin/perl
# -*- cperl -*-
#
# Copyright (C) 2010 Steve Schnepp
#
# 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.

use strict;
use warnings;

use Sys::Hostname;
use Data::Dumper;
use Getopt::Long;
use Pod::Usage;

use Munin::Node::SpoolReader;
use Munin::Node::SpoolWriter;

# Disable buffering
$| = 1;

my $SPOOLDIR = "/var/lib/munin/spool";
my $hostname;
my $overridehost;

my $spoolfetch;
my $vectorfetch;
my $cleanup;
my $cleanupandexit;

my $verbose;
my $debug;
my $help;

GetOptions(
        "spooldir|s=s" => \$SPOOLDIR,
        "hostname=s" => \$overridehost,
        "cleanup" => \$cleanup,
        "cleanupandexit" => \$cleanupandexit,

        "spoolfetch" => \$spoolfetch,
        "vectorfetch" => \$vectorfetch,

        "help|h" => \$help,
        "verbose|v" => \$verbose,
        "debug" => \$debug,
) or pod2usage(1);
if ($help) {
        pod2usage(1);
}


if ($cleanupandexit) {
	cleanup();
	exit;
}


# Use STDIN/STDOUT, in order to be : 
# 1. secure over internet (SSH), munin-node needs only 
#    to listen on localhost:4949
# 2. very simple to launch

my $spoolreader = Munin::Node::SpoolReader->new(
	spooldir => $SPOOLDIR,
);

$hostname = $spoolreader->get_metadata("hostname") || hostname();
$hostname = $overridehost if $overridehost;
chomp($hostname);

die "spooldir [$SPOOLDIR] not found" unless -d $SPOOLDIR;

print "# munin node at $hostname\n";

while (my $line = <>) {
	if ($line =~ m/^list/) {
		print $spoolreader->list();
	} elsif ($line =~ m/^config (\w+)/) {
		# XXX - Vector-fetching is disabled for now
		print ".\n";
	} elsif ($vectorfetch && $line =~ m/^fetch (\w+)/) {
		# Fetching all values since last time

		# XXX - Vector-fetching is disabled for now
		print ".\n";
	} elsif ($line =~ m/^spoolfetch (\d+)/) {
		my $last_epoch = $1;
		$spoolreader->fetch($1, sub { print shift(); });
		print ".\n";
	} elsif ($spoolfetch && $line =~ m/^cap/) {
		print "cap spool\n";
	} elsif ($line =~ m/^quit/) {
		last;
	} else {
		print "# Unknown command.\n";
	}
}

cleanup() if $cleanup;
exit;

sub cleanup {
	my $spoolwriter = Munin::Node::SpoolWriter->new(
		spooldir => $SPOOLDIR,
	);
	$spoolwriter->cleanup();
}

sub cat_file {
	my $filename = shift;
	return if ! -r $filename;
	
	open(FILE, "$filename");
	while(<FILE>) { 
		# remove line starting with .
		next if m/^\./;
		print $_; 
	}
	close(FILE);
}

__END__

=head1 NAME

munin-async - A program to replay spooled munin-node calls

=head1 SYNOPSIS

munin-async [options]

 Options:
     -s --spooldir <spooldir>   Directory for spooled data [/var/lib/munin/spool]
     --hostname <hostname>      Overrides the hostname [`hostname`]
     --cleanup                  Clean up the spooldir after interactive session completes
     --cleanupandexit           Clean up the spooldir and exit (non-interactive)

     --spoolfetch               Enables the "spool" capability [no]
     --vectorfetch              Enables the "vectorized" fetching capability [no]
                                  Note that without this flag, the "fetch" 
				  command is disabled.

     -v --verbose               Be verbose
     -h --help                  View this message	

Anon7 - 2022
AnonSec Team