From 0792f65232a6e92e0c0dff5ec7d91d998f7870b8 Mon Sep 17 00:00:00 2001 From: Charles Wyble Date: Thu, 25 Apr 2019 22:50:23 -0500 Subject: [PATCH] adding libre bits --- libre-work/librenms-tsys-agent.tar.gz | Bin 0 -> 10071 bytes libre-work/librenms/distro | 114 ++++++ libre-work/librenms/ntp-client.sh | 25 ++ libre-work/librenms/ntp-server.sh | 89 +++++ libre-work/librenms/os-updates.sh | 73 ++++ libre-work/librenms/postfix-queues | 13 + libre-work/librenms/postfixdetailed | 545 ++++++++++++++++++++++++++ libre-work/librenms/smart | 363 +++++++++++++++++ libre-work/librenms/smart.config | 3 + libre-work/librenms/snmpd.conf | 32 ++ 10 files changed, 1257 insertions(+) create mode 100644 libre-work/librenms-tsys-agent.tar.gz create mode 100755 libre-work/librenms/distro create mode 100755 libre-work/librenms/ntp-client.sh create mode 100755 libre-work/librenms/ntp-server.sh create mode 100755 libre-work/librenms/os-updates.sh create mode 100755 libre-work/librenms/postfix-queues create mode 100755 libre-work/librenms/postfixdetailed create mode 100755 libre-work/librenms/smart create mode 100644 libre-work/librenms/smart.config create mode 100644 libre-work/librenms/snmpd.conf diff --git a/libre-work/librenms-tsys-agent.tar.gz b/libre-work/librenms-tsys-agent.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6c05ea02d7a2f57936809037f730dd2da02b614d GIT binary patch literal 10071 zcmV-dC#cvTiwFP!000021MNL~f7>>a{a5@HsH{ENiJpGOPSvd<$%(GE?3Ltrb8%|Z z5@m5ikqRGH-PHHlZ)O0HAVtY?(q{M9v(hFcFf$ko2Ebr204?*{HSCF3{_fBFRp7U` zv-4eLw^H5PsnWldN|n;Z@4M>OcD1szyR);m{avNHRo$z6$9BH^2EV}bb(gX48e`qH z43Bl#`Q5c;%)xaW+xYIU_p@aC4^7W^oqtFB?{01GLi=y-ZS7V!w>CGS{kOL_q5UgQ z?f<9$*1j(Xo?E^)?XqFtvTNNNYiq1&_{PBZ*lcVL#_XiWbbH9m5i@;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f$*P99B$2 zh_dnHRcm-YSc`x0Dg`P2aW!qNiDB~&Yr+bJZeWoVVin!2Y*tHqFZL^?Dvz^wQfc$7 t@UvULjl85>AW5717;Orr*tcn)rue7d)9>l`^!rQy{tx|nV$}eu003Q(s!;#{ literal 0 HcmV?d00001 diff --git a/libre-work/librenms/distro b/libre-work/librenms/distro new file mode 100755 index 0000000..61ad248 --- /dev/null +++ b/libre-work/librenms/distro @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# Detects which OS and if it is Linux then it will detect which Linux Distribution. + +OS=`uname -s` +REV=`uname -r` +MACH=`uname -m` + +if [ "${OS}" = "SunOS" ] ; then + OS=Solaris + ARCH=`uname -p` + OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" + +elif [ "${OS}" = "AIX" ] ; then + OSSTR="${OS} `oslevel` (`oslevel -r`)" + +elif [ "${OS}" = "Linux" ] ; then + KERNEL=`uname -r` + + if [ -f /etc/fedora-release ]; then + DIST=$(cat /etc/fedora-release | awk '{print $1}') + REV=`cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//` + + elif [ -f /etc/redhat-release ] ; then + DIST=$(cat /etc/redhat-release | awk '{print $1}') + if [ "${DIST}" = "CentOS" ]; then + DIST="CentOS" + elif [ "${DIST}" = "Mandriva" ]; then + DIST="Mandriva" + PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//` + REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//` + elif [ -f /etc/oracle-release ]; then + DIST="Oracle" + else + DIST="RedHat" + fi + + PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` + REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` + + elif [ -f /etc/mandrake-release ] ; then + DIST='Mandrake' + PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//` + REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//` + + elif [ -f /etc/devuan_version ] ; then + DIST="Devuan `cat /etc/devuan_version`" + REV="" + + elif [ -f /etc/debian_version ] ; then + DIST="Debian `cat /etc/debian_version`" + REV="" + ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g'` + if [ "${ID}" = "Raspbian" ] ; then + DIST="Raspbian `cat /etc/debian_version`" + fi + + elif [ -f /etc/gentoo-release ] ; then + DIST="Gentoo" + REV=$(tr -d '[[:alpha:]]' $new ){ + return $new; + }; + + return $new - $old; +} + + +my $output=`$pflogsumm /var/log/mail.log`; + +#holds client host rejected values till the end when it is compared to the old one +my $chrNew=0; + +#holds RBL values till the end when it is compared to the old one +my $buNew=0; + +# holds recipient address rejected values till the end when it is compared to the old one +my $raruuNew=0; + +#holds the current values for checking later +my $current=''; + +my @outputA=split( /\n/, $output ); +my $int=0; +while ( defined( $outputA[$int] ) ){ + my $line=$outputA[$int]; + + $line=~s/^ *//; + $line=~s/ +/ /g; + $line=~s/\)$//; + + my $handled=0; + + #received line + if ( ( $line =~ /[0123456789] received$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $receivedC=$line; + $received=newValue( $received, $line ); + $handled=1; + } + + #delivered line + if ( ( $line =~ /[0123456789] delivered$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $deliveredC=$line; + $delivered=newValue( $delivered, $line ); + $handled=1; + } + + #forward line + if ( ( $line =~ /[0123456789] forwarded$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $forwardedC=$line; + $forwarded=newValue( $forwarded, $line ); + $handled=1; + } + + #defereed line + if ( ( $line =~ /[0123456789] deferred \(/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $deferredC=$line; + $deferred=newValue( $deferred, $line ); + $handled=1; + } + + #bounced line + if ( ( $line =~ /[0123456789] bounced$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $bouncedC=$line; + $bounced=newValue( $bounced, $line ); + $handled=1; + } + + #rejected line + if ( ( $line =~ /[0123456789] rejected \(/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $rejectedC=$line; + $rejected=newValue( $rejected, $line ); + $handled=1; + } + + #reject warning line + if ( ( $line =~ /[0123456789] reject warnings/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $rejectwC=$line; + $rejectw=newValue( $rejectw, $line ); + $handled=1; + } + + #held line + if ( ( $line =~ /[0123456789] held$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $heldC=$line; + $held=newValue( $held, $line ); + $handled=1; + } + + #discarded line + if ( ( $line =~ /[0123456789] discarded \(/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $discardedC=$line; + $discarded=newValue( $discarded, $line ); + $handled=1; + } + + #bytes received line + if ( ( $line =~ /[0123456789kM] bytes received$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $line=~s/k/000/; + $line=~s/M/000000/; + $bytesrC=$line; + $bytesr=newValue( $bytesr, $line ); + $handled=1; + } + + #bytes delivered line + if ( ( $line =~ /[0123456789kM] bytes delivered$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $line=~s/k/000/; + $line=~s/M/000000/; + $bytesdC=$line; + $bytesd=newValue( $bytesd, $line ); + $handled=1; + } + + #senders line + if ( ( $line =~ /[0123456789] senders$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $sendersC=$line; + $senders=newValue( $senders, $line ); + $handled=1; + } + + #sendering hosts/domains line + if ( ( $line =~ /[0123456789] sending hosts\/domains$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $sendinghdC=$line; + $sendinghd=newValue( $sendinghd, $line ); + $handled=1; + } + + #recipients line + if ( ( $line =~ /[0123456789] recipients$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $recipientsC=$line; + $recipients=newValue( $recipients, $line ); + $handled=1; + } + + #recipients line + if ( ( $line =~ /[0123456789] recipient hosts\/domains$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $recipienthdC=$line; + $recipienthd=newValue( $recipienthd, $line ); + $handled=1; + } + + # deferrals connectios refused + if ( ( $line =~ /[0123456789] 25\: Connection refused$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $deferralcrC=$line; + $deferralcr=newValue( $deferralcr, $line ); + $handled=1; + } + + # deferrals Host is down + if ( ( $line =~ /Host is down$/ ) && ( ! $handled ) ){ + $line=~s/ .*//; + $deferralhidC=$line; + $deferralhid=newValue( $deferralhid, $line ); + $handled=1; + } + + # Client host rejected + if ( ( $line =~ /Client host rejected/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $chrNew=$chrNew + $line; + $handled=1; + } + + #Helo command rejected: need fully-qualified hostname + if ( ( $line =~ /Helo command rejected\: need fully\-qualified hostname/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $hcrnfqhC=$line; + $hcrnfqh=newValue( $hcrnfqh, $line ); + $handled=1; + } + + #Sender address rejected: Domain not found + if ( ( $line =~ /Sender address rejected\: Domain not found/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $sardnfC=$line; + $sardnf=newValue( $sardnf, $line ); + $handled=1; + } + + #Sender address rejected: not owned by user + if ( ( $line =~ /Sender address rejected\: not owned by user/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $sarnobuC=$line; + $sarnobu=newValue( $sarnobu, $line ); + $handled=1; + } + + #blocked using + # These lines are RBLs so there will be more than one. + # Use $buNew to add them all up. + if ( ( $line =~ /blocked using/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $buNew=$buNew + $line; + $handled=1; + } + + #Recipient address rejected: User unknown + if ( ( $line =~ /Recipient address rejected\: User unknown/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $raruuNew=$raruuNew + $line; + $handled=1; + } + + #Helo command rejected: Invalid name + if ( ( $line =~ /Helo command rejected\: Invalid name/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $hcrinC=$line; + $hcrin=newValue( $hcrin, $line ); + } + + #Sender address rejected: need fully-qualified address + if ( ( $line =~ /Sender address rejected\: need fully-qualified address/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $sarnfqaC=$line; + $sarnfqa=newValue( $sarnfqa, $line ); + } + + #Recipient address rejected: Domain not found + if ( ( $line =~ /Recipient address rejected\: Domain not found/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $rardnfC=$line; + $rardnf=newValue( $rardnf, $line ); + } + + #Improper use of SMTP command pipelining + if ( ( $line =~ /Improper use of SMTP command pipelining/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $iuoscpC=$line; + $iuoscp=newValue( $iuoscp, $line ); + } + + #Message size exceeds fixed limit + if ( ( $line =~ /Message size exceeds fixed limit/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $mseflC=$line; + $msefl=newValue( $msefl, $line ); + } + + #Server configuration error + if ( ( $line =~ /Server configuration error/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $sceC=$line; + $sce=newValue( $sce, $line ); + } + + #Server configuration problem + if ( ( $line =~ /Server configuration problem/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $scpC=$line; + $scp=newValue( $scp, $line ); + } + + #unknown reject reason + if ( ( $line =~ /unknown reject reason/ ) && ( ! $handled ) ){ + $line=~s/.*\: //g; + $urrC=$line; + $urr=newValue( $urr, $line ); + } + $int++; +} + +# final client host rejected total +$chr=newValue( $chr, $chrNew ); + +# final RBL total +$bu=newValue( $bu, $buNew ); + +# final recipient address rejected total +$raruu=newValue( $raruu, $raruuNew ); + +my $data=$received."\n". + $delivered."\n". + $forwarded."\n". + $deferred."\n". + $bounced."\n". + $rejected."\n". + $rejectw."\n". + $held."\n". + $discarded."\n". + $bytesr."\n". + $bytesd."\n". + $senders."\n". + $sendinghd."\n". + $recipients."\n". + $recipienthd."\n". + $deferralcr."\n". + $deferralhid."\n". + $chr."\n". + $hcrnfqh."\n". + $sardnf."\n". + $sarnobu."\n". + $bu."\n". + $raruu."\n". + $hcrin."\n". + $sarnfqa."\n". + $rardnf."\n". + $rarnfqa."\n". + $iuscp."\n". + $sce."\n". + $scp."\n". + $urr."\n"; + $msefl."\n". + +print $data; + +my $current=$receivedC."\n". + $deliveredC."\n". + $forwardedC."\n". + $deferredC."\n". + $bouncedC."\n". + $rejectedC."\n". + $rejectwC."\n". + $heldC."\n". + $discardedC."\n". + $bytesrC."\n". + $bytesdC."\n". + $sendersC."\n". + $sendinghdC."\n". + $recipientsC."\n". + $recipienthdC."\n". + $deferralcrC."\n". + $deferralhidC."\n". + $chrNew."\n". + $hcrnfqhC."\n". + $sardnfC."\n". + $sarnobuC."\n". + $buNew."\n". + $raruuNew."\n". + $hcrinC."\n". + $sarnfqaC."\n". + $rardnfC."\n". + $rarnfqaC."\n". + $iuscpC."\n". + $mseflC."\n". + $sceC."\n". + $scpC."\n". + $urrC."\n"; + +open(my $fh, ">", $cache) or die "Can't open '".$cache."'"; +print $fh $current; +close($fh); diff --git a/libre-work/librenms/smart b/libre-work/librenms/smart new file mode 100755 index 0000000..44b7a31 --- /dev/null +++ b/libre-work/librenms/smart @@ -0,0 +1,363 @@ +#!/usr/bin/env perl +#Copyright (c) 2017, Zane C. Bowers-Hadley +#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. +# +#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. + +=for comment + +Add this to snmpd.conf like below. + + extend smart /etc/snmp/smart + +Then add to root's cron tab, if you have more than a few disks. + + */3 * * * * /etc/snmp/smart -u + +You will also need to create the config file, which defaults to the same path as the script, +but with .config appended. So if the script is located at /etc/snmp/smart, the config file +will be /etc/snmp/smart.config. Alternatively you can also specific a config via -c. + +Anything starting with a # is comment. The format for variables is $variable=$value. Empty +lines are ignored. Spaces and tabes at either the start or end of a line are ignored. Any +line with out a = or # are treated as a disk. + + #This is a comment + cache=/var/cache/smart + smartctl=/usr/local/sbin/smartctl + useSN=0 + ada0 + ada1 + +The variables are as below. + + cache = The path to the cache file to use. Default: /var/cache/smart + smartctl = The path to use for smartctl. Default: /usr/bin/env smartctl + useSN = If set to 1, it will use the disks SN for reporting instead of the device name. + 1 is the default. 0 will use the device name. + +If you want to guess at the configuration, call it with -g and it will print out what it thinks +it should be. + +=cut + +## +## You should not need to touch anything below here. +## +use warnings; +use strict; +use Getopt::Std; + +my $cache='/var/cache/smart'; +my $smartctl='/usr/bin/env smartctl'; +my @disks; +my $useSN=1; + +$Getopt::Std::STANDARD_HELP_VERSION = 1; +sub main::VERSION_MESSAGE { + print "SMART SNMP extend 0.0.0\n"; +}; + + +sub main::HELP_MESSAGE { + print "\n". + "-u Update '".$cache."'\n". + "-g Guess at the config and print it to STDOUT.\n". + "-c The config file to use.\n"; +} + +#gets the options +my %opts=(); +getopts('ugc:', \%opts); + +# guess if asked +if ( defined( $opts{g} ) ){ + + #get what path to use for smartctl + $smartctl=`which smartctl`; + chomp($smartctl); + if ( $? != 0 ){ + warn("'which smartctl' failed with a exit code of $?"); + exit 1; + } + + #try to touch the default cache location and warn if it can't be done + system('touch '.$cache.'>/dev/null'); + if ( $? != 0 ){ + $cache='#Could not touch '.$cache. "You will need to manually set it\n". + "cache=?\n"; + }else{ + $cache='cache='.$cache."\n"; + } + + my %found_disks; + + #check for drives named /dev/sd* + my @matches=glob('/dev/sd*'); + @matches=grep(!/[0-9]/, @matches); + my $matches_int=0; + while ( defined( $matches[$matches_int] ) ){ + my $device=$matches[$matches_int]; + system( $smartctl.' -A '.$device.' > /dev/null' ); + if ( $? == 0 ){ + $device =~ s/\/dev\///; + $found_disks{$device}=1; + } + + $matches_int++; + } + + #check for drives named /dev/ada* + @matches=glob('/dev/ada*'); + @matches=grep(!/[ps]/, @matches); + $matches_int=0; + while ( defined( $matches[$matches_int] ) ){ + my $device=$matches[$matches_int]; + system( $smartctl.' -A '.$device.' > /dev/null' ); + if ( $? == 0 ){ + $device =~ s/\/dev\///; + $found_disks{$device}=1; + } + + $matches_int++; + } + + #check for drives named /dev/da* + @matches=glob('/dev/da*'); + @matches=grep(!/[ps]/, @matches); + $matches_int=0; + while ( defined( $matches[$matches_int] ) ){ + my $device=$matches[$matches_int]; + system( $smartctl.' -A '.$device.' > /dev/null' ); + if ( $? == 0 ){ + $device =~ s/\/dev\///; + $found_disks{$device}=1; + } + + $matches_int++; + } + + #have smartctl scan and see if it finds anythings not get found + my $scan_output=`$smartctl --scan-open`; + my @scan_outputA=split(/\n/, $scan_output); + @scan_outputA=grep(!/ses[0-9]/, @scan_outputA); # not a disk, but may or may not have SMART attributes + @scan_outputA=grep(!/pass[0-9]/, @scan_outputA); # very likely a duplicate and a disk under another name + $matches_int=0; + while ( defined( $scan_outputA[$matches_int] ) ){ + my $device=$scan_outputA[$matches_int]; + $device =~ s/ .*//; + system( $smartctl.' -A '.$device.' > /dev/null' ); + if ( $? == 0 ){ + $device =~ s/\/dev\///; + $found_disks{$device}=1; + } + + $matches_int++; + } + + print "useSN=0\n".'smartctl='.$smartctl."\n". + $cache. + join( "\n", keys(%found_disks) )."\n"; + + exit 0; +} + +#get which config file to use +my $config=$0.'.config'; +if ( defined( $opts{c} ) ){ + $config=$opts{c}; +} + +#reads the config file, optionally +my $config_file=''; +open(my $readfh, "<", $config) or die "Can't open '".$config."'"; +read($readfh , $config_file , 1000000); +close($readfh); + +#parse the config file and remove comments and empty lines +my @configA=split(/\n/, $config_file); +@configA=grep(!/^$/, @configA); +@configA=grep(!/^\#/, @configA); +@configA=grep(!/^[\s\t]*$/, @configA); +my $configA_int=0; +while ( defined( $configA[$configA_int] ) ){ + my $line=$configA[$configA_int]; + $line=~s/^[\t\s]+//; + $line=~s/[\t\s]+$//; + + my ( $var, $val )=split(/=/, $line, 2); + + if ( $var eq 'cache' ){ + $cache=$val; + } + + if ( $var eq 'smartctl' ){ + $smartctl=$val; + } + + if ( $var eq 'useSN' ){ + $useSN=$val; + } + + if ( !defined( $val ) ){ + push(@disks, $var); + } + + $configA_int++; +} + +#if set to 1, no cache will be written and it will be printed instead +my $noWrite=0; + +# if no -u, it means we are being called from snmped +if ( ! defined( $opts{u} ) ){ + # if the cache file exists, print it, otherwise assume one is not being used + if ( -f $cache ){ + my $old=''; + open(my $readfh, "<", $cache) or die "Can't open '".$cache."'"; + read($readfh , $old , 1000000); + close($readfh); + print $old; + exit 0; + }else{ + $opts{u}=1; + $noWrite=1; + } +} + +my $toReturn=''; +my $int=0; +while ( defined($disks[$int]) ) { + my $disk=$disks[$int]; + my $disk_sn=$disk; + my $output=`$smartctl -A /dev/$disk`; + + my %IDs=( '5'=>'null', + '10'=>'null', + '173'=>'null', + '177'=>'null', + '183'=>'null', + '184'=>'null', + '187'=>'null', + '188'=>'null', + '190'=>'null', + '194'=>'null', + '196'=>'null', + '197'=>'null', + '198'=>'null', + '199'=>'null', + '231'=>'null', + '233'=>'null', + ); + + my @outputA=split( /\n/, $output ); + my $outputAint=0; + while ( defined($outputA[$outputAint]) ) { + my $line=$outputA[$outputAint]; + $line=~s/^ +//; + $line=~s/ +/ /g; + + if ( $line =~ /^[0123456789]+ / ) { + my @lineA=split(/\ /, $line, 10); + my $raw=$lineA[9]; + my $id=$lineA[0]; + + # single int raw values + if ( + ( $id == 5 ) || + ( $id == 10 ) || + ( $id == 173 ) || + ( $id == 177 ) || + ( $id == 183 ) || + ( $id == 184 ) || + ( $id == 187 ) || + ( $id == 196 ) || + ( $id == 197 ) || + ( $id == 198 ) || + ( $id == 199 ) || + ( $id == 231 ) || + ( $id == 233 ) + ) { + $IDs{$id}=$raw; + } + + # 188, Command_Timeout + if ( $id == 188 ) { + my $total=0; + my @rawA=split( /\ /, $raw ); + my $rawAint=0; + while ( defined( $rawA[$rawAint] ) ) { + $total=$total+$rawA[$rawAint]; + $rawAint++; + } + $IDs{$id}=$total; + } + + # 190, airflow temp + # 194, temp + if ( + ( $id == 190 ) || + ( $id == 194 ) + ) { + my ( $temp )=split(/\ /, $raw); + $IDs{$id}=$temp; + } + + } + + $outputAint++; + } + + #get the selftest logs + $output=`$smartctl -l selftest /dev/$disk`; + @outputA=split( /\n/, $output ); + my $completed=scalar grep(/Completed without error/, @outputA); + my $interrupted=scalar grep(/Interrupted/, @outputA); + my $read_failure=scalar grep(/read failure/, @outputA); + my $unknown_failure=scalar grep(/unknown failure/, @outputA); + my $extended=scalar grep(/Extended/, @outputA); + my $short=scalar grep(/Short/, @outputA); + my $conveyance=scalar grep(/Conveyance/, @outputA); + my $selective=scalar grep(/Selective/, @outputA); + + # get the drive serial number, if needed + my $disk_id=$disk; + if ( $useSN ){ + while (`$smartctl -i /dev/$disk` =~ /Serial Number:(.*)/g) { + $disk_id = $1; + $disk_id =~ s/^\s+|\s+$//g; + } + } + + $toReturn=$toReturn.$disk_id.','.$IDs{'5'}.','.$IDs{'10'}.','.$IDs{'173'}.','.$IDs{'177'}.','.$IDs{'183'}.','.$IDs{'184'}.','.$IDs{'187'}.','.$IDs{'188'} + .','.$IDs{'190'} .','.$IDs{'194'}.','.$IDs{'196'}.','.$IDs{'197'}.','.$IDs{'198'}.','.$IDs{'199'}.','.$IDs{'231'}.','.$IDs{'233'}.','. + $completed.','.$interrupted.','.$read_failure.','.$unknown_failure.','.$extended.','.$short.','.$conveyance.','.$selective."\n"; + + $int++; +} + +if ( ! $noWrite ){ + open(my $writefh, ">", $cache) or die "Can't open '".$cache."'"; + print $writefh $toReturn; + close($writefh); +}else{ + print $toReturn; +} diff --git a/libre-work/librenms/smart.config b/libre-work/librenms/smart.config new file mode 100644 index 0000000..2b12988 --- /dev/null +++ b/libre-work/librenms/smart.config @@ -0,0 +1,3 @@ +smartctl=/usr/sbin/smartctl +cache=/var/cache/smart +sda diff --git a/libre-work/librenms/snmpd.conf b/libre-work/librenms/snmpd.conf new file mode 100644 index 0000000..ee89764 --- /dev/null +++ b/libre-work/librenms/snmpd.conf @@ -0,0 +1,32 @@ +########################################################################## +# snmpd.conf +# Created by CNW on 11/3/2018 via snmpconf wizard and manual post tweaks +########################################################################### +# SECTION: Monitor Various Aspects of the Running Host +# +# The following check up on various aspects of a host. + +# disk: Check for disk space usage of a partition. +# The agent can check the amount of available disk space, and make +# sure it is above a set limit. +# +load 3 3 3 +rocommunity kn3lmgmt 10.253.3.99 +syslocation PFV +syscontact prodtechopsalerts@turnsys.com +sysservices 76 + + +#TSYS tweaks +#Temperature +#pass_persist .1.3.6.1.4.1.9.9.13.1.3 /usr/local/bin/temper-snmp +#Smart +extend smart /usr/local/librenms/smart +#NTP +extend ntp-client /usr/local/librenms/ntp-client.sh +#SMTP +extend mailq /usr/local/librenms/postfix-queues +#Distro Detection +extend .1.3.6.1.4.1.2021.7890.1 distro /usr/local/librenms/distro +#extend zfs /usr/local/bin/zfs +extend osupdate /usr/local/librenms/os-updates.sh