Skip to content

Commit

Permalink
add some default plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
replay committed Jan 8, 2012
1 parent ba49f16 commit 41818c2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/mailq_size/5_mailq.sh
@@ -0,0 +1,10 @@
#!/bin/bash

MAILQ="/usr/bin/mailq"
TAIL="/usr/bin/tail"
AWK="/usr/bin/awk"
HOSTNAME=$(/bin/hostname)

MAILS=$($MAILQ | $TAIL -n 1 | $AWK '{print $5};')
echo "mailqueue.$HOSTNAME.queuesize $MAILS"

6 changes: 6 additions & 0 deletions plugins/memory/1_meminfo.sh
@@ -0,0 +1,6 @@
#!/bin/bash

MEMINFO="/proc/meminfo"

export METRIC="system.$HOSTNAME.memory."
awk -F"[[:space:]]+" '{print "'"$METRIC"'" substr($1,0,length($1)-1) " " $2}' < $MEMINFO
84 changes: 84 additions & 0 deletions plugins/network_interface/1_network.pl
@@ -0,0 +1,84 @@
#!/usr/bin/perl

use strict;
use warnings;
use Sys::Hostname;

sub trim
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

my $proc_net_dev="/proc/net/dev";
my $line;
my @split;
my @split2;
my $element;
my $element2;
my $if;
my @top_title;
my @sub_title;
my $phase = 1;
my $metric;
my $metric_prefix = "system." . hostname() . ".net";

open(FIN, $proc_net_dev) or die "could not read from $proc_net_dev: $!\n";
while ($line = <FIN>)
{
if ($phase == 1){
@split = split(/\|/, $line);
for ($element = 1; $element <= $#split; $element++)
{
chomp($split[$element]);
$split[$element] = trim($split[$element]);
push(@top_title, $split[$element]);
}
$phase++;
} elsif ($phase == 2) {
@split = split(/\|/, $line);
for ($element = 1; $element <= $#split; $element++)
{
@split2 = split(/[[:space:]]+/, $split[$element]);
$sub_title[$element - 1] = [];
for ($element2 = 0; $element2 <= $#split2; $element2++)
{
chomp($split2[$element2]);
$split2[$element2] = trim($split2[$element2]);
if ($split2[$element2] ne '')
{
push(@{$sub_title[$element - 1]}, $split2[$element2]);
}
}
}
$phase++;
} elsif ($phase == 3) {
$line = trim($line);
@split = split(/\:/, $line);
$if = $split[0];
$if = trim($if);
$line = $split[1];
@split = split(/[[:space:]]+/, $line);
#print "---line\n\n\n";
for ($element = 0; $element < $#split; $element++)
{
chomp($split[$element]);
$split[$element] = trim($split[$element]);
if ($split[$element] ne '')
{
if ($element < scalar(@{$sub_title[1]}))
{
$metric = $top_title[0] . "." . $sub_title[0][$element];
}
else
{
$metric = $top_title[1] . "." . $sub_title[1][$element - scalar(@{$sub_title[0]})];
}
print $metric_prefix . "." . $if . "." . $metric . " " . $split[$element] . "\n";
}
}
}
}
close(FIN);
11 changes: 11 additions & 0 deletions plugins/unixload/1_unixload.sh
@@ -0,0 +1,11 @@
#!/bin/bash

LOAD=$(cat /proc/loadavg | awk '{print $1}')
LOAD1=$(echo $LOAD | awk '{print $1}')
LOAD5=$(cat /proc/loadavg | awk '{print $2}')
LOAD15=$(cat /proc/loadavg | awk '{print $3}')


echo system.$HOSTNAME.unixload.1 $LOAD1
echo system.$HOSTNAME.unixload.5 $LOAD5
echo system.$HOSTNAME.unixload.15 $LOAD15

0 comments on commit 41818c2

Please sign in to comment.