mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin-Gallery: Better 2nd level headings
This commit is contained in:
parent
6ffdebec0d
commit
f769371079
22 changed files with 0 additions and 0 deletions
67
plugins/bsd/df_abs_bsd
Executable file
67
plugins/bsd/df_abs_bsd
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2008, Net Easy, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Net Easy, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY Net Easy, Inc. ''AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Net Easy, Inc. BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import re, os
|
||||
from sys import argv
|
||||
|
||||
class checker(object):
|
||||
def __init__(self):
|
||||
'parsed_data will have a tuple of the disk capacity and usage (in kbytes) and the mount point for each disk partition'
|
||||
self.parsed_data = {}
|
||||
|
||||
def __repr__(self):
|
||||
thisdata = ''
|
||||
for item in self.parsed_data.keys():
|
||||
thisdata = '%s%s.value %s\n' % (thisdata, item, int(self.parsed_data[item][1] * 1024))
|
||||
return thisdata
|
||||
|
||||
def config(self):
|
||||
thisdata = """graph_title Filesystem usage (in bytes)
|
||||
graph_args --base 1024 --lower-limit 0
|
||||
graph_vlabel bytes
|
||||
graph_category disk
|
||||
graph_info Filesystem usage
|
||||
"""
|
||||
for item in self.parsed_data.keys():
|
||||
thisdata = "%s%s.label %s\n%s.warning %s\n%s.critical %s\n" % (thisdata, item, self.parsed_data[item][2],
|
||||
item, int(self.parsed_data[item][0] * 1024 * 0.92),
|
||||
item, int(self.parsed_data[item][0] * 1024 * 0.98))
|
||||
return thisdata
|
||||
|
||||
def get_data(self):
|
||||
rawdata = os.popen('df -P -l -k').readlines()
|
||||
for i in range(1,len(rawdata)):
|
||||
dataline=rawdata[i].split()
|
||||
self.parsed_data[re.sub('/', '_', dataline[0])] = (int(dataline[1]), int(dataline[2]), dataline[5])
|
||||
|
||||
if __name__ == "__main__":
|
||||
processor = checker()
|
||||
processor.get_data()
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
print processor.config()
|
||||
else:
|
||||
print processor
|
65
plugins/bsd/df_bsd
Executable file
65
plugins/bsd/df_bsd
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2008, Net Easy, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Net Easy, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY Net Easy, Inc. ''AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Net Easy, Inc. BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import re, os
|
||||
from sys import argv
|
||||
|
||||
class checker(object):
|
||||
def __init__(self):
|
||||
'parsed_data will have a tuple of the percentage of disk usage and the mount point for each disk partition'
|
||||
self.parsed_data = {}
|
||||
|
||||
def __repr__(self):
|
||||
thisdata = ''
|
||||
for item in self.parsed_data.keys():
|
||||
thisdata = '%s%s.value %s\n' % (thisdata, item, self.parsed_data[item][0])
|
||||
return thisdata
|
||||
|
||||
def config(self):
|
||||
thisdata = """graph_title Filesystem usage (in %)
|
||||
graph_args --lower-limit 0
|
||||
graph_vlabel %
|
||||
graph_category disk
|
||||
graph_info Filesystem usage
|
||||
"""
|
||||
for item in self.parsed_data.keys():
|
||||
thisdata = "%s%s.label %s\n%s.warning 92\n%s.critical 98\n" % (thisdata, item, self.parsed_data[item][1], item, item)
|
||||
return thisdata
|
||||
|
||||
def get_data(self):
|
||||
rawdata = os.popen('df -P -l').readlines()
|
||||
for i in range(1,len(rawdata)):
|
||||
dataline=rawdata[i].split()
|
||||
self.parsed_data[re.sub('/', '_', dataline[0])] = (re.sub('%', '', dataline[4]), dataline[5])
|
||||
|
||||
if __name__ == "__main__":
|
||||
processor = checker()
|
||||
processor.get_data()
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
print processor.config()
|
||||
else:
|
||||
print processor
|
78
plugins/bsd/freebsd_hdd_power_state
Executable file
78
plugins/bsd/freebsd_hdd_power_state
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor the power state of hard disk drives on FreeBSD.
|
||||
#
|
||||
# Configure the plugin to run as root by adding the following to
|
||||
# /usr/local/etc/munin/plugin-conf.d/plugins.conf:
|
||||
#
|
||||
# [freebsd_hdd_power_state]
|
||||
# user root
|
||||
#
|
||||
# You can also specify the monitored devices using the 'env.devices'
|
||||
# environment variable, if autoconfiguration doesn't work for you:
|
||||
#
|
||||
# env.devices ada0 ada1 ada2 ada3 ada4 ada5 ada6 ada7
|
||||
#
|
||||
# Copyright (c) 2014, Petteri Valkonen <petteri.valkonen@iki.fi>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#%# family=auto contrib
|
||||
#%# capabilities=autoconf
|
||||
|
||||
DEVICES=${devices:-$(iostat -x | tail -n +3 | egrep -o '^a?da[0-9]+')}
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<EOM
|
||||
multigraph $(basename $0)
|
||||
graph_title HDD power state
|
||||
graph_vlabel Power state
|
||||
graph_args --upper-limit 1 -l 0
|
||||
graph_scale no
|
||||
graph_category disk
|
||||
graph_info The power state of the hard disk drives on the system (1 is spun up, 0 is idle/standby).
|
||||
EOM
|
||||
echo $DEVICES | awk 'BEGIN{OFS=""} { for (i = 0; i++ < NF;) print "power", i, ".label ", $i }'
|
||||
exit 0;;
|
||||
autoconf)
|
||||
if [ -z "$DEVICES" ] ; then
|
||||
echo "no (no devices found)"
|
||||
else
|
||||
echo yes
|
||||
fi
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
INDEX=1
|
||||
set -- $DEVICES
|
||||
for DEVICE in $@ ; do
|
||||
STATE=$(camcontrol cmd $DEVICE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - 2>/dev/null | awk '{print $10}')
|
||||
if [ -z "$STATE" ] ; then
|
||||
VALUE="-1"
|
||||
else
|
||||
VALUE=$(echo "$(echo "ibase=16; $STATE" | bc) / 255" | bc)
|
||||
fi
|
||||
printf "power%d.value %d\n" $INDEX $VALUE
|
||||
INDEX=$(expr $INDEX + 1)
|
||||
done
|
96
plugins/bsd/netstat_bsd_m_
Executable file
96
plugins/bsd/netstat_bsd_m_
Executable file
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# netstat_bsd_m revision 1 (Feb 2012)
|
||||
#
|
||||
# This plugin shows various statistics from 'netstat -m'
|
||||
#
|
||||
# Required privileges: none
|
||||
#
|
||||
# OS:
|
||||
# Supposed: BSD
|
||||
# Tested: FreeBSD 8.2
|
||||
#
|
||||
# Author: Artem Sheremet <dot.doom@gmail.com>
|
||||
#
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
# original filename
|
||||
PLUGIN_NAME = 'netstat_bsd_m_'
|
||||
|
||||
class String
|
||||
def escape
|
||||
self.gsub /[^\w]/, '_'
|
||||
end
|
||||
|
||||
unless method_defined? :start_with?
|
||||
def start_with?(str)
|
||||
self[0...str.size] == str
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def netstat_m(filter = nil)
|
||||
Hash[`netstat -m`.split($/).map { |line|
|
||||
if line =~ /^([\d\/K]+) (.*) \(([\w\/+]+)\)$/
|
||||
# 7891K/22385K/30276K bytes allocated to network (current/cache/total)
|
||||
values, desc, names = $1, $2, $3
|
||||
[desc, names.split('/').zip(values.split '/')] if filter.nil? or desc.escape == filter
|
||||
elsif line =~ /^(\d+) (.*)$/
|
||||
# 12327 requests for I/O initiated by sendfile
|
||||
value, desc = $1, $2
|
||||
[desc, [[ :value, value ]]] if filter.nil? or desc.escape == filter
|
||||
end
|
||||
}.compact]
|
||||
end
|
||||
|
||||
stat_name = File.basename($0, '.*').escape
|
||||
stat_name.slice! 0, PLUGIN_NAME.size if stat_name.start_with? PLUGIN_NAME
|
||||
|
||||
case ARGV.first
|
||||
when 'autoconf'
|
||||
puts `uname -s`.include?('FreeBSD') ? 'yes' : 'no'
|
||||
when 'suggest'
|
||||
puts netstat_m.keys.map(&:escape).join $/
|
||||
when 'config'
|
||||
data = netstat_m(stat_name)
|
||||
if data.empty?
|
||||
warn "no data for <#{stat_name}>. Try running with 'suggest'"
|
||||
else
|
||||
desc, values = data.first
|
||||
stack = values.size > 1
|
||||
first = true
|
||||
puts <<CONFIG
|
||||
graph_title Netstat: #{desc}
|
||||
graph_category network
|
||||
graph_vlabel current
|
||||
graph_order #{values.map { |name, _| name.to_s.escape }.join ' '}
|
||||
CONFIG
|
||||
puts values.map { |name, _|
|
||||
esc_name = name.to_s.escape
|
||||
"#{esc_name}.draw " + if %w(total max).include? name
|
||||
'LINE'
|
||||
elsif stack
|
||||
if first
|
||||
first = false
|
||||
'AREA'
|
||||
else
|
||||
'STACK'
|
||||
end
|
||||
else
|
||||
'LINE2'
|
||||
end + "\n#{esc_name}.label #{name}"
|
||||
}.join $/
|
||||
end
|
||||
when nil # fetch
|
||||
data = netstat_m(stat_name)
|
||||
unless data.empty?
|
||||
puts data.first.last.map { |name, value|
|
||||
value = value.to_i * 1024 if value.end_with? 'K'
|
||||
"#{name.to_s.escape}.value #{value}"
|
||||
}.join $/
|
||||
end
|
||||
else
|
||||
warn "unrecognized argument <#{ARGV.first}>"
|
||||
end
|
BIN
plugins/bsd/netstat_bsd_m_-day.png
Normal file
BIN
plugins/bsd/netstat_bsd_m_-day.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
36
plugins/bsd/openbsd-memory
Executable file
36
plugins/bsd/openbsd-memory
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Memory usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "acti.label Active"
|
||||
echo "used.label Used"
|
||||
echo "total.label Total"
|
||||
echo "free.label Free"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot
|
||||
|
||||
top -un | nawk '
|
||||
function scale(v) {
|
||||
if (v ~ /G$/) { sub("G", "", v);v *= 1024 }
|
||||
else if (v ~ /M$/) sub("M", "", v)
|
||||
else if (v ~ /K$/) { sub("K", "", v);v /= 1024 }
|
||||
else v /= 1024 * 1024;
|
||||
return v;
|
||||
}
|
||||
function spliter(v, i) {
|
||||
split(v, a, "/");
|
||||
return(a[i]);
|
||||
}
|
||||
/^Memory/ {
|
||||
acti = scale(spliter($3,1));
|
||||
used = scale(spliter($3,2));
|
||||
free = scale($6);
|
||||
total = used + free;
|
||||
|
||||
print "acti.value", acti
|
||||
print "used.value", used
|
||||
print "total.value", total
|
||||
print "free.value", free
|
||||
}'
|
33
plugins/bsd/openbsd-swap
Executable file
33
plugins/bsd/openbsd-swap
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# @author northox <northox@mantor.org>
|
||||
# Mantor Organization
|
||||
#
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Swap usage (in MB)"
|
||||
echo 'graph_category system'
|
||||
echo "swap.label Swap used"
|
||||
echo "swapt.label Swap total"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot
|
||||
|
||||
top -un | nawk '
|
||||
function scale(v) {
|
||||
if (value ~ /G$/) { sub("G", "", v); v *= 1024 }
|
||||
else if (v ~ /M$/) sub("M", "", v)
|
||||
else if (v ~ /K$/) { sub("K", "", v); v /= 1024 }
|
||||
else v /= 1024 * 1024;
|
||||
return v;
|
||||
}
|
||||
function spliter(v, i) {
|
||||
split(v,a,"/");
|
||||
return(a[i]);
|
||||
}
|
||||
/^Memory/ {
|
||||
swap = scale(spliter($8,1));
|
||||
swapt = scale(spliter($8,2));
|
||||
|
||||
print "swap.value", swap
|
||||
print "swapt.value", swapt
|
||||
}'
|
80
plugins/bsd/spamd-blacklist-bsd
Executable file
80
plugins/bsd/spamd-blacklist-bsd
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2008, Net Easy, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Net Easy, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY Net Easy, Inc. ''AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Net Easy, Inc. BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# requires logcheck from ports
|
||||
|
||||
import re, os
|
||||
from sys import argv
|
||||
|
||||
logfile = "/var/log/daemon"
|
||||
blacklists = ['spews1', 'spews2', 'uatraps', 'nixspam']
|
||||
|
||||
class checker(object):
|
||||
def __init__(self, blacklist):
|
||||
self.grey = 0
|
||||
self.black = 0
|
||||
self.blacklist_count = {}
|
||||
for item in blacklist:
|
||||
self.blacklist_count[item] = 0
|
||||
|
||||
def __repr__(self):
|
||||
string = """grey.value %s
|
||||
black.value %s""" % (self.grey, self.black)
|
||||
for item in self.blacklist_count.keys():
|
||||
string = "%s\n%s.value %s" % (string, item, self.blacklist_count[item])
|
||||
return string
|
||||
|
||||
def process_line(self, line):
|
||||
if re.search('(BLACK)', line):
|
||||
self.black += 1
|
||||
if re.search('(GREY)', line):
|
||||
self.grey += 1
|
||||
if re.search(' lists: ', line):
|
||||
if re.search(' connected', line): # only log connects
|
||||
spamtraps = re.sub('^.*lists:', '', line).split()
|
||||
for item in spamtraps:
|
||||
self.blacklist_count[item] += 1
|
||||
|
||||
def process_lines(self, file):
|
||||
for line in os.popen('logtail %s %s.bl.offset' % (file, file)).readlines():
|
||||
self.process_line(line)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
print """graph_title spamd
|
||||
graph_vlabel Count / 5 min.
|
||||
graph_category Mail
|
||||
graph_info Number of greylisted and blacklisted connections to the OpenBSD spamd tarpit, and the hits on each blacklist
|
||||
grey.label Greylisted
|
||||
black.label Blacklisted"""
|
||||
for item in blacklists:
|
||||
print "%s.label Blacklist %s hits" % (item, item)
|
||||
else:
|
||||
processor = checker(blacklists)
|
||||
processor.process_lines(logfile)
|
||||
print processor
|
||||
|
71
plugins/bsd/spamd-tarpit-bsd
Executable file
71
plugins/bsd/spamd-tarpit-bsd
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2008, Net Easy, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of Net Easy, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY Net Easy, Inc. ''AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Net Easy, Inc. BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# requires logcheck from ports
|
||||
|
||||
import re, os
|
||||
from sys import argv
|
||||
|
||||
logfile = "/var/log/daemon"
|
||||
|
||||
class checker(object):
|
||||
def __init__(self):
|
||||
self.tarpit_count = 0
|
||||
self.tarpit_total = 0
|
||||
|
||||
def __repr__(self):
|
||||
return "tarpit.value %s" % (self.tarpit_average())
|
||||
|
||||
def tarpit_average(self):
|
||||
if self.tarpit_count > 0:
|
||||
return "%.1f" % (self.tarpit_total / self.tarpit_count)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def process_line(self, line):
|
||||
if re.search(' disconnected after ', line):
|
||||
self.tarpit_count += 1
|
||||
tarpit_time = re.sub('^.*after ','',re.sub(' second.*$','',line))
|
||||
self.tarpit_total += int(tarpit_time)
|
||||
|
||||
def process_lines(self, file):
|
||||
for line in os.popen('logtail %s %s.tp.offset' % (file, file)).readlines():
|
||||
self.process_line(line)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(argv) > 1 and argv[1] == 'config':
|
||||
print """graph_title spamd delay
|
||||
graph_vlabel Average delay.
|
||||
graph_category Mail
|
||||
graph_info Average time spammers delayed by spamd
|
||||
tarpit.label Average tarpit delay"""
|
||||
|
||||
else:
|
||||
processor = checker()
|
||||
processor.process_lines(logfile)
|
||||
print processor
|
||||
|
63
plugins/bsd/uptime_bsd
Executable file
63
plugins/bsd/uptime_bsd
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env perl
|
||||
# -*- perl -*-
|
||||
# Plugin to monitor the system uptime
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %IN;
|
||||
|
||||
my $sysctl = defined($ENV{sysctl}) ? $ENV{sysctl} : '/sbin/sysctl';
|
||||
my $ostype = `uname -s`;
|
||||
chomp ($ostype);
|
||||
|
||||
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf')) {
|
||||
if ( -x $sysctl ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no (sysctl binary not found)\n";
|
||||
};
|
||||
exit;
|
||||
};
|
||||
|
||||
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
|
||||
print <<EOT ;
|
||||
graph_title Uptime
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel days
|
||||
graph_category system
|
||||
compile.label Kernel age
|
||||
compile.type GAUGE
|
||||
compile.min 0
|
||||
compile.max 1000
|
||||
compile.draw AREA
|
||||
uptime.label Uptime
|
||||
uptime.type GAUGE
|
||||
uptime.min 0
|
||||
uptime.max 1000
|
||||
uptime.draw AREA
|
||||
EOT
|
||||
exit;
|
||||
}
|
||||
|
||||
use Date::Parse;
|
||||
|
||||
my $kern=`sysctl -n kern.version`;
|
||||
$kern=~ /:\s+(.*\S)\s+\w+\@/;
|
||||
#print "Compile: $1\n";
|
||||
$kern=str2time($1);
|
||||
|
||||
my $boot=`sysctl -n kern.boottime`; # OpenBSD will return seconds from the epoch
|
||||
if ($ostype ne "OpenBSD") {
|
||||
$boot=~ / sec = (\d+)/;
|
||||
#print "Boot: $1\n";
|
||||
$boot=$1;
|
||||
}
|
||||
|
||||
my $now=time;
|
||||
|
||||
print "compile.value ",($now-$kern)/60/60/24,"\n";
|
||||
print "uptime.value ",($now-$boot)/60/60/24,"\n";
|
Loading…
Add table
Add a link
Reference in a new issue