Article Index

  1. Als ik kijk naar de pagina's zie ik niets over ZFS staan, ik heb de volgende plugin gevonden: http://munin-monitoring.org/browser/munin-contrib/plugins/zfs/zfs_stats_

    Dit bestand maak ik aan:
    # cd /usr/local/share/munin/plugins
    # vi /usr/local/share/munin/plugins/zfs_stats_

    Ik plak de volgende tekst erin:

     

     

    #!/bin/sh
    # ZFS statistics for FreeBSD
    # Author: David Bjornsson <This email address is being protected from spambots. You need JavaScript enabled to view it.>
    #
    # Description:
    # This is a rewrite of the zfs-stats-for-freebsd
    # scripts by patpro. Rather then pulling the
    # information from the zfs-stats utility, it
    # pulls it straight from sysctl.
    #
    # Tested on FreeBSD 9.0-RELEASE
    #
    # Usage: zfs_stats_FUNCTION
    #
    # Available functions:
    # efficiency - ARC efficiency
    # cachehitlist - Cache hit by cache list
    # cachehitdtype - Cache hit by data type
    # dmuprefetch - DMU prefetch
    # utilization - ARC size breakdown
    # l2utilization - L2ARC size breakdown
    # l2efficiency - L2ARC efficiency
    #
    #%# family=auto
    FUNCTION=$(basename $0 | cut -d_ -f3)
    PAGESIZE=`/sbin/sysctl -n vm.stats.vm.v_page_size`
    MEMSIZE=`/sbin/sysctl -n vm.stats.vm.v_page_count`
    MEMMAX=`echo 'scale=2;' $PAGESIZE*$MEMSIZE | /usr/bin/bc -q`
    BC='/usr/bin/bc -q'
    SYS='/sbin/sysctl -n'
    #
    # Sysctl macros
    #
    ARC_HITS=`$SYS kstat.zfs.misc.arcstats.hits`
    ARC_MISSES=`$SYS kstat.zfs.misc.arcstats.misses`
    DEMAND_DATA_HITS=`$SYS kstat.zfs.misc.arcstats.demand_data_hits`
    DEMAND_DATA_MISSES=`$SYS kstat.zfs.misc.arcstats.demand_data_misses`
    DEMAND_METADATA_HITS=`$SYS kstat.zfs.misc.arcstats.demand_metadata_hits`
    DEMAND_METADATA_MISSES=`$SYS kstat.zfs.misc.arcstats.demand_metadata_misses`
    MFU_GHOST_HITS=`$SYS kstat.zfs.misc.arcstats.mfu_ghost_hits`
    MFU_HITS=`$SYS kstat.zfs.misc.arcstats.mfu_hits`
    MRU_GHOST_HITS=`$SYS kstat.zfs.misc.arcstats.mru_ghost_hits`
    MRU_HITS=`$SYS kstat.zfs.misc.arcstats.mru_hits`
    PREFETCH_DATA_HITS=`$SYS kstat.zfs.misc.arcstats.prefetch_data_hits`
    PREFETCH_DATA_MISSES=`$SYS kstat.zfs.misc.arcstats.prefetch_data_misses`
    PREFETCH_METADATA_HITS=`$SYS kstat.zfs.misc.arcstats.prefetch_metadata_hits`
    PREFETCH_METADATA_MISSES=`$SYS kstat.zfs.misc.arcstats.prefetch_metadata_misses`
    DMU_HITS=`$SYS kstat.zfs.misc.zfetchstats.hits`
    DMU_MISSES=`$SYS kstat.zfs.misc.zfetchstats.misses`
    SIZE=`$SYS kstat.zfs.misc.arcstats.size`
    MRU_SIZE=`$SYS kstat.zfs.misc.arcstats.p`
    MAX_SIZE=`$SYS kstat.zfs.misc.arcstats.c_max`
    MIN_SIZE=`$SYS kstat.zfs.misc.arcstats.c_min`
    TARGET_SIZE=`$SYS kstat.zfs.misc.arcstats.c`
    L2_SIZE=`$SYS kstat.zfs.misc.arcstats.l2_size`
    L2_HDR_SIZE=`$SYS kstat.zfs.misc.arcstats.l2_hdr_size`
    L2_HITS=`$SYS kstat.zfs.misc.arcstats.l2_hits`
    L2_MISSES=`$SYS kstat.zfs.misc.arcstats.l2_misses`
    #
    # Calculation macros
    #
    ANON_HITS=`echo "$ARC_HITS-($MFU_HITS+$MRU_HITS+$MFU_GHOST_HITS+$MRU_GHOST_HITS)" | $BC`
    ARC_ACCESSES_TOTAL=`echo "$ARC_HITS+$ARC_MISSES" | $BC`
    DEMAND_DATA_TOTAL=`echo "$DEMAND_DATA_HITS+$DEMAND_DATA_MISSES" | $BC`
    PREFETCH_DATA_TOTAL=`echo "$PREFETCH_DATA_HITS+$PREFETCH_DATA_MISSES" | $BC`
    REAL_HITS=`echo "$MFU_HITS+$MRU_HITS" | $BC`
    CACHE_HIT_RATIO_PERC=`echo "scale=2 ; (100*$ARC_HITS/$ARC_ACCESSES_TOTAL)" | $BC`
    CACHE_MISS_RATIO_PERC=`echo "scale=2 ; (100*$ARC_MISSES/$ARC_ACCESSES_TOTAL)" | $BC`
    ACTUAL_HIT_RATIO_PERC=`echo "scale=2 ; (100*$REAL_HITS/$ARC_ACCESSES_TOTAL)" | $BC`
    DATA_DEMAND_EFFICIENCY_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_HITS/$DEMAND_DATA_TOTAL)" | $BC`
    DATA_PREFETCH_EFFICENCY_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_HITS/$PREFETCH_DATA_TOTAL)" | $BC`
    ANONYMOUSLY_USED_PERC=`echo "scale=2 ; (100*$ANON_HITS/$ARC_HITS)" | $BC`
    MOST_RECENTLY_USED_PERC=`echo "scale=2 ; (100*$MRU_HITS/$ARC_HITS)" | $BC`
    MOST_FREQUENTLY_USED_PERC=`echo "scale=2 ; (100*$MFU_HITS/$ARC_HITS)" | $BC`
    MOST_RECENTLY_USED_GHOST_PERC=`echo "scale=2 ; (100*$MRU_GHOST_HITS/$ARC_HITS)" | $BC`
    MOST_FREQUENTLY_USED_GHOST_PERC=`echo "scale=2 ; (100*$MFU_GHOST_HITS/$ARC_HITS)" | $BC`
    DEMAND_DATA_HIT_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_HITS/$ARC_HITS)" | $BC`
    DEMAND_DATA_MISS_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_MISSES/$ARC_MISSES)" | $BC`
    PREFETCH_DATA_HIT_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_HITS/$ARC_HITS)" | $BC`
    PREFETCH_DATA_MISS_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_MISSES/$ARC_MISSES)" | $BC`
    DEMAND_METADATA_HIT_PERC=`echo "scale=2 ; (100*$DEMAND_METADATA_HITS/$ARC_HITS)" | $BC`
    DEMAND_METADATA_MISS_PERC=`echo "scale=2 ; (100*$DEMAND_METADATA_MISSES/$ARC_MISSES)" | $BC`
    PREFETCH_METADATA_HIT_PERC=`echo "scale=2 ; (100*$PREFETCH_METADATA_HITS/$ARC_HITS)" | $BC`
    PREFETCH_METADATA_MISSES_PERC=`echo "scale=2 ; (100*$PREFETCH_METADATA_MISSES/$ARC_MISSES)" | $BC`
    DMU_TOTAL=`echo "$DMU_HITS+$DMU_MISSES" | $BC`
    DMU_HITS_PERC=`echo "scale=2 ; (100*$DMU_HITS/$DMU_TOTAL)" | $BC`
    DMU_MISSES_PERC=`echo "scale=2 ; (100*$DMU_MISSES/$DMU_TOTAL)" | $BC`
    if [ $SIZE -gt $TARGET_SIZE ]; then
    MFU_SIZE=`echo "$SIZE-$MRU_SIZE" | $BC`
    else
    MFU_SIZE=`echo "$TARGET_SIZE-$MRU_SIZE" | $BC`
    fi
    L2_ACCESSES_TOTAL=`echo "$L2_HITS+$L2_MISSES" | $BC`
    if [ $L2_ACCESSES_TOTAL -gt 0 ]; then
    L2_HIT_RATIO_PERC=`echo "scale=2 ; (100*$L2_HITS/$L2_ACCESSES_TOTAL)" | $BC`
    L2_MISS_RATIO_PERC=`echo "scale=2 ; (100*$L2_MISSES/$L2_ACCESSES_TOTAL)" | $BC`
    fi
    efficiency() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS ARC Efficiency'
    echo 'graph_args -u 100'
    echo 'graph_vlabel %'
    echo 'graph_info This graph shows the ARC Efficiency'
    echo 'hits.label Hit Ratio'
    echo 'misses.label Miss Ratio'
    echo 'actual_hits.label Actual Hit Ratio'
    echo 'data_demand_efficiency.label Data Demand Efficiency'
    echo 'data_prefetch_efficiency.label Data Prefetch Efficiency'
    exit 0
    else
    echo 'hits.value ' $CACHE_HIT_RATIO_PERC
    echo 'misses.value ' $CACHE_MISS_RATIO_PERC
    echo 'actual_hits.value ' $ACTUAL_HIT_RATIO_PERC
    echo 'data_demand_efficiency.value ' $DATA_DEMAND_EFFICIENCY_PERC
    echo 'data_prefetch_efficiency.value ' $DATA_PREFETCH_EFFICENCY_PERC
    fi
    }
    cachehitlist() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS ARC Efficiency: Cache hits by cache list'
    echo 'graph_args -u 100'
    echo 'graph_vlabel %'
    echo 'graph_info This graph shows the ARC Efficiency'
    echo 'cache_list_anon.label Anonymously Used'
    echo 'cache_list_most_rec.label Most Recently Used'
    echo 'cache_list_most_freq.label Most Frequently Used'
    echo 'cache_list_most_rec_ghost.label Most Recently Used Ghost'
    echo 'cache_list_most_freq_ghost.label Most Frequently Used Ghost'
    exit 0
    else
    echo 'cache_list_anon.value ' $ANONYMOUSLY_USED_PERC
    echo 'cache_list_most_rec.value ' $MOST_RECENTLY_USED_PERC
    echo 'cache_list_most_freq.value ' $MOST_FREQUENTLY_USED_PERC
    echo 'cache_list_most_rec_ghost.value ' $MOST_RECENTLY_USED_GHOST_PERC
    echo 'cache_list_most_freq_ghost.value ' $MOST_FREQUENTLY_USED_GHOST_PERC
    fi
    }
    cachehitdtype() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS ARC Efficiency: Cache hits by data type'
    echo 'graph_args -u 100'
    echo 'graph_vlabel %'
    echo 'graph_info This graph shows the ARC Efficiency'
    echo 'data_type_demand_hits.label Demand Data Hit Ratio'
    echo 'data_type_demand_misses.label Demand Data Miss Ratio'
    echo 'data_type_prefetch_hits.label Prefetch Data Hit Ratio'
    echo 'data_type_prefetch_misses.label Prefetch Data Miss Ratio'
    echo 'data_type_demand_metadata_hits.label Demand Metadata Hit Ratio'
    echo 'data_type_demand_metadata_misses.label Demand Metadata Miss Ratio'
    echo 'data_type_prefetch_metadata_hits.label Prefetch Metadata Hit Ratio'
    echo 'data_type_prefetch_metadata_misses.label Prefetch Metadata Miss Ratio'
    exit 0
    else
    echo 'data_type_demand_hits.value ' $DEMAND_DATA_HIT_PERC
    echo 'data_type_demand_misses.value ' $DEMAND_DATA_MISS_PERC
    echo 'data_type_prefetch_hits.value ' $PREFETCH_DATA_HIT_PERC
    echo 'data_type_prefetch_misses.value ' $PREFETCH_DATA_MISS_PERC
    echo 'data_type_demand_metadata_hits.value ' $DEMAND_METADATA_HIT_PERC
    echo 'data_type_demand_metadata_misses.value ' $DEMAND_METADATA_MISS_PERC
    echo 'data_type_prefetch_metadata_hits.value ' $PREFETCH_METADATA_HIT_PERC
    echo 'data_type_prefetch_metadata_misses.value ' $PREFETCH_METADATA_MISSES_PERC
    fi
    }
    dmuprefetch() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS DMU prefetch stats'
    echo 'graph_args -u 100'
    echo 'graph_vlabel %'
    echo 'graph_info This graph shows the DMU prefetch stats'
    echo 'hits.label Hit Ratio'
    echo 'misses.label Miss Ratio'
    exit 0
    else
    echo 'hits.value ' $DMU_HITS_PERC
    echo 'misses.value ' $DMU_MISSES_PERC
    fi
    }
    utilization() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS ARC Size'
    echo 'graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit '$MEMMAX
    echo 'graph_vlabel Size in MB'
    echo 'graph_info This graph shows the ARC Size utilization'
    echo 'max_size.label Maximum Size'
    echo 'max_size.draw AREA'
    echo 'size.label Size'
    echo 'size.draw AREA'
    echo 'min_size.label Minimum Size'
    echo 'min_size.draw AREA'
    echo 'target_size.label Target Size'
    echo 'target_size.draw LINE1'
    echo 'recently_size.label Recently Used Cache Size'
    echo 'recently_size.draw LINE1'
    echo 'frequently_size.label Frequently Used Cache Size'
    echo 'frequently_size.draw LINE1'
    exit 0
    else
    echo 'max_size.value ' $MAX_SIZE
    echo 'size.value ' $SIZE
    echo 'min_size.value ' $MIN_SIZE
    echo 'target_size.value ' $TARGET_SIZE
    echo 'recently_size.value ' $MRU_SIZE
    echo 'frequently_size.value ' $MFU_SIZE
    fi
    }
    l2utilization() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS L2ARC Size'
    echo 'graph_args --base 1024 -r -l 0 --vertical-label Bytes'
    echo 'graph_vlabel Size in MB'
    echo 'graph_info This graph shows the L2ARC Size utilization'
    echo 'size.label Size'
    echo 'size.draw AREA'
    echo 'hdr_size.label Header Size'
    echo 'hdr_size.draw AREA'
    exit 0
    else
    echo 'size.value ' $L2_SIZE
    echo 'hdr_size.value ' $L2_HDR_SIZE
    fi
    }
    l2efficiency() {
    if [ "$1" = "config" ]; then
    echo 'graph_title ZFS L2ARC Efficiency'
    echo 'graph_args -u 100'
    echo 'graph_vlabel %'
    echo 'graph_info This graph shows the L2ARC Efficiency'
    echo 'l2_hits.label Hit Ratio'
    echo 'l2_misses.label Miss Ratio'
    else
    echo 'l2_hits.value ' $L2_HIT_RATIO_PERC
    echo 'l2_misses.value ' $L2_MISS_RATIO_PERC
    fi
    }
    [ "$1" = "config" ] && echo "graph_category zfs"
    case "$FUNCTION" in
    efficiency)
    efficiency $1
    ;;
    cachehitlist)
    cachehitlist $1
    ;;
    cachehitdtype)
    cachehitdtype $1
    ;;
    dmuprefetch)
    dmuprefetch $1
    ;;
    utilization)
    utilization $1
    ;;
    l2utilization)
    l2utilization $1
    ;;
    l2efficiency)
    l2efficiency $1
    ;;
    esac



  2. Sla het bestand op en geef het de juiste rechten:
    # chmod 0755 zfs_stats_

  3. Configureer de node nogmaals, zodat de nieuwe plugins worden opgepakt:

    # munin-node-configure --shell



  4. Maak een symbolic link aan:

    # cd /usr/local/etc/munin/plugins
    # ln -s /usr/local/share/munin/plugins/zfs_stats_ zfs_stats_


    Opmerking: het script heet zfs_stats_ (Eindigd inderdaad op Underscore), en in de symbolic link geef je met "zdata" aan, hoe de zfs pool heet. In mijn geval is dat zdata. Je voert de naam in: zfs_stats_<zfs pool naam>

  5. Herstart de munin node op de server die je aan het monitoren bent, in mijn geval is dat: 10.30.0.5.

    # /usr/local/etc/rc.d/munin-node restart




     

  6. Uiteraard wil ik ook graag de temperatuur van mijn harde schijven in de gaten houden, dit kan met de plugin: /usr/local/share/munin/plugins/hddtemp_smartctl, dit script word standaard mee geinstalleerd bij de installatie van Munin-node.
    # vi /usr/local/share/munin/plugins/hddtemp_smartctl

    Hierin stonden alleen de devices ad00 en ada00, aangezien mijn devices da0 t/m da13 heten moest ik de volgende regel aanpassen.

    Ga op zoek naar ada, en als je deze tekst ziet:
    } elsif ($^O eq 'freebsd') {
    opendir(DEV, '/dev');
    @drives = grep /^ ad[0-9]+$|^ada[0-9]+$/, readdir DEV;
    closedir(DEV);
    } elsif ($^O eq 'solaris') {
    @drives = map { s@.*/@@ ; $_ } glob '/dev/rdsk/c*t*d*s2';
    }


    En wijzig dit naar:
    } elsif ($^O eq 'freebsd') {
    opendir(DEV, '/dev');
    @drives = grep /^da[0-9]+$|ad[0-9]+$|^ada[0-9]+$/, readdir DEV;
    closedir(DEV);
    } elsif ($^O eq 'solaris') {
    @drives = map { s@.*/@@ ; $_ } glob '/dev/rdsk/c*t*d*s2';
    }

     

  7. Maak dan weer een symobic link:

    # cd /usr/local/etc/munin/plugins
    # ln -s /usr/local/share/munin/plugins/hddtemp_smartctl hddtemp_smartctl

  8. Herstart munin node:
    # service munin-node restart

    En je zal geconfronteerd worden met meldingen dat er onvoldoende rechten zijn in de statistieken.

  9. De foutmelding over de rechten kan je oplossen door in plugins.conf aan te geven onder welke gebruiker het opgestart moet worden:

    # vi /usr/local/etc/munin/plugin-conf.d/plugins.conf

  10. Ga op zoek naar: [hddtemp_smartctl] en voeg:


    user root toe:


    Sla het bestand op en herstart munin-node:
    # service munin-node restart

  11. Dit is het volledige bestand van hddtemp_smartctl

    #!/usr/local/bin/perl –w
    # -*- perl -*-
    =head1 NAME
    hddtemp_smartctl - Plugin to monitor harddrive temperatures through
    SMART

    =head1 CONFIGURATION

    This plugin needs to run as root or some other user that has access to
    the harddrive devices.

    The following environment variables are used

    smartctl - path to smartctl executable
    drives - List drives to monitor. E.g. "env.drives hda hdc".
    type_$dev - device type for one drive, e.g. "env.type_sda 3ware,0"
    or more typically "env.type_sda ata" if sda is a SATA disk.
    args_$dev - additional arguments to smartctl for one drive,
    e.g. "env.args_hda -v 194,10xCelsius". Use this to make
    the plugin use the --all or -a option if your disk will
    not return its temperature when only the -A option is
    used.
    dev_$dev - monitoring device for one drive, e.g. twe0

    If the "smartctl" enviroment variable is not set the plugin will
    search your $PATH, /usr/bin, /usr/sbin, /usr/local/bin and
    /usr/local/sbin for a file called "smartctl", and use that.

    If the "drives" environment variable is not set, the plugin will
    attempt to search for drives to probe.

    =head1 MAGIC MARKERS

    #%# family=auto
    #%# capabilities=autoconf

    =head1 AUTHOR

    Copyright (c) 2005, Lutz Peter Christoph
    All rights reserved.

    =head1 LICENSE

    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.

    * The name and aliases of Lutz Peter Christoph ("Lupe Christoph",
    "Lutz Christoph") may not 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
    OWNER OR CONTRIBUTORS 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.

    =head1 NOTES

    Note for users of RAID controllers (smartmontools currently only
    supports 3ware): you can specify the drives attached to your RAID
    controller(s) as raiddev_num (e.g. sda_0). Then you must specify the
    type like this: type_sda_0 3ware,0.

    Recent versions of the kernel driver use a separate major device
    number for monitoring purposes, like /dev/twe or /dev/twa. This
    can be put in the e.g. dev_sda environment variable, to allow the user
    to keep sda as the name of the disk.

    To avoid spinning up sleeping disks smartctl will use the –nocheck
    parameter. If this parameter isn't supported by your version of
    smartctl then hdparm will be used. Note that hdparm isn't available
    on all platforms.

    =cut

    use strict;
    use File::Spec::Functions qw(splitdir);
    use lib $ENV{'MUNIN_LIBDIR'};
    use Munin::Plugin;

    my $DEBUG = $ENV{'MUNIN_DEBUG'} || 0;

    my $smartctl;

    if (exists $ENV{smartctl}) {
    $smartctl = $ENV{smartctl};
    if (defined $ARGV[0] and $ARGV[0] eq 'autoconf') {
    if (! -e $smartctl) {
    print "no (Predefined smartctl ($smartctl) does not exist)\n";
    exit 0;
    } elsif (! -x $smartctl) {
    print "no (Predefined smartctl ($smartctl) is not executable)\n";
    exit 0;
    }
    } else {
    die "$smartctl does not exist\n" unless (-e $smartctl);
    die "$smartctl is not executable\n" unless (-x $smartctl);
    }
    } else {
    # Not defined in %ENV? Check obvious places
    my @dirs = split(':', $ENV{PATH});
    push (@dirs, qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin) );

    until ($smartctl or @dirs == 0) {
    my $dir = shift @dirs;
    my $path = $dir.'/smartctl';
    $smartctl = $path if -x $path;
    }
    }

    # Check version of smartctl to determine --nocheck capabilities
    my $use_nocheck = 0;
    if ($smartctl and `$smartctl --version` =~ / release (\d+\.\d+) /i) {
    $use_nocheck = $1 >= 5.37;
    warn "[DEBUG] Smartctl supports --nocheck\n" if $DEBUG;
    }

    # hdparm is used as a fallback
    my $hdparm = `which hdparm 2>/dev/null`;
    chomp $hdparm;

    my @drives;

    # Try to get a default set of drives
    if ($^O eq 'linux') {
    # On Linux, we know how to enumerate ide drives.
    my @drivesIDE;
    if (-d '/proc/ide') {
    opendir(IDE, '/proc/ide');
    @drivesIDE = grep /hd[a-z]/, readdir IDE;
    closedir(IDE);
    }

    # Look for SCSI / SATA drives in /sys
    my @drivesSCSI;
    if (-d '/sys/block/') {
    opendir(SCSI, '/sys/block/');
    @drivesSCSI = grep /sd[a-z]/, readdir SCSI;
    closedir(SCSI);
    }

    # Get list of all drives we found
    @drives=(@drivesIDE,@drivesSCSI);

    } elsif ($^O eq 'freebsd') {
    opendir(DEV, '/dev');
    @drives = grep /^da[0-9]+$|ad[0-9]+$|^ada[0-9]+$/, readdir DEV;
    closedir(DEV);
    } elsif ($^O eq 'solaris') {
    @drives = map { s@.*/@@ ; $_ } glob '/dev/rdsk/c*t*d*s2';
    }

    @drives = split ' ', $ENV{drives} if exists $ENV{drives};

    # Sort list of drives
    @drives = sort @drives;

    warn "[DEBUG] Drives: ",join(', ',@drives),"\n" if $DEBUG;

    if (defined $ARGV[0]) {
    if ($ARGV[0] eq 'autoconf') {
    if (@drives) {
    my $cmd = command_for_drive_device($drives[0],
    device_for_drive($drives[0]));
    if (`$cmd` =~ /Temperature/) {
    print "yes\n";
    } else {
    print "no (first drive not supported, configure the plugin)\n";
    }
    exit 0;
    } else {
    print "no (no drives known)\n";
    exit 0;
    }
    } elsif ($ARGV[0] eq 'config') {
    print "graph_title HDD temperature\n";
    print "graph_vlabel Degrees Celsius\n";
    print "graph_category sensors\n";
    print "graph_info This graph shows the temperature in degrees Celsius of the hard drives in the machine.\n";
    foreach (@drives) {
    my @dirs = splitdir($_);
    print clean_fieldname($_) . ".label " . $dirs[-1] . "\n";
    print clean_fieldname($_) . ".max 100\n";
    print clean_fieldname($_) . ".warning 57\n";
    print clean_fieldname($_) . ".critical 60\n";
    }
    exit 0;
    }
    }

    foreach my $drive (@drives) {
    warn "[DEBUG] Processing $drive\n" if $DEBUG;
    my $fulldev = device_for_drive($drive);

    # Fall back to using hdparm for detecting disks in stand-by only if nocheck
    # isn't supported (hdparm isn't available on all platforms).
    if (!$use_nocheck && $hdparm && $fulldev =~ /\/dev\/[sh]d?/) {
    if (`$hdparm -C $fulldev 2>/dev/null` =~ /standby/) {
    warn "[DEBUG] Drive $fulldev is in standby mode, not checking\n"
    if $DEBUG;
    next;
    }
    }
    my $cmd = command_for_drive_device($drive, $fulldev, $use_nocheck);
    warn "[DEBUG] Command for $drive is % $cmd %\n" if $DEBUG;

    my $output = `$cmd`;
    if ($? ne 0) {
    print "$drive.value U\n";
    print "$drive.extinfo Command $cmd on drive $drive failed: $?. The plugin needs to have read permission on all monitored devices.\n";
    warn "[ERROR] Command $cmd on drive $drive failed: $?. The plugin needs to have read permission on all monitored devices.\n";
    next;
    }
    if ($output =~ /Current Drive Temperature:\s*(\d+)/) {
    print "$drive.value $1\n";
    } elsif ($output =~ /^(194 Temperature_Celsius.*)/m) {
    my @F = split /\s+/, $1;
    print "$drive.value $F[9]\n";
    } elsif ($output =~ /^(231 Temperature_Celsius.*)/m) {
    my @F = split ' ', $1;
    print "$drive.value $F[9]\n";
    } else {
    print "$drive.value U\n";
    print "$drive.extinfo Temperature not detected in smartctl output\n";
    }
    }

    sub device_for_drive {
    my ($drive) = @_;
    my $dev = $drive =~ /(.*)(?:_\d+)$/ ? $1 : $drive;

    my $fulldev = '/dev/';
    $fulldev .= 'rdsk/' if $^O eq 'solaris';
    $fulldev .= exists $ENV{'dev_'.$drive} ? $ENV{'dev_'.$drive} : $dev;

    return $fulldev;
    }

    sub command_for_drive_device {
    my ($drive, $fulldev, $use_nocheck) = @_;

    my $cmd = $smartctl.' -A ';
    $cmd .= '--nocheck=standby ' if $use_nocheck;
    $cmd .= $ENV{'args_'.$drive}.' ' if exists $ENV{'args_'.$drive};
    $cmd .= '-d '.$ENV{'type_'.$drive}.' ' if exists $ENV{'type_'.$drive};
    $cmd .= $fulldev;

    }


     

  12. Ik kreeg helaas helaas niets te zien in de overzichten, dus moesten we gaan controleren. Dit kan je heel makkelijk doen door het script te starten:
    # cd /usr/local/share/munin/plugins
    # ./hddtemp_smartctl

    Opmerking: Een heleboel foutmeldingen, en laat de read permissions je niet misleiden. Het blijkt dat ik nog smartmon tools moest installeren.

  13. De meldingen kloppen deels wel, hij kan de data niet verkrijgen en daardoor denkt FreeBSD dat hij onvoldoende permissies heeft om de getallen uit te lezen. Je installeert smart_ctl door de volgende commando's in te voeren:
    # cd /usr/ports/sysutils/smartmontools
    # make install clean


  14. Houdt de standaard opties aan voor smartctl
  15. Smart monitoring tools zijn succesvol geinstalleerd:
  16. Nogmaals testen doormiddel van het commando:
    #
  17. Dit is een script die ik zelf heb gefabriceerd op basis van hddtemp_smartctl, genaamd: poweron_smartctl

    #!/usr/local/bin/perl –w
    # -*- perl -*-

    =head1 NAME

    poweron_smartctl - Plugin to monitor harddrive temperatures through
    SMART

    =head1 CONFIGURATION

    This plugin needs to run as root or some other user that has access to
    the harddrive devices.

    The following environment variables are used
    smartctl - path to smartctl executable
    drives - List drives to monitor. E.g. "env.drives hda hdc".
    type_$dev - device type for one drive, e.g. "env.type_sda 3ware,0"
    or more typically "env.type_sda ata" if sda is a SATA disk.
    args_$dev - additional arguments to smartctl for one drive,
    e.g. "env.args_hda -v 194,10xCelsius". Use this to make
    the plugin use the --all or -a option if your disk will
    not return its temperature when only the -A option is
    used.
    dev_$dev - monitoring device for one drive, e.g. twe0

    If the "smartctl" enviroment variable is not set the plugin will
    search your $PATH, /usr/bin, /usr/sbin, /usr/local/bin and
    /usr/local/sbin for a file called "smartctl", and use that.

    If the "drives" environment variable is not set, the plugin will
    attempt to search for drives to probe.

    =head1 MAGIC MARKERS

    #%# family=auto
    #%# capabilities=autoconf

    =head1 AUTHOR

    Copyright (c) 2005, Lutz Peter Christoph
    All rights reserved.

    =head1 LICENSE

    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.

    * The name and aliases of Lutz Peter Christoph ("Lupe Christoph",
    "Lutz Christoph") may not 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
    OWNER OR CONTRIBUTORS 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.

    =head1 NOTES

    Note for users of RAID controllers (smartmontools currently only
    supports 3ware): you can specify the drives attached to your RAID
    controller(s) as raiddev_num (e.g. sda_0). Then you must specify the
    type like this: type_sda_0 3ware,0.

    Recent versions of the kernel driver use a separate major device
    number for monitoring purposes, like /dev/twe or /dev/twa. This
    can be put in the e.g. dev_sda environment variable, to allow the user
    to keep sda as the name of the disk.

    To avoid spinning up sleeping disks smartctl will use the –nocheck
    parameter. If this parameter isn't supported by your version of
    smartctl then hdparm will be used. Note that hdparm isn't available
    on all platforms.

    =cut

    use strict;
    use File::Spec::Functions qw(splitdir);
    use lib $ENV{'MUNIN_LIBDIR'};
    use Munin::Plugin;

    my $DEBUG = $ENV{'MUNIN_DEBUG'} || 0;

    my $smartctl;

    if (exists $ENV{smartctl}) {
    $smartctl = $ENV{smartctl};
    if (defined $ARGV[0] and $ARGV[0] eq 'autoconf') {
    if (! -e $smartctl) {
    print "no (Predefined smartctl ($smartctl) does not exist)\n";
    exit 0;
    } elsif (! -x $smartctl) {
    print "no (Predefined smartctl ($smartctl) is not executable)\n";
    exit 0;
    }
    } else {
    die "$smartctl does not exist\n" unless (-e $smartctl);
    die "$smartctl is not executable\n" unless (-x $smartctl);
    }
    } else {
    # Not defined in %ENV? Check obvious places
    my @dirs = split(':', $ENV{PATH});
    push (@dirs, qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin) );

    until ($smartctl or @dirs == 0) {
    my $dir = shift @dirs;
    my $path = $dir.'/smartctl';
    $smartctl = $path if -x $path;
    }
    }

    # Check version of smartctl to determine --nocheck capabilities
    my $use_nocheck = 0;
    if ($smartctl and `$smartctl --version` =~ / release (\d+\.\d+) /i) {
    $use_nocheck = $1 >= 5.37;
    warn "[DEBUG] Smartctl supports --nocheck\n" if $DEBUG;
    }

    # hdparm is used as a fallback
    my $hdparm = `which hdparm 2>/dev/null`;
    chomp $hdparm;

    my @drives;

    # Try to get a default set of drives
    if ($^O eq 'linux') {
    # On Linux, we know how to enumerate ide drives.
    my @drivesIDE;
    if (-d '/proc/ide') {
    opendir(IDE, '/proc/ide');
    @drivesIDE = grep /hd[a-z]/, readdir IDE;
    closedir(IDE);
    }

    # Look for SCSI / SATA drives in /sys
    my @drivesSCSI;
    if (-d '/sys/block/') {
    opendir(SCSI, '/sys/block/');
    @drivesSCSI = grep /sd[a-z]/, readdir SCSI;
    closedir(SCSI);
    }

    # Get list of all drives we found
    @drives=(@drivesIDE,@drivesSCSI);

    } elsif ($^O eq 'freebsd') {
    opendir(DEV, '/dev');
    @drives = grep /^da[0-9]+$|ad[0-9]+$|^ada[0-9]+$/, readdir DEV;
    closedir(DEV);
    } elsif ($^O eq 'solaris') {
    @drives = map { s@.*/@@ ; $_ } glob '/dev/rdsk/c*t*d*s2';
    }

    @drives = split ' ', $ENV{drives} if exists $ENV{drives};

    # Sort list of drives
    @drives = sort @drives;

    warn "[DEBUG] Drives: ",join(', ',@drives),"\n" if $DEBUG;

    if (defined $ARGV[0]) {
    if ($ARGV[0] eq 'autoconf') {
    if (@drives) {
    my $cmd = command_for_drive_device($drives[0],
    device_for_drive($drives[0]));
    if (`$cmd` =~ /Power_On/) {
    print "yes\n";
    } else {
    print "no (first drive not supported, configure the plugin)\n";
    }
    exit 0;
    } else {
    print "no (no drives known)\n";
    exit 0;
    }
    } elsif ($ARGV[0] eq 'config') {
    print "graph_title HDD power on hours\n";
    print "graph_vlabel Hours\n";
    print "graph_category s.m.a.r.t.\n";
    print "graph_info This graph shows the Power on hours of the hard drives in the machine.\n";
    foreach (@drives) {
    my @dirs = splitdir($_);

    ## According to: http://en.wikipedia.org/wiki/S.M.A.R.T.
    ## 5 Years is the max: 4380000 Hours
    ## So i took that is critical
    #
    print clean_fieldname($_) . ".label " . $dirs[-1] . "\n";
    print clean_fieldname($_) . ".max 6132000\n";
    print clean_fieldname($_) . ".warning 4380000\n";
    print clean_fieldname($_) . ".critical 5256000\n";
    }
    exit 0;
    }
    }

    foreach my $drive (@drives) {
    warn "[DEBUG] Processing $drive\n" if $DEBUG;
    my $fulldev = device_for_drive($drive);

    # Fall back to using hdparm for detecting disks in stand-by only if nocheck
    # isn't supported (hdparm isn't available on all platforms).
    if (!$use_nocheck && $hdparm && $fulldev =~ /\/dev\/[sh]d?/) {
    if (`$hdparm -C $fulldev 2>/dev/null` =~ /standby/) {
    warn "[DEBUG] Drive $fulldev is in standby mode, not checking\n"
    if $DEBUG;
    next;
    }
    }

    my $cmd = command_for_drive_device($drive, $fulldev, $use_nocheck);
    warn "[DEBUG] Command for $drive is % $cmd %\n" if $DEBUG;

    #echo $cmd."\n";
    my $output = `$cmd`;

    if ($output =~ /^(Product:.*)/m) {
    my @F = split /\s+/, $1;
    print "$drive.extinfo Product: $F[1]\n";
    }

    if ($output =~ /^(Device does not support Self Test logging.*)/m)
    {
    print "$drive.extinfo Hard Disk Drive does not support Self Test logging.\n";
    next;
    }
    elsif ($output =~ /^(=== START OF INFORMATION SECTION ===.*)/m)
    {
    ## For some reason the script things it does not support smart,
    ## but it does support smart!
    }
    else
    {
    if ($? ne 0) {
    print "$drive.value U\n";
    print "$drive.extinfo Command $cmd on drive $drive failed: $?. The plugin needs to have read permission on all monitored devices.\n";
    warn "[ERROR] Command $cmd on drive $drive failed: $?. The plugin needs to have read permission on all monitored devices.\n";
    next;
    }
    }

    print "$drive.extinfo ";
    if ($output =~ /^(Serial Number:.*)/m) {
    my @F = split /\s+/, $1;
    print "Serial Number: $F[2]";
    }
    if ($output =~ /^(Device Model:.*)/m) {
    my @F = split /\s+/, $1;
    print "Device Model: $F[2] $F[3] $F[4]";
    }
    if ($output =~ /^(Model Family:.*)/m) {
    my @F = split /\s+/, $1;
    print "Device Family: $F[2] $F[3] $F[4] $F[5] $F[6] $F[7] $F[8]\n";
    }
    if ($output =~ /Power On Hours\s*(\d+)/) {
    print "$drive.value $1\n";
    } elsif ($output =~ /^( 9 Power_On_Hours.*)/m) {
    my @F = split /\s+/, $1;
    print "$drive.value $F[10]\n";
    } elsif ($output =~ /^(240 Head_Flying_Hours.*)/m) {
    my @F = split ' ', $1;
    print "$drive.value $F[10]\n";
    } else {
    print "$drive.value U\n";
    print "$drive.extinfo Power on hours not detected in smartctl output\n";
    }
    }

    sub device_for_drive {
    my ($drive) = @_;
    my $dev = $drive =~ /(.*)(?:_\d+)$/ ? $1 : $drive;
    my $fulldev = '/dev/';
    $fulldev .= 'rdsk/' if $^O eq 'solaris';
    $fulldev .= exists $ENV{'dev_'.$drive} ? $ENV{'dev_'.$drive} : $dev;
    return $fulldev;
    }

    sub command_for_drive_device {
    my ($drive, $fulldev, $use_nocheck) = @_;
    my $cmd = $smartctl.' -a ';
    $cmd .= '--nocheck=standby ' if $use_nocheck;
    $cmd .= $ENV{'args_'.$drive}.' ' if exists $ENV{'args_'.$drive};
    #$cmd .= '-d '.$ENV{'type_'.$drive}.' ' if exists $ENV{'type_'.$drive};
    $cmd .= $fulldev;
    }

  18. Dan moeten we natuurlijk ook weer een link maken:
    # cd /usr/local/etc/munin/plugins
    # ln -s /usr/local/share/munin/plugins/poweron_smartctl poweron_smartctl

  19. En herstart de Munin node service
    # service munin-node restart


     

  20. Het veiligheids aspect zat me toch niet helemaal lekker, dus heb ik een .htaccess bestand aangemaakt in /usr/local/www/apache24/data. Maar dit functioneerde helemaal niet, waarschijnlijk hangt dit weer samen met het probleem van munin.

    Kwam er achter dat httpd.conf aangepast moet worden:
    # vi /usr/local/etc/apache24/httpd.conf

    Zoek naar DocumentRoot " /usr/local/www/apache24/data"

    Verander de volgende lijnen:
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    Order deny,allow

    en zet een # voor
    #Require all Granted



  21. Herstart de apache server:
    /usr/local/sbin/apachectl graceful

    Opmerking: Deze kon ik nog niet en gaat dus in mijn hoofd als betere optie dan harde herstart.

  22. Na de herstart werkt .htaccess dus wel, aangezien deze in de root staat moet je eerst een wachtwoord invoeren wil je uberhaupt iets zien, dus ook de munin directory.


    Met een gerust hard heb ik mijn router ingesteld om deze poort te forwarden, en uiteraard niet op de standaard poort.

  23. TIP! Ik kon de Munin node van de host niet uitlezen, dit kwam omdat ik de netwerk kaart van de VirtualBox waarin Munin Master draaide niet op DHCP stond. Nadat ik dit had aangepast in /etc/rc.conf en een herstart had gedaan werden de gegevens van de host door de guest wel weer goed uitgelezen.

 

Lees hier hoe ik verder ben gegaan met de installatie van mijn server:
Samba 4.3 installeren