1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

146
plugins/sourceds/srcds_cpu Executable file
View file

@ -0,0 +1,146 @@
#!/usr/bin/perl
#
# 2007-06-26
# Written by Ghost
#
# 2008-04-16
# Update: Wildcard version
#
# 2008-11-12
# Update: Perl RCON system
#
# Configuration variables
#
# srcdspass - RCON password
# srcdssamples - Number of samples to take (optional, default: 5)
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
# Set library path correctly
use File::Basename;
if (-l $0) {
push(@INC, dirname(readlink($0)));
}
push(@INC, dirname($0));
# Load Rcon module or exit with failuer message
if (!eval "require Rcon") {
print "Failed to load Rcon module. ";
print "Make sure Rcon.pm is copied to Munin plugins directory.\n";
exit 1;
}
# Parse hostname and port from the plugin filename
my ($HOST, $PORT) = $0 =~ m/.*_([^:]+)_(\d+)$/;
if (!defined($HOST) || !defined($PORT)) {
print "Could not parse server address from filename.\n";
exit 1;
}
# Load config variables or use default values
my $PASS = $ENV{srcdspass} || "";
my $SAMPLES = $ENV{srcdssamples} || 5;
# Print config or do plugin test if asked
my $arg = shift();
if ($arg eq 'config') {
print_config();
} elsif ($arg eq 'autoconf') {
test_service();
}
#
# Main program starts here
#
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "Could not open socket to $HOST:$PORT.\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "Could not authenticate.\n";
exit 1;
}
my $cpu_avg = 0;
my @cpu_samples;
for (my $i = 0; $i < $SAMPLES; $i++) {
my $reply = Rcon::rcon_command($sock, "stats");
if (!defined($reply)) {
print "Did not receive reply from server (sample $i).\n";
next;
}
my @reply = split(/\n/, $reply);
foreach my $statline (@reply) {
next if ($statline !~ m/\s*[\w+\.]+\s+[\w+\.]+\s+[\w+\.]+\s+\d+\s+\d+\s+[\w+\.]+\s+\d+/);
my ($cpu, $in, $out, $uptime, $users, $fps, $players) = ($statline =~ m/^\s*([\w+\.]+)\s+([\w+\.]+)\s+([\w+\.]+)\s+(\d+)\s+(\d+)\s+([\w+\.]+)\s+(\d+)/);
if (defined($cpu)) {
push(@cpu_samples, $cpu);
}
}
select(undef, undef, undef, 0.2); # Wait moment before next sample
}
# MEAN
if (@cpu_samples) {
foreach (@cpu_samples) {
$cpu_avg += int($_);
}
$cpu_avg /= ($#cpu_samples+1);
$cpu_avg = int($cpu_avg);
print "cpu.value $cpu_avg\n";
}
# MEDIAN
#if (@cpu_samples) {
# @cpu_samples = sort {$a <=> $b} @cpu_samples;
# my $median = int($#cpu_samples / 2 + 0.5);
# $cpu_avg = $cpu_samples[$median];
#}
sub print_config {
print("graph_title Server CPU usage at $HOST:$PORT\n",
"graph_args --base 1000\n",
"graph_vlabel CPU\n",
"graph_category SourceDS\n",
"graph_info The CPU usage of Source game server, such as HL2, CS:S and DoD:S.\n");
print ("cpu.label CPU\n",
"cpu.min 0\n",
"cpu.max 100\n",
"cpu.type GAUGE\n");
exit 0;
}
sub test_service {
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "no (could not open socket to $HOST:$PORT)\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "no (could not authenticate)\n";
exit 1;
}
if (!defined(Rcon::rcon_command($sock, "stats"))) {
print "no (did not receive reply from server)\n";
exit 1;
}
print "yes\n";
exit 0;
}

148
plugins/sourceds/srcds_fps Executable file
View file

@ -0,0 +1,148 @@
#!/usr/bin/perl
#
# 2007-06-26
# Written by Ghost
#
# 2008-04-16
# Update: Wildcard version
#
# 2008-11-12
# Update: Perl RCON system
#
# Configuration variables
#
# srcdspass - RCON password
# srcdssamples - Number of samples to take (optional, default: 5)
# srcdsfpsmax - Maximum FPS on the game server (optional, default: 1000)
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
# Set library path correctly
use File::Basename;
if (-l $0) {
push(@INC, dirname(readlink($0)));
}
push(@INC, dirname($0));
# Load Rcon module or exit with failuer message
if (!eval "require Rcon") {
print "Failed to load Rcon module. ";
print "Make sure Rcon.pm is copied to Munin plugins directory.\n";
exit 1;
}
# Parse hostname and port from the plugin filename
my ($HOST, $PORT) = $0 =~ m/.*_([^:]+)_(\d+)$/;
if (!defined($HOST) || !defined($PORT)) {
print "Could not parse server address from filename.\n";
exit 1;
}
# Load config variables or use default values
my $PASS = $ENV{srcdspass} || "";
my $SAMPLES = $ENV{srcdssamples} || 5;
my $MAX = $ENV{srcdsfpsmax} || 1000;
# Print config or do plugin test if asked
my $arg = shift();
if ($arg eq 'config') {
print_config();
} elsif ($arg eq 'autoconf') {
test_service();
}
#
# Main program starts here
#
my $fps_avg = 0;
my @fps_samples;
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "Could not open socket to $HOST:$PORT.\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "Could not authenticate.\n";
exit 1;
}
for (my $i = 0; $i < $SAMPLES; $i++) {
my $reply = Rcon::rcon_command($sock, "stats");
if (!defined($reply)) {
print "Did not receive reply from server (sample $i).\n";
next;
}
my @reply = split(/\n/, $reply);
foreach my $statline (@reply) {
next if ($statline !~ m/\s*[\w+\.]+\s+[\w+\.]+\s+[\w+\.]+\s+\d+\s+\d+\s+[\w+\.]+\s+\d+/);
my ($cpu, $in, $out, $uptime, $users, $fps, $players) = ($statline =~ m/^\s*([\w+\.]+)\s+([\w+\.]+)\s+([\w+\.]+)\s+(\d+)\s+(\d+)\s+([\w+\.]+)\s+(\d+)/);
if (defined($fps)) {
push(@fps_samples, $fps);
}
}
select(undef, undef, undef, 0.2); # Wait moment before next sample
}
# MEAN
if (@fps_samples) {
foreach (@fps_samples) {
$fps_avg += int($_);
}
$fps_avg /= ($#fps_samples+1);
$fps_avg = int($fps_avg);
print "fps.value $fps_avg\n";
}
# MEDIAN
#if (@fps_samples) {
# @fps_samples = sort {$a <=> $b} @fps_samples;
# my $median = int($#fps_samples / 2 + 0.5);
# $fps_avg = $fps_samples[$median];
#}
sub print_config {
print("graph_title Server FPS at $HOST:$PORT\n",
"graph_args --base 1000\n",
"graph_vlabel FPS\n",
"graph_category SourceDS\n",
"graph_info The number of frames per second generated by Source game server, such as HL2, CS:S and DoD:S.\n");
print ("fps.label FPS\n",
"fps.min 0\n",
"fps.max $MAX\n",
"fps.type GAUGE\n");
exit 0;
}
sub test_service {
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "no (could not open socket to $HOST:$PORT)\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "no (could not authenticate)\n";
exit 1;
}
if (!defined(Rcon::rcon_command($sock, "stats"))) {
print "no (did not receive reply from server)\n";
exit 1;
}
print "yes\n";
exit 0;
}

159
plugins/sourceds/srcds_inout Executable file
View file

@ -0,0 +1,159 @@
#!/usr/bin/perl
#
# 2007-06-26
# Written by Ghost
#
# 2008-04-16
# Update: Wildcard version
#
# 2008-11-12
# Update: Perl RCON system
#
# Configuration variables
#
# srcdspass - RCON password
# srcdssamples - Number of samples to take (optional, default: 5)
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
# Set library path correctly
use File::Basename;
if (-l $0) {
push(@INC, dirname(readlink($0)));
}
push(@INC, dirname($0));
# Load Rcon module or exit with failuer message
if (!eval "require Rcon") {
print "Failed to load Rcon module. ";
print "Make sure Rcon.pm is copied to Munin plugins directory.\n";
exit 1;
}
# Parse hostname and port from the plugin filename
my ($HOST, $PORT) = $0 =~ m/.*_([^:]+)_(\d+)$/;
if (!defined($HOST) || !defined($PORT)) {
print "Could not parse server address from filename.\n";
exit 1;
}
# Load config variables or use default values
my $PASS = $ENV{srcdspass} || "";
my $SAMPLES = $ENV{srcdssamples} || 5;
# Print config or do plugin test if asked
my $arg = shift();
if ($arg eq 'config') {
print_config();
} elsif ($arg eq 'autoconf') {
test_service();
}
#
# Main program starts here
#
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "Could not open socket to $HOST:$PORT.\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "Could not authenticate.\n";
exit 1;
}
my $in_avg = 0;
my @in_samples;
my $out_avg = 0;
my @out_samples;
for (my $i = 0; $i < $SAMPLES; $i++) {
my $reply = Rcon::rcon_command($sock, "stats");
if (!defined($reply)) {
print "Did not receive reply from server (sample $i).\n";
next;
}
my @reply = split(/\n/, $reply);
foreach my $statline (@reply) {
next if ($statline !~ m/\s*[\w+\.]+\s+[\w+\.]+\s+[\w+\.]+\s+\d+\s+\d+\s+[\w+\.]+\s+\d+/);
my ($cpu, $in, $out, $uptime, $users, $fps, $players) = ($statline =~ m/^\s*([\w+\.]+)\s+([\w+\.]+)\s+([\w+\.]+)\s+(\d+)\s+(\d+)\s+([\w+\.]+)\s+(\d+)/);
if (defined($in) && defined($out)) {
$in = int($in);
$out = int($out);
push(@in_samples, $in);
push(@out_samples, $out);
}
}
select(undef, undef, undef, 0.2); # Wait moment before next sample
}
# MEAN
if (@in_samples && @out_samples) {
foreach (@in_samples) {
$in_avg += int($_);
}
$in_avg /= ($#in_samples+1);
$in_avg = int($in_avg);
foreach (@out_samples) {
$out_avg += int($_);
}
$out_avg /= ($#out_samples+1);
$out_avg = int($out_avg);
print "in.value $in_avg\n";
print "out.value $out_avg\n";
}
sub print_config {
print("graph_title Server traffic at $HOST:$PORT\n",
"graph_args --base 1000\n",
"graph_vlabel bits in (-) / out (+) per second\n",
"graph_category SourceDS\n",
"graph_info The traffic of incoming and outgoing data from Source game server, such as HL2, CS:S and DoD:S.\n");
print (
"in.type GAUGE\n",
"out.type GAUGE\n",
"in.min 0\n",
"out.min 0\n",
"in.label bps\n",
"out.label bps\n",
"in.graph no\n",
"in.cdef in,8,*\n",
"out.cdef out,8,*\n",
"out.negative in\n"
);
}
sub test_service {
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "no (could not open socket to $HOST:$PORT)\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "no (could not authenticate)\n";
exit 1;
}
if (!defined(Rcon::rcon_command($sock, "stats"))) {
print "no (did not receive reply from server)\n";
exit 1;
}
print "yes\n";
exit 0;
}

122
plugins/sourceds/srcds_players Executable file
View file

@ -0,0 +1,122 @@
#!/usr/bin/perl
#
# 2007-06-26
# Written by Ghost
#
# 2008-04-16
# Update: Wildcard version
#
# 2008-11-12
# Update: Perl RCON system
#
# Configuration variables
#
# srcdspass - RCON password
# srcdsplayersmax - Maximum number of players (optional, default: 32)
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
# Set library path correctly
use File::Basename;
if (-l $0) {
push(@INC, dirname(readlink($0)));
}
push(@INC, dirname($0));
# Load Rcon module or exit with failuer message
if (!eval "require Rcon") {
print "Failed to load Rcon module. ";
print "Make sure Rcon.pm is copied to Munin plugins directory.\n";
exit 1;
}
# Parse hostname and port from the plugin filename
my ($HOST, $PORT) = $0 =~ m/.*_([^:]+)_(\d+)$/;
if (!defined($HOST) || !defined($PORT)) {
print "Could not parse server address from filename.\n";
exit 1;
}
# Load config variables or use default values
my $PASS = $ENV{srcdspass} || "";
my $MAX = $ENV{srcdsplayersmax} || 32;
# Print config or do plugin test if asked
my $arg = shift();
if ($arg eq 'config') {
print_config();
} elsif ($arg eq 'autoconf') {
test_service();
}
#
# Main program starts here
#
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "Could not open socket to $HOST:$PORT.\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "Could not authenticate.\n";
exit 1;
}
my $reply = Rcon::rcon_command($sock, "stats");
if (!defined($reply)) {
print "Did not receive reply from server.\n";
exit 1;
}
my @reply = split(/\n/, $reply);
foreach my $statline (@reply) {
next if ($statline !~ m/\s*[\w+\.]+\s+[\w+\.]+\s+[\w+\.]+\s+\d+\s+\d+\s+[\w+\.]+\s+\d+/);
my ($cpu, $in, $out, $uptime, $users, $fps, $players) = ($statline =~ m/^\s*([\w+\.]+)\s+([\w+\.]+)\s+([\w+\.]+)\s+(\d+)\s+(\d+)\s+([\w+\.]+)\s+(\d+)/);
if (defined($players)) {
print "players.value $players\n";
}
}
sub print_config {
print("graph_title Number of players at $HOST:$PORT\n",
"graph_args --base 1000\n",
"graph_vlabel Players\n",
"graph_category SourceDS\n",
"graph_info The number of players on Source game server, such as HL2, CS:S and DoD:S.\n");
print ("players.label Players\n",
"players.min 0\n",
"players.max $MAX\n",
"players.type GAUGE\n");
}
sub test_service {
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "no (could not open socket to $HOST:$PORT)\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "no (could not authenticate)\n";
exit 1;
}
if (!defined(Rcon::rcon_command($sock, "stats"))) {
print "no (did not receive reply from server)\n";
exit 1;
}
print "yes\n";
exit 0;
}

120
plugins/sourceds/srcds_uptime Executable file
View file

@ -0,0 +1,120 @@
#!/usr/bin/perl
#
# 2007-06-26
# Written by Ghost
#
# 2008-04-16
# Update: Wildcard version
#
# 2008-11-12
# Update: Perl RCON system
#
# Configuration variables
#
# srcdspass - RCON password
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=contrib
#%# capabilities=autoconf
use strict;
# Set library path correctly
use File::Basename;
if (-l $0) {
push(@INC, dirname(readlink($0)));
}
push(@INC, dirname($0));
# Load Rcon module or exit with failuer message
if (!eval "require Rcon") {
print "Failed to load Rcon module. ";
print "Make sure Rcon.pm is copied to Munin plugins directory.\n";
exit 1;
}
# Parse hostname and port from the plugin filename
my ($HOST, $PORT) = $0 =~ m/.*_([^:]+)_(\d+)$/;
if (!defined($HOST) || !defined($PORT)) {
print "Could not parse server address from filename.\n";
exit 1;
}
# Load config variables or use default values
my $PASS = $ENV{srcdspass} || "";
# Print config or do plugin test if asked
my $arg = shift();
if ($arg eq 'config') {
print_config();
} elsif ($arg eq 'autoconf') {
test_service();
}
#
# Main program starts here
#
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "Could not open socket to $HOST:$PORT.\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "Could not authenticate.\n";
exit 1;
}
my $reply = Rcon::rcon_command($sock, "stats");
if (!defined($reply)) {
print "Did not receive reply from server.\n";
exit 1;
}
my @reply = split(/\n/, $reply);
foreach my $statline (@reply) {
next if ($statline !~ m/\s*[\w+\.]+\s+[\w+\.]+\s+[\w+\.]+\s+\d+\s+\d+\s+[\w+\.]+\s+\d+/);
my ($cpu, $in, $out, $uptime, $users, $fps, $players) = ($statline =~ m/^\s*([\w+\.]+)\s+([\w+\.]+)\s+([\w+\.]+)\s+(\d+)\s+(\d+)\s+([\w+\.]+)\s+(\d+)/);
$uptime /= 60; # Change to hours
if (defined($uptime)) {
print "uptime.value $uptime\n";
}
}
sub print_config {
print("graph_title Game server uptime at $HOST:$PORT\n",
"graph_args --base 1000\n",
"graph_vlabel Uptime (hours)\n",
"graph_category SourceDS\n",
"graph_info The uptime for Source game server, such as HL2, CS:S and DoD:S.\n");
print ("uptime.label Uptime\n",
"uptime.min 0\n",
"uptime.type GAUGE\n");
}
sub test_service {
my $sock = Rcon::sock_connect($HOST, $PORT);
if (!$sock) {
print "no (could not open socket to $HOST:$PORT)\n";
exit 1;
}
if (!Rcon::rcon_auth($sock, $PASS)) {
print "no (could not authenticate)\n";
exit 1;
}
if (!defined(Rcon::rcon_command($sock, "stats"))) {
print "no (did not receive reply from server)\n";
exit 1;
}
print "yes\n";
exit 0;
}