samba
This commit is contained in:
parent
c24d53a43a
commit
811999172f
3 changed files with 86 additions and 122 deletions
122
docker_cpu
122
docker_cpu
|
@ -1,122 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
docker_cpu - Munin plugin to monitor docker container CPU usage.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Should work on any Linux system that has docker support.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
Root privilege required to execute docker command.
|
||||
|
||||
1. Create a new file named "docker" inside the folder /etc/munin/plugin-conf.d/
|
||||
2. Docker file content:
|
||||
|
||||
[docker_cpu]
|
||||
user root
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
v.0.1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2015 Samuel Cantero <scanterog at gmail dot com>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv3
|
||||
|
||||
=cut
|
||||
|
||||
my $docker=`sudo /usr/bin/docker`;
|
||||
|
||||
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||||
if ($docker) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
else{
|
||||
print "no (Docker has not been found)\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
#$docker =~ s/\s+$//;
|
||||
|
||||
my @containers = split "\n" , `$docker ps --no-trunc=true`;
|
||||
my $result;
|
||||
|
||||
for my $i (1 .. $#containers)
|
||||
{
|
||||
my @fields = split / +/, $containers[$i];
|
||||
my $id = $fields[0];
|
||||
my $name = $fields[$#fields];
|
||||
my $label = $name;
|
||||
# manage container name containing arithmetic operators and dots. E.g, my-container.
|
||||
$name =~ s/[-\+*\/\.]/_/g;
|
||||
# truncate container name with "," character.
|
||||
$name =~ s/,.*//g;
|
||||
# prefix if container starts with 0-9
|
||||
$name =~ s/^([0-9])/c$1/;
|
||||
if (open(my $file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage"))
|
||||
{
|
||||
my $total_cpu_ns = <$file>;
|
||||
$total_cpu_ns =~ s/\s+$//;
|
||||
close $file;
|
||||
if (open($file, '<', "/sys/fs/cgroup/cpuacct/docker/$id/cpuacct.usage_percpu"))
|
||||
{
|
||||
my @ncpu = split / /, <$file>;
|
||||
close $file;
|
||||
push @result, {'name'=>$name, 'label'=>$label, 'total_cpu_ns'=>$total_cpu_ns, 'ncpu'=>$#ncpu};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
||||
{
|
||||
my $nanoSecondsInSecond=1000000000;
|
||||
my $graphlimit = 1;
|
||||
foreach(@result){
|
||||
if ($$_{'ncpu'} || 1 > $graphlimit){
|
||||
$graphlimit = $$_{'ncpu'};
|
||||
}
|
||||
}
|
||||
$graphlimit = $graphlimit * 100;
|
||||
print "graph_title Docker container CPU usage\n";
|
||||
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit\n";
|
||||
print "graph_vlabel %\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_period second\n";
|
||||
print "graph_category virtualization\n";
|
||||
print "graph_info This graph shows docker container CPU usage.\n";
|
||||
|
||||
foreach(@result)
|
||||
{
|
||||
print "$$_{'name'}.label $$_{'label'}\n";
|
||||
print "$$_{'name'}.draw LINE2\n";
|
||||
print "$$_{'name'}.min 0\n";
|
||||
print "$$_{'name'}.type DERIVE\n";
|
||||
print "$$_{'name'}.cdef $$_{'name'},$nanoSecondsInSecond,/\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Note: Counters/derive need to report integer values.
|
||||
|
||||
foreach(@result)
|
||||
{
|
||||
$tcpu = ($$_{'total_cpu_ns'}*100); #to percentage
|
||||
print "$$_{'name'}.value $tcpu\n";
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
40
samba_locked
Normal file
40
samba_locked
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor the number of Samba locked files on the machine.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2007/04/16 Jon Higgs
|
||||
# Initial Release - Adapted from jimmyo's processes plugin.
|
||||
#
|
||||
# Magick markers (optional - used by munin-config and some installation
|
||||
# scripts):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Samba Locked Files'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel number of locked files'
|
||||
echo 'graph_category fs'
|
||||
echo 'graph_info This graph shows the number locked Samba Files.'
|
||||
echo 'samba_locked.label Locked Files'
|
||||
echo 'samba_locked.draw LINE2'
|
||||
echo 'samba_locked.info The current number of locked files.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "samba_locked.value $(smbstatus -L 2> /dev/null | grep -c DENY_)"
|
||||
|
||||
# If here, always return OK
|
||||
exit 0
|
46
samba_users
Normal file
46
samba_users
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to monitor the number of Samba users on the machine.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2007/04/16 Jon Higgs
|
||||
# Initial Release - Adapted from jimmyo's processes plugin.
|
||||
#
|
||||
# Revision 1.1 2014/07/24 MangaII
|
||||
# Add exit 0
|
||||
# WARNING : Samba 3.6 and newer block access to smbstatus for no root user
|
||||
# On Debian make a "chmod a+w /run/samba/sessionid.tdb"
|
||||
# smbstatus must open this file with RW option
|
||||
#
|
||||
# Magick markers (optional - used by munin-config and some installation
|
||||
# scripts):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Samba Users'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel number of Samba users.'
|
||||
echo 'graph_category fs'
|
||||
echo 'graph_info This graph shows the number Samba users.'
|
||||
echo 'samba_users.label Samba Users'
|
||||
echo 'samba_users.draw LINE2'
|
||||
echo 'samba_users.info The current number of Samba users.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "samba_users.value "
|
||||
smbstatus -b 2> /dev/null | grep -c -v -e "^Samba" -e "^---" -e "^PID" -e ^$
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue