Remove agent scripts

Leave a note that they have been moved to https://github.com/librenms/librenms-agent
The goal is to prevent divergence.
This commit is contained in:
Tony Murray 2016-07-21 22:34:11 -05:00
parent 5ca2eab0dc
commit 6119aa9c22
15 changed files with 2 additions and 1916 deletions

View File

@ -1,5 +1,3 @@
These are local plugin scripts for the LibreNMS Unix Agent.
Scripts for the LibreNMS Agent have been moved.
*DO NOT* put all of these files into your local folder, only use the scripts you want.
Make sure that you configure any scripts that require configuration. (MySQL!)
https://github.com/librenms/librenms-agent

View File

@ -1,92 +0,0 @@
#!/usr/bin/env perl
# Original python script Copyright (C) 2009 Glen Pitt-Pladdy
#
# 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.
use LWP::Simple;
$CACHETIME = 30;
$CACHEFILE = '/tmp/agent-local-apache';
# check for cache file newer CACHETIME seconds ago
if ( -f $CACHEFILE && time - (stat( $CACHEFILE ))[9] < $CACHETIME) {
# use cached data
#print "Using cached data from file $CACHEFILE.\n";
open (INFILE, "<$CACHEFILE" )
or die "File open failure: $CACHEFILE\n";
@data = <INFILE>;
close INFILE;
} else {
# grab the status URL (fresh data)
@data = split /(\n)/, LWP::Simple::get( 'http://localhost/server-status?auto' )
or die "Data fetch failure.\n";
# write file
$tmpfile = "$CACHEFILE.TMP.$PID";
open (OUTFILE, ">$tmpfile")
or die "File open failure: $tmpfile\n";
print OUTFILE @data;
close OUTFILE;
rename ( $tmpfile, $CACHEFILE );
}
print "<<<apache>>>\n";
# dice up the data
@scoreboardkey = ( '_', 'S', 'R', 'W', 'K', 'D', 'C', 'L', 'G', 'I', '.' );
%params = {};
foreach $line (@data) {
chomp $line;
@fields = split( /: /, $line);
if ($fields[0] eq 'Scoreboard') {
# count up the scoreboard into states
%states = {};
foreach $state (@scoreboardkey) {
$states{$state} = 0;
}
foreach $state ( split(//, $fields[1]) ) {
$states{$state}++;
}
} elsif ($fields[0] eq 'Total kBytes') {
# turn into base (byte) value
$params{$fields[0]} = int($fields[1])*1024;
} else {
# just store everything else
$params{$fields[0]} = $fields[1];
}
}
# output the data in order (this is because some platforms don't have them all)
@dataorder = (
'Total Accesses',
'Total kBytes',
'CPULoad',
'Uptime',
'ReqPerSec',
'BytesPerSec',
'BytesPerReq',
'BusyServers',
'IdleServers'
);
foreach $param (@dataorder) {
if (exists $params{$param}) {
print $params{$param}."\n";
} else {
# not all Apache's have all stats
print "U\n";
}
}
# print the scoreboard
foreach $state (@scoreboardkey) {
print $states{$state}."\n";
}

View File

@ -1,21 +0,0 @@
#!/bin/bash
# (c) 2015, f0o@devilcode.org
# 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 3 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, see <http://www.gnu.org/licenses/>.
stats="/etc/bind/named.stats"
echo "<<<bind>>>"
> $stats
rndc stats && cat $stats

View File

@ -1,9 +0,0 @@
#!/bin/bash
echo '<<<dmi>>>'
# requires dmidecode
for FIELD in bios-vendor bios-version bios-release-date system-manufacturer system-product-name system-version system-serial-number system-uuid baseboard-manufacturer baseboard-product-name baseboard-version baseboard-serial-number baseboard-asset-tag chassis-manufacturer chassis-type chassis-version chassis-serial-number chassis-asset-tag processor-family processor-manufacturer processor-version processor-frequency
do
echo $FIELD=$(dmidecode -s $FIELD)
done

View File

@ -1,20 +0,0 @@
#!/bin/bash
# Cache the file for 30 minutes
# If you want to override this, put the command in cron.
# We cache because it is a 1sec delay, which is painful for the poller
if [ -x /usr/bin/dpkg-query ]; then
DATE=$(date +%s)
FILE=/tmp/agent-local-dpkg
if [ ! -e $FILE ]; then
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
fi
FILEMTIME=$(stat -c %Y $FILE)
FILEAGE=$(($DATE-$FILEMTIME))
if [ $FILEAGE -gt 1800 ]; then
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
fi
echo "<<<dpkg>>>"
cat $FILE
fi

View File

@ -1,372 +0,0 @@
#!/usr/bin/perl
=head1 NAME
check_drbd - Nagios plugin for DRBD
=head1 SYNOPSIS
B<check_drbd> [B<--verbose> | B<-v>]
=head1 DESCRIPTION
B<check_drbd> is a Nagios plugin for DRBD. It checks the connection state,
resource roles and disk states for every configured DRBD resource, and
produces a WARNING or CRITICAL alert if anything is amiss. The states
of both the local and remote sides of each connection are monitored.
=head2 Nagios status information
The status information emitted by this plugin is similar to the information
in F</proc/drbd>:
drbd0: Connected Primary/Secondary UpToDate/UpToDate
| | | | | |
| | | | | Remote disk state
| | | | Local disk state
| | | Remote resource role
| | Local resource role
| Connection state
DRBD device
If more than one device is present, and all devices are OK, the output is
summarised:
drbd0: PriConUpT, drbd1: SecConUpT
If any devices are not OK, the output contains their statuses in full.
=head2 Nagios performance data
Complete performance data is emitted for all configured DRBD resources:
=over
=item drbdI<*>_ns
=item drbdI<*>_nr
The volume of network data sent to and received from the peer, in kiB.
=item drbdI<*>_dw
=item drbdI<*>_dr
The volume of network data written to and read from the local disk, in kiB.
=item drbdI<*>_al
The number of updates of the activity log area of the metadata.
=item drbdI<*>_lo
The number of open requests to the local I/O subsystem issued by DRBD.
=item drbdI<*>_pe
The number of requests sent to the peer but not yet been answered by the latter.
=item drbdI<*>_ua
The number of requests received by the peer but not yet been answered by the latter.
=item drbdI<*>_ap
The number of block I/O requests forwarded by DRBD, but not yet answered by DRBD.
=item drbdI<*>_ep
The number of epoch objects.
=item drbdI<*>_oos
The amount of storage currently out-of-sync, in kiB.
=back
=head1 OPTIONS
=over
=item B<-v>, B<--verbose>
Increase the verbosity of the output messages. This disables the Nagios status
information summarisation described above: all resources' statuses are printed
in full.
=back
=head1 EXIT STATUS
=over
=item 0
All resources are OK.
=item 1
Some resources are not OK, but do not need immediate attention.
=item 2
Some resources are not OK and need immediate attention.
=item 3
An error occurred while collecting the resources' statuses.
=back
=head1 FILES
F</proc/drbd>
=head1 SEE ALSO
L<The DRBD Home Page|http://www.drbd.org/>
=cut
use strict;
use warnings;
use constant BASENAME => ($0 =~ m{.*/([^/]+)})[0] || 'check_drbd';
use constant STATE_FILE => '/proc/drbd';
use constant {
OK => 0,
WARNING => 1,
CRITICAL => 2,
UNKNOWN => 3,
};
use Getopt::Long;
use IO::File;
sub help;
sub usage;
sub perfdata;
sub ok;
sub warning;
sub critical;
sub unknown;
sub get_state;
$SIG{__DIE__} = sub {
die @_ if $^S;
print @_;
exit UNKNOWN;
};
my $verbose;
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions(
'verbose|v+' => \$verbose,
'help|?' => sub { help; exit 0 },
'usage' => sub { usage; exit 0 },
) and @ARGV == 0
or do { usage; exit UNKNOWN };
my @state = get_state;
my $status = OK;
print "<<<drbd>>>\n";
foreach my $id (0 .. $#state) {
my $device = $state[$id]
or next;
# Assume CRITICAL by default
foreach (qw( cs )) {
$device->{"${_}_level"} = {
Connected => OK,
Unconfigured => OK,
StandAlone => WARNING,
SyncingAll => WARNING,
SyncingQuick => WARNING,
SyncSource => WARNING,
SyncTarget => WARNING,
VerifyS => WARNING,
VerifyT => WARNING,
Disconnecting => WARNING,
TearDown => WARNING,
StartingSyncS => WARNING,
StartingSyncT => WARNING,
WFSyncUUID => WARNING,
}->{$device->{$_}};
$device->{"${_}_level"} = CRITICAL unless defined $device->{"${_}_level"};
if ($device->{oos}) {
$device->{oos_level} = {
StartingSyncS => OK,
StartingSyncT => OK,
SyncSource => OK,
SyncTarget => OK,
PausedSyncS => OK,
PausedSyncT => OK,
}->{$device->{$_}};
$device->{oos_level} = CRITICAL unless defined $device->{oos_level};
}
}
foreach (qw( ro pro )) {
$device->{"${_}_level"} = {
Primary => OK,
Secondary => OK,
}->{$device->{$_}};
$device->{"${_}_level"} = CRITICAL unless defined $device->{"${_}_level"};
}
foreach (qw( ds pds )) {
$device->{"${_}_level"} = {
UpToDate => OK,
Consistent => OK,
Negotiating => WARNING,
Attaching => WARNING,
}->{$device->{$_}};
$device->{"${_}_level"} = CRITICAL unless defined $device->{"${_}_level"};
}
my @extra;
if ($device->{oos}) {
push @extra, sprintf '%d kiB out-of-sync', $device->{oos};
}
if ($device->{iof} !~ /^r.--(.(-)?)?$/) {
$device->{iof_level} = CRITICAL;
push @extra, sprintf 'I/O flags: %s', $device->{iof};
}
my $extra = @extra ? sprintf(' (%s)', join ', ', @extra) : '';
my $level = OK;
foreach (grep /_level$/, keys %$device) {
$level = $device->{$_} if $level < $device->{$_};
}
$status = $level if $status < $level;
$device->{level} = $level;
$device->{info} = sprintf 'drbd%d:cs=%s|ro=%s|pro=%s|ds=%s|pds=%s|extra=%s', $id, $device->{cs}, $device->{ro}, $device->{pro}, $device->{ds}, $device->{pds}, $extra;
$device->{short} = sprintf 'drbd%d: %0.3s%0.3s%0.3s%s', $id, $device->{ro}, $device->{cs}, $device->{ds}, $extra; # Role and connstate reversed, like old check_drbd
foreach (qw( ns nr dw dr al bm )) {
my $value = $device->{$_};
defined $value
or next;
perfdata "${_}=${value}";
}
foreach (qw( lo pe ua ap oos )) {
my $value = $device->{$_};
defined $value
or next;
perfdata "${_}=${value}";
}
}
@state
or critical 'No DRBD volumes present';
if ($status) {
my $message = join ', ', map $_->{info}, grep { defined and $_->{level} } @state;
if ($status == WARNING) {
warning $message;
} else {
critical $message;
}
} else {
my $message = join ', ', map { ($verbose || @state == 1) ? $_->{info} : $_->{short} } grep defined, @state;
ok $message;
}
die;
###########################################################################
sub help {
print <<EOF;
Usage: @{[BASENAME]} [OPTION...]
Check DRBD resources.
Plugin options:
-v, --verbose Increase verbosity
Help options:
-?, --help Give this help list
--usage Give a short usage message
EOF
}
sub usage {
print <<EOF;
Usage: @{[BASENAME]} [-v?] [--verbose] [--help] [--usage]
EOF
}
###########################################################################
{
my @perfdata;
sub perfdata { push @perfdata, @_ }
sub _exit {
my ($status, $message) = @_;
if (defined $message) {
print $message;
} else {
print qw( OK WARNING CRITICAL )[$status] || 'UNKNOWN';
}
if (my $perfdata = shift @perfdata) {
print "|$perfdata";
}
# print "\n";
if (@perfdata) {
print '|';
print map "$_|", @perfdata;
}
print "\n";
exit $status;
}
}
sub ok { _exit OK, @_ }
sub warning { _exit WARNING, @_ }
sub critical { _exit CRITICAL, @_ }
sub unknown { _exit UNKNOWN, @_ }
###########################################################################
sub get_state {
my $io = new IO::File(STATE_FILE)
or critical "Could not open @{[STATE_FILE]} for reading: $!";
# 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----
# ns:0 nr:20492 dw:20480 dr:124 al:5 bm:1296 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:0
my @state;
my $device;
while (<$io>) {
if (m(^ \s* (\d+): \s* cs:(\w+) \s+ (?:ro|st):(\w+)/(\w+) \s+ ds:(\w+)/(\w+) \s+ \S+ \s+ (\S+))x) {
$device = $state[$1] = {
cs => $2,
ro => $3,
pro => $4,
ds => $5,
pds => $6,
iof => $7,
};
next;
};
$device or next;
$device->{$1} = $2 while /(\w+):(\S+)/g;
}
@state;
}

View File

@ -1,10 +0,0 @@
#!/bin/bash
# hddtemp sensor readings
# needs hddtemp daemon listening on (at least) localhost
# requires netcat to be installed and in the path
# (c) 2012, Tom Laermans for Observium
echo '<<<hddtemp>>>'
nc localhost 7634
echo

View File

@ -1,13 +0,0 @@
#!/usr/bin/php
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
$stats = $m->getStats();
if(is_array($stats))
{
echo("<<<app-memcached>>>\n");
echo(serialize($m->getStats()));
echo("\n");
}
?>

View File

@ -1,14 +0,0 @@
# Lokale Einzelchecks
if cd munin-scripts
then
for skript in $(ls)
do
if [ -x "$skript" ] ; then
echo "<<<munin-$skript>>>"
./$skript
./$skript config
fi
done
cd ..
fi

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
#!/bin/bash
#############################################################
# - put this file on the nfs server somewhere like /opt/ #
# - edit your snmpd.conf and add line #
# extend nfsstat /opt/nfsstats.sh #
# - restart snmpd #
# - make sure that you have all the binaries required below #
#############################################################
CFG_NFSVER='3'
BIN_NFSSTAT='/usr/sbin/nfsstat'
BIN_TR='/usr/bin/tr'
BIN_CUT='/usr/bin/cut'
BIN_GREP='/usr/bin/grep'
BIN_PASTE='/usr/bin/paste'
BIN_RM='/usr/bin/rm'
BIN_MV='/usr/bin/mv'
LOG_OLD='/tmp/nfsstats_old'
LOG_NEW='/tmp/nfsstats_new'
$BIN_NFSSTAT -$CFG_NFSVER -n -l | $BIN_TR -s " " | $BIN_CUT -d ' ' -f 5 | $BIN_GREP -v '^$' > $LOG_NEW 2>&1
$BIN_PASTE $LOG_NEW $LOG_OLD | while read a b ; do
echo $(($a - $b))
done
$BIN_RM $LOG_OLD 2>&1
$BIN_MV $LOG_NEW $LOG_OLD 2>&1

View File

@ -1,38 +0,0 @@
#!/usr/bin/env python2
import urllib2
import re
data = urllib2.urlopen('http://127.0.0.1/nginx-status').read()
params = {}
for line in data.split("\n"):
smallstat = re.match(r"\s?Reading:\s(.*)\sWriting:\s(.*)\sWaiting:\s(.*)$", line)
req = re.match(r"\s+(\d+)\s+(\d+)\s+(\d+)", line)
if smallstat:
params["Reading"] = smallstat.group(1)
params["Writing"] = smallstat.group(2)
params["Waiting"] = smallstat.group(3)
elif req:
params["Requests"] = req.group(3)
else:
pass
dataorder = [
"Active",
"Reading",
"Writing",
"Waiting",
"Requests"
]
print "<<<nginx>>>\n";
for param in dataorder:
if param == "Active":
Active = int(params["Reading"]) + int(params["Writing"]) + int(params["Waiting"])
print Active
else:
print params[param]

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Cache the file for 30 minutes
# If you want to override this, put the command in cron.
# We cache because it is a 1sec delay, which is painful for the poller
if [ -x /bin/rpm ]; then
DATE=$(date +%s)
FILE=/tmp/agent-local-rpm
if [ ! -e $FILE ]; then
/bin/rpm -q --all --queryformat '%{N} %{V} %{R} %{ARCH} %{SIZE}\n' > $FILE
fi
FILEMTIME=$(stat -c %Y $FILE)
FILEAGE=$(($DATE-$FILEMTIME))
if [ $FILEAGE -gt 1800 ]; then
/bin/rpm -q --all --queryformat '%{N} %{V} %{R} %{ARCH} %{SIZE}\n' > $FILE
fi
echo "<<<rpm>>>"
cat $FILE
fi

View File

@ -1,4 +0,0 @@
#!/bin/bash
# example to output some temperatures
#echo "<<<temperature>>>"
#echo "/dev/sda:" `hddtemp /dev/hda -n`

View File

@ -1,18 +0,0 @@
#!/bin/bash
# (c) 2015, f0o@devilcode.org
# 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 3 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, see <http://www.gnu.org/licenses/>.
echo "<<<tinydns>>>"
head -n1 /service/dns/log/main/tinystats/tinystats.out