mirror of
https://github.com/librenms/librenms-agent.git
synced 2024-05-09 09:54:52 +00:00
Lint more files (#356)
This commit is contained in:
@@ -4,18 +4,18 @@
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
stats="/etc/bind/named.stats"
|
||||
|
||||
echo "<<<bind>>>"
|
||||
> $stats
|
||||
true > $stats
|
||||
rndc stats && cat $stats
|
||||
|
||||
|
@@ -14,7 +14,7 @@ EXITCODE=3
|
||||
|
||||
while getopts "Vha:H:p:" opt; do
|
||||
case $opt in
|
||||
V) printf "check_mrpe v$VERSION\n"
|
||||
V) printf 'check_mrpe v%s\n' "$VERSION"
|
||||
exit 0
|
||||
;;
|
||||
h) hflag=1
|
||||
@@ -25,8 +25,7 @@ while getopts "Vha:H:p:" opt; do
|
||||
H) Hflag=1
|
||||
Hval="$OPTARG"
|
||||
;;
|
||||
p) pflag=1
|
||||
pval="$OPTARG"
|
||||
p) pval="$OPTARG"
|
||||
;;
|
||||
\?) hflag=1
|
||||
EXITCODE=0
|
||||
@@ -80,4 +79,4 @@ for i in $($BIN_NC -w 1 "$Hval" "$pval" 2>&1 | $BIN_SED '/^<<<mrpe>>>/,/^<<</{//
|
||||
fi
|
||||
done
|
||||
|
||||
exit $EXITCODE
|
||||
exit $EXITCODE
|
||||
|
@@ -5,5 +5,5 @@ echo '<<<dmi>>>'
|
||||
# requires dmidecode
|
||||
for FIELD in bios-vendor bios-version bios-release-date system-manufacturer system-product-name system-version system-serial-number system-uuid baseboard-manufacturer baseboard-product-name baseboard-version baseboard-serial-number baseboard-asset-tag chassis-manufacturer chassis-type chassis-version chassis-serial-number chassis-asset-tag processor-family processor-manufacturer processor-version processor-frequency
|
||||
do
|
||||
echo $FIELD=$(dmidecode -s $FIELD | grep -v '^#')
|
||||
echo $FIELD="$(dmidecode -s $FIELD | grep -v '^#')"
|
||||
done
|
||||
|
@@ -21,7 +21,7 @@ LOG_NEW='/var/cache/librenms/nfsstats_new'
|
||||
$BIN_NFSSTAT -$CFG_NFSVER -n -l | $BIN_TR -s " " | $BIN_CUT -d ' ' -f 5 | $BIN_GREP -v '^$' > $LOG_NEW 2>&1
|
||||
|
||||
$BIN_PASTE $LOG_NEW $LOG_OLD | while read a b ; do
|
||||
echo $(($a - $b))
|
||||
echo $(($a - $b))
|
||||
done
|
||||
|
||||
$BIN_RM $LOG_OLD 2>&1
|
||||
|
@@ -7,6 +7,7 @@
|
||||
# @author SvennD <svennd@svennd.be>
|
||||
|
||||
# required
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/profile.d/sge-binaries.sh;
|
||||
|
||||
QSTAT="/opt/gridengine/bin/linux-x64/qstat"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# wlClients.sh
|
||||
# Counts connected (associated) Wi-Fi devices
|
||||
# Arguments: targed interface. Assumes all interfaces if no argument
|
||||
@@ -12,16 +12,13 @@ if [ $# -gt 1 ]; then
|
||||
fi
|
||||
|
||||
# Get path to this script
|
||||
scriptdir=$(dirname $(readlink -f -- "$0"))
|
||||
scriptdir=$(dirname "$(readlink -f -- "$0")")
|
||||
|
||||
# Get hostname, interface list. Set target, which is name returned for interface
|
||||
hostname=$(/bin/uname -n)
|
||||
# Get interface list. Set target, which is name returned for interface
|
||||
if [ "$1" ]; then
|
||||
interfaces=$1
|
||||
target=$1
|
||||
else
|
||||
interfaces=$(cat "$scriptdir"/wlInterfaces.txt | cut -f 1 -d",")
|
||||
target=wlan
|
||||
fi
|
||||
|
||||
# Count associated devices
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# wlFrequency.sh
|
||||
# Returns wlFrequency, in MHz (not channel number)
|
||||
# Arguments: targed interface
|
||||
@@ -11,8 +11,7 @@ if [ $# -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get hostname, extract frequency
|
||||
hostname=$(/bin/uname -n)
|
||||
# Extract frequency
|
||||
frequency=$(/usr/sbin/iw dev "$1" info | /bin/grep channel | /usr/bin/cut -f 2- -s -d" " | /usr/bin/cut -f 2- -s -d"(" | /usr/bin/cut -f 1 -s -d" ")
|
||||
|
||||
# Return snmp result
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# wlNoiseFloor.sh
|
||||
# Returns wlNoiseFloor, in dBm
|
||||
# Arguments: targed interface
|
||||
@@ -11,9 +11,8 @@ if [ $# -ne 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get hostname, extract noise floor. Note, all associated stations have the same value, so just grab the first one
|
||||
# Extract noise floor. Note, all associated stations have the same value, so just grab the first one
|
||||
# Use tail, not head (i.e. last line, not first), as head exits immediately, breaks the pipe to cut!
|
||||
hostname=$(/bin/uname -n)
|
||||
noise=$(/usr/bin/iwinfo "$1" assoclist | /usr/bin/cut -s -d "/" -f 2 | /usr/bin/cut -s -d "(" -f 1 | /usr/bin/cut -s -d " " -f 2 | /usr/bin/tail -1)
|
||||
|
||||
# Return snmp result
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# wlRate.sh
|
||||
# Returns wlRate, bit rate in Mbit/s
|
||||
# Arguments:
|
||||
@@ -14,17 +14,16 @@ if [ $# -ne 3 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get hostname, calculate result. Sum just for debug, and have to return integer
|
||||
# Calculate result. Sum just for debug, and have to return integer
|
||||
# => If not integer (e.g. 2.67e+07), LibreNMS will drop the exponent (result, 2.67 bits/sec!)
|
||||
hostname=$(/bin/uname -n)
|
||||
ratelist=$(/usr/sbin/iw dev "$1" station dump | /bin/grep "$2 bitrate" | /usr/bin/cut -f 2 -s -d" ")
|
||||
if [ "$3" == "sum" ]; then
|
||||
if [ "$3" = "sum" ]; then
|
||||
result=$(/bin/echo "$ratelist" | /usr/bin/awk -F ':' '{sum += $2} END {printf "%d\n", 1000000*sum}')
|
||||
elif [ "$3" == "avg" ]; then
|
||||
elif [ "$3" = "avg" ]; then
|
||||
result=$(/bin/echo "$ratelist" | /usr/bin/awk -F ':' '{sum += $2} END {printf "%d\n", 1000000*sum/NR}')
|
||||
elif [ "$3" == "min" ]; then
|
||||
elif [ "$3" = "min" ]; then
|
||||
result=$(/bin/echo "$ratelist" | /usr/bin/awk -F ':' 'NR == 1 || $2 < min {min = $2} END {printf "%d\n", 1000000*min}')
|
||||
elif [ "$3" == "max" ]; then
|
||||
elif [ "$3" = "max" ]; then
|
||||
result=$(/bin/echo "$ratelist" | /usr/bin/awk -F ':' 'NR == 1 || $2 > max {max = $2} END {printf "%d\n", 1000000*max}')
|
||||
fi
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# wlSNR.sh
|
||||
# Returns wlSNR, Signal-to-Noise ratio in dB
|
||||
# Arguments:
|
||||
@@ -13,16 +13,15 @@ if [ $# -ne 2 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get hostname, calculate result. Sum just for debug, and return integer (safest / easiest)
|
||||
hostname=$(/bin/uname -n)
|
||||
# Calculate result. Sum just for debug, and return integer (safest / easiest)
|
||||
snrlist=$(/usr/bin/iwinfo "$1" assoclist | /usr/bin/cut -s -d "/" -f 2 | /usr/bin/cut -s -d "(" -f 2 | /usr/bin/cut -s -d " " -f 2 | /usr/bin/cut -s -d ")" -f 1)
|
||||
if [ "$2" == "sum" ]; then
|
||||
if [ "$2" = "sum" ]; then
|
||||
result=$(/bin/echo "$snrlist" | /usr/bin/awk -F ':' '{sum += $1} END {printf "%d\n", sum}')
|
||||
elif [ "$2" == "avg" ]; then
|
||||
elif [ "$2" = "avg" ]; then
|
||||
result=$(/bin/echo "$snrlist" | /usr/bin/awk -F ':' '{sum += $1} END {printf "%d\n", sum/NR}')
|
||||
elif [ "$2" == "min" ]; then
|
||||
elif [ "$2" = "min" ]; then
|
||||
result=$(/bin/echo "$snrlist" | /usr/bin/awk -F ':' 'NR == 1 || $1 < min {min = $1} END {printf "%d\n", min}')
|
||||
elif [ "$2" == "max" ]; then
|
||||
elif [ "$2" = "max" ]; then
|
||||
result=$(/bin/echo "$snrlist" | /usr/bin/awk -F ':' 'NR == 1 || $1 > max {max = $1} END {printf "%d\n", max}')
|
||||
fi
|
||||
|
||||
|
@@ -12,7 +12,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
function debugecho() {
|
||||
if [ ${#Debug} -gt 0 ]; then
|
||||
echo debug: $@
|
||||
echo debug: "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ function debugecho() {
|
||||
Tmp_File=/tmp/apache_status
|
||||
|
||||
# Debug=on; use environment, i.e. Debug=on apache-stats.sh
|
||||
# shellcheck disable=SC2153
|
||||
if [ "${DEBUG}" != "" ]; then
|
||||
Debug=${DEBUG}
|
||||
else
|
||||
|
@@ -20,20 +20,20 @@ backupninja_datas = {
|
||||
if not os.path.isfile(logfile):
|
||||
error_string = "file unavailable"
|
||||
error = 1
|
||||
break
|
||||
else:
|
||||
with io.open(logfile, "r") as f:
|
||||
for line in reversed(list(f)):
|
||||
match = re.search(
|
||||
"^(.*) [a-zA-Z]*: FINISHED: ([0-9]+) actions run. ([0-9]+) fatal. ([0-9]+) error. ([0-9]+) warning.$",
|
||||
line,
|
||||
)
|
||||
if match:
|
||||
backupninja_datas["last_actions"] = int(match.group(2))
|
||||
backupninja_datas["last_fatal"] = int(match.group(3))
|
||||
backupninja_datas["last_error"] = int(match.group(4))
|
||||
backupninja_datas["last_warning"] = int(match.group(5))
|
||||
break
|
||||
|
||||
with io.open(logfile, "r") as f:
|
||||
for line in reversed(list(f)):
|
||||
match = re.search(
|
||||
"^(.*) [a-zA-Z]*: FINISHED: ([0-9]+) actions run. ([0-9]+) fatal. ([0-9]+) error. ([0-9]+) warning.$",
|
||||
line,
|
||||
)
|
||||
if match:
|
||||
backupninja_datas["last_actions"] = int(match.group(2))
|
||||
backupninja_datas["last_fatal"] = int(match.group(3))
|
||||
backupninja_datas["last_error"] = int(match.group(4))
|
||||
backupninja_datas["last_warning"] = int(match.group(5))
|
||||
break
|
||||
|
||||
output = {
|
||||
"version": version,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Based on https://github.com/Photonicsguy/CHIP
|
||||
# Based on https://github.com/Photonicsguy/CHIP
|
||||
# Enable ADC registers
|
||||
i2cset -y -f 0 0x34 0x82 0xff
|
||||
|
||||
@@ -67,7 +67,7 @@ if [ $STATUS_BATCON == 1 ]; then
|
||||
BAT_PERCENT=$(printf "%d" "$REG")
|
||||
else
|
||||
VBAT=0
|
||||
BATT_CUR=0
|
||||
#BATT_CUR=0
|
||||
BAT_PERCENT=0
|
||||
fi
|
||||
|
||||
@@ -82,6 +82,6 @@ echo $ACIN_C
|
||||
echo $VBUS
|
||||
echo $VBUS_C
|
||||
echo $VBAT
|
||||
echo $(echo "$BAT_C-$BAT_D"|bc)
|
||||
echo "$(echo "$BAT_C-$BAT_D"|bc)"
|
||||
echo $BAT_PERCENT
|
||||
echo $STATUS_CHARGING
|
||||
|
68
snmp/distro
68
snmp/distro
@@ -1,24 +1,24 @@
|
||||
#!/usr/bin/env sh
|
||||
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
|
||||
|
||||
OS=`uname -s`
|
||||
REV=`uname -r`
|
||||
MACH=`uname -m`
|
||||
OS=$(uname -s)
|
||||
REV=$(uname -r)
|
||||
#MACH=$(uname -m)
|
||||
|
||||
if [ "${OS}" = "SunOS" ] ; then
|
||||
OS=Solaris
|
||||
ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
ARCH=$(uname -p)
|
||||
OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
|
||||
|
||||
elif [ "${OS}" = "AIX" ] ; then
|
||||
OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
OSSTR="${OS} $(oslevel) ($(oslevel -r))"
|
||||
|
||||
elif [ "${OS}" = "Linux" ] ; then
|
||||
KERNEL=`uname -r`
|
||||
#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/\ .*//`
|
||||
REV=$(cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//)
|
||||
|
||||
elif [ -f /etc/redhat-release ] ; then
|
||||
DIST=$(cat /etc/redhat-release | awk '{print $1}')
|
||||
@@ -29,8 +29,8 @@ elif [ "${OS}" = "Linux" ] ; then
|
||||
DIST="CloudLinux"
|
||||
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/\ .*//`
|
||||
#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"
|
||||
elif [ -f /etc/rockstor-release ]; then
|
||||
@@ -39,39 +39,39 @@ elif [ "${OS}" = "Linux" ] ; then
|
||||
DIST="RedHat"
|
||||
fi
|
||||
|
||||
PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
|
||||
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
#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/\ .*//`
|
||||
#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`"
|
||||
DIST="Devuan $(cat /etc/devuan_version)"
|
||||
REV=""
|
||||
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
DIST="Debian `cat /etc/debian_version`"
|
||||
DIST="Debian $(cat /etc/debian_version)"
|
||||
REV=""
|
||||
IGNORE_OS_RELEASE=1
|
||||
if [ -f /usr/bin/lsb_release ] ; then
|
||||
ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g'`
|
||||
ID=$(lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g')
|
||||
fi
|
||||
if [ "${ID}" = "Raspbian" ] ; then
|
||||
DIST="Raspbian `cat /etc/debian_version`"
|
||||
DIST="Raspbian $(cat /etc/debian_version)"
|
||||
fi
|
||||
if [ -f /usr/bin/pveversion ]; then
|
||||
DIST="${DIST}/PVE `/usr/bin/pveversion | cut -d '/' -f 2`"
|
||||
DIST="${DIST}/PVE $(/usr/bin/pveversion | cut -d '/' -f 2)"
|
||||
fi
|
||||
if [ -f /usr/bin/pmgversion ]; then
|
||||
# pmgversion requires root permissions to run, please add NOPASSWD setting to visudo.
|
||||
DIST="${DIST}/PMG `sudo /usr/bin/pmgversion | cut -d '/' -f 2`"
|
||||
DIST="${DIST}/PMG $(sudo /usr/bin/pmgversion | cut -d '/' -f 2)"
|
||||
fi
|
||||
if [ -f /etc/dogtag ]; then
|
||||
DIST=`cat /etc/dogtag`
|
||||
DIST=$(cat /etc/dogtag)
|
||||
fi
|
||||
|
||||
|
||||
elif [ -f /etc/gentoo-release ] ; then
|
||||
DIST="Gentoo"
|
||||
REV=$(tr -d '[[:alpha:]]' </etc/gentoo-release | tr -d " ")
|
||||
@@ -80,7 +80,7 @@ elif [ "${OS}" = "Linux" ] ; then
|
||||
DIST="Arch Linux"
|
||||
REV="" # Omit version since Arch Linux uses rolling releases
|
||||
IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling"
|
||||
|
||||
|
||||
elif [ -f /etc/photon-release ] ; then
|
||||
DIST=$(head -1 < /etc/photon-release)
|
||||
REV=$(sed -n -e 's/^.*PHOTON_BUILD_NUMBER=//p' /etc/photon-release)
|
||||
@@ -95,26 +95,26 @@ elif [ "${OS}" = "Linux" ] ; then
|
||||
REV=""
|
||||
|
||||
elif [ -f /etc/SuSE-release ] ; then
|
||||
DIST=$(echo SLES $(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
||||
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
|
||||
DIST=$(echo SLES "$(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " ")")
|
||||
REV=$(echo SP"$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " ")")
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v awk)" ]; then # some distros do not ship with awk
|
||||
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
|
||||
if [ "$(uname -a | awk '{print $(NF)}')" = "DD-WRT" ] ; then
|
||||
DIST="dd-wrt"
|
||||
fi
|
||||
if [ "`uname -a | awk '{print $(NF)}'`" = "ASUSWRT-Merlin" ] ; then
|
||||
if [ "$(uname -a | awk '{print $(NF)}')" = "ASUSWRT-Merlin" ] ; then
|
||||
DIST="ASUSWRT-Merlin"
|
||||
REV=`nvram show | grep buildno= | egrep -o '[0-9].[0-9].[0-9]'` > /dev/null 2>&1
|
||||
REV=$(nvram show | grep buildno= | egrep -o '[0-9].[0-9].[0-9]') > /dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
# try standardized os version methods
|
||||
if [ -f /etc/os-release -a "${IGNORE_OS_RELEASE}" != 1 ] ; then
|
||||
if [ -f /etc/os-release ] && [ "${IGNORE_OS_RELEASE}" != 1 ] ; then
|
||||
. /etc/os-release
|
||||
STD_DIST="$NAME"
|
||||
STD_REV="$VERSION_ID"
|
||||
elif [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
|
||||
elif [ -f /etc/lsb-release ] && [ "${IGNORE_LSB}" != 1 ] ; then
|
||||
STD_DIST=$(lsb_release -si)
|
||||
STD_REV=$(lsb_release -sr)
|
||||
fi
|
||||
@@ -133,18 +133,18 @@ elif [ "${OS}" = "Linux" ] ; then
|
||||
|
||||
elif [ "${OS}" = "Darwin" ] ; then
|
||||
if [ -f /usr/bin/sw_vers ] ; then
|
||||
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
|
||||
OSSTR=$(/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' ')
|
||||
fi
|
||||
|
||||
elif [ "${OS}" = "FreeBSD" ] ; then
|
||||
if [ -f /etc/version ] ; then
|
||||
DIST=$(cat /etc/version | cut -d'-' -f 1)
|
||||
if [ "${DIST}" = "FreeNAS" ]; then
|
||||
OSSTR=`cat /etc/version | cut -d' ' -f 1`
|
||||
OSSTR=$(cat /etc/version | cut -d' ' -f 1)
|
||||
fi
|
||||
else
|
||||
OSSTR=`/usr/bin/uname -mior`
|
||||
OSSTR=$(/usr/bin/uname -mior)
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ${OSSTR}
|
||||
echo "${OSSTR}"
|
||||
|
@@ -11,6 +11,7 @@ RADIUS_PORT='18121'
|
||||
RADIUS_KEY='adminsecret'
|
||||
|
||||
if [ -f $CONFIGFILE ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. $CONFIGFILE
|
||||
fi
|
||||
|
||||
@@ -27,44 +28,44 @@ fi
|
||||
|
||||
RESULT=$(echo "$RADIUS_STATUS_CMD" | $BIN_RADCLIENT -x $RADIUS_SERVER:$RADIUS_PORT status $RADIUS_KEY)
|
||||
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Access-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Access-Accepts = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Access-Rejects = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Access-Challenges = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Auth-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Accounting-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Accounting-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Acct-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Acct-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Acct-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Acct-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Acct-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Access-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Access-Accepts = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Access-Rejects = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Access-Challenges = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Auth-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Accounting-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Accounting-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Acct-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Acct-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Acct-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Acct-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Total-Proxy-Acct-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-Len-Internal = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-Len-Proxy = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-Len-Auth = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-Len-Acct = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-Len-Detail = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-PPS-In = [[:digit:]]*'
|
||||
echo "$RESULT" | grep -o 'FreeRADIUS-Queue-PPS-Out = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Access-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Access-Accepts = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Access-Rejects = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Access-Challenges = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Auth-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Accounting-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Accounting-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Acct-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Acct-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Acct-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Acct-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Acct-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Access-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Access-Accepts = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Access-Rejects = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Access-Challenges = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Auth-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Accounting-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Accounting-Responses = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Acct-Duplicate-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Acct-Malformed-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Acct-Invalid-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Acct-Dropped-Requests = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Total-Proxy-Acct-Unknown-Types = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-Len-Internal = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-Len-Proxy = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-Len-Auth = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-Len-Acct = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-Len-Detail = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-PPS-In = [[:digit:]]*'
|
||||
echo "$RESULT" | $BIN_GREP -o 'FreeRADIUS-Queue-PPS-Out = [[:digit:]]*'
|
||||
|
@@ -18,12 +18,13 @@ BIN_PYTHON='/usr/bin/env python'
|
||||
# Check for config file
|
||||
CONFIG=$0".conf"
|
||||
if [ -f "$CONFIG" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$CONFIG"
|
||||
fi
|
||||
|
||||
# Create Temp File
|
||||
TMPFILE=$(mktemp)
|
||||
trap "rm -f $TMPFILE" 0 2 3 15
|
||||
trap 'rm -f $TMPFILE' 0 2 3 15
|
||||
|
||||
# Write GPSPIPE Data to Temp File
|
||||
$BIN_GPIPE -w -n 20 > "$TMPFILE"
|
||||
|
@@ -5,7 +5,7 @@ used_memory=$(ps -U icecast -o rsz | awk 'FNR==2{print}')
|
||||
cpu_load=$(ps -U icecast -o %cpu | awk 'FNR==2{print}')
|
||||
|
||||
pid=$(pidof icecast)
|
||||
total_files=$(ls -l /proc/"${pid}"/fd | wc -l)
|
||||
total_files=$(find /proc/"${pid}"/fd | wc -l)
|
||||
|
||||
echo "Used Memory=""$used_memory"
|
||||
echo "CPU Load=""$cpu_load"
|
||||
|
@@ -7,7 +7,8 @@ REALPATH=/usr/bin/realpath
|
||||
|
||||
CONFIGFILE=/etc/snmp/mdadm.conf
|
||||
if [ -f $CONFIGFILE ] ; then
|
||||
. $CONFIGFILE
|
||||
# shellcheck disable=SC1090
|
||||
. $CONFIGFILE
|
||||
fi
|
||||
|
||||
VERSION=1
|
||||
@@ -19,7 +20,7 @@ OUTPUT_DATA='['
|
||||
# use 'ls' command to check if md blocks exist
|
||||
if $LS /dev/md?* 1> /dev/null 2>&1 ; then
|
||||
for ARRAY_BLOCKDEVICE in $($LS -1 /dev/md?*) ; do
|
||||
RAID="/sys/block/"$($BASENAME $($REALPATH "$ARRAY_BLOCKDEVICE"))
|
||||
RAID="/sys/block/"$($BASENAME "$($REALPATH "$ARRAY_BLOCKDEVICE")")
|
||||
|
||||
# ignore arrays with no slaves
|
||||
if [ -z "$($LS -1 "$RAID"/slaves 2> /dev/null)" ] ; then
|
||||
|
@@ -13,13 +13,12 @@
|
||||
# Don't change anything unless you know what are you doing #
|
||||
################################################################
|
||||
BIN_NTPQ='/usr/bin/env ntpq'
|
||||
BIN_NTPD='/usr/bin/env ntpd'
|
||||
BIN_GREP='/usr/bin/env grep'
|
||||
BIN_AWK='/usr/bin/env awk'
|
||||
BIN_HEAD='/usr/bin/env head'
|
||||
|
||||
CONFIG=$0".conf"
|
||||
if [ -f "$CONFIG" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$CONFIG"
|
||||
fi
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# Alternatively you can put them in $0.conf, meaning if you've named
|
||||
# this script ntp-client.sh then it must go in ntp-client.sh.conf .
|
||||
#
|
||||
# NTPQV output version of "ntpq -c rv"
|
||||
# NTPQV output version of "ntpq -c rv"
|
||||
# p1 DD-WRT and some other outdated linux distros
|
||||
# p11 FreeBSD 11 and any linux distro that is up to date
|
||||
#
|
||||
@@ -16,7 +16,8 @@ CONFIGFILE=/etc/snmp/ntp-server.conf
|
||||
BIN_ENV='/usr/bin/env'
|
||||
|
||||
if [ -f $CONFIGFILE ] ; then
|
||||
. $CONFIGFILE
|
||||
# shellcheck disable=SC1090
|
||||
. $CONFIGFILE
|
||||
fi
|
||||
|
||||
BIN_NTPD="$BIN_ENV ntpd"
|
||||
@@ -34,7 +35,8 @@ NTPQV="p11"
|
||||
################################################################
|
||||
CONFIG=$0".conf"
|
||||
if [ -f "$CONFIG" ]; then
|
||||
. "$CONFIG"
|
||||
# shellcheck disable=SC1090
|
||||
. "$CONFIG"
|
||||
fi
|
||||
VERSION=1
|
||||
|
||||
@@ -75,7 +77,7 @@ IGNOREDPACKETS=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $7}')
|
||||
RECEIVEDPACKETS=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $8}')
|
||||
PACKETSSENT=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $9}')
|
||||
PACKETSENDFAILURES=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $10}')
|
||||
INPUTWAKEUPS=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $11}')
|
||||
#INPUTWAKEUPS=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $11}')
|
||||
USEFULINPUTWAKEUPS=$(echo "$CMD2" | $BIN_AWK -F ' ' '{print $12}')
|
||||
|
||||
echo '{"data":{"offset":"'"$OFFSET"\
|
||||
|
@@ -52,13 +52,13 @@ opts=""
|
||||
# Contributed by @safeie with PR #276
|
||||
# Modified to work as a SNMP extend by Zane C. Bowers-Hadley
|
||||
|
||||
declare -A phpfpm_urls=()
|
||||
declare -A phpfpm_curl_opts=()
|
||||
#declare -A phpfpm_urls=()
|
||||
#declare -A phpfpm_curl_opts=()
|
||||
|
||||
# _update_every is a special variable - it holds the number of seconds
|
||||
# between the calls of the _update() function
|
||||
phpfpm_update_every=
|
||||
phpfpm_priority=60000
|
||||
#phpfpm_update_every=
|
||||
#phpfpm_priority=60000
|
||||
|
||||
declare -a phpfpm_response=()
|
||||
phpfpm_pool=""
|
||||
@@ -78,8 +78,8 @@ phpfpm_slow_requests=0
|
||||
|
||||
# local opts="${1}" url="${2}"
|
||||
|
||||
phpfpm_response=($(curl -Ss "${opts}" "${url}"))
|
||||
[ $? -ne 0 -o "${#phpfpm_response[@]}" -eq 0 ] && exit 1
|
||||
phpfpm_response=("$(curl -Ss "${opts}" "${url}")")
|
||||
[ $? -ne 0 ] || [ "${#phpfpm_response[@]}" -eq 0 ] && exit 1
|
||||
|
||||
if [[ "${phpfpm_response[0]}" != "pool:" \
|
||||
|| "${phpfpm_response[2]}" != "process" \
|
||||
|
@@ -12,11 +12,13 @@ PICONFIGFILE='/etc/pihole/setupVars.conf'
|
||||
DHCPLEASEFILE='/etc/pihole/dhcp.leases'
|
||||
|
||||
if [ -f $CONFIGFILE ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. $CONFIGFILE
|
||||
fi
|
||||
|
||||
# read in pi-hole variables for DHCP range
|
||||
if [ -f $PICONFIGFILE ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. $PICONFIGFILE
|
||||
fi
|
||||
|
||||
@@ -74,7 +76,7 @@ debug() {
|
||||
fi
|
||||
if [ -f $PICONFIGFILE ]; then
|
||||
echo '[ok] Pi-Hole config file exists, DHCP stats will be captured if scope active'
|
||||
else
|
||||
else
|
||||
echo '[error] Pi-Hole config file does not exist, DHCP stats will not be captured if used'
|
||||
fi
|
||||
if [ -f $DHCPLEASEFILE ]; then
|
||||
|
@@ -98,7 +98,7 @@ usage = (
|
||||
+ " [-v|--verbose] [-w|--warnings] | -l|--list-methods | -h|--help"
|
||||
)
|
||||
methods = ["sensors", "hpasmcli"]
|
||||
# costPerkWh = 0.15 # <<<< UNCOMMENT
|
||||
# costPerkWh = 0.15 # <<<< CHANGE
|
||||
|
||||
### General functions
|
||||
|
||||
@@ -352,7 +352,7 @@ except NameError:
|
||||
# Get data
|
||||
data = getData(method)
|
||||
data["supply"] = {}
|
||||
data["supply"]["rate"] = costPerkWh
|
||||
data["supply"]["rate"] = costPerkWh # pylint: disable=E0602
|
||||
|
||||
# Top-level reading
|
||||
# CUSTOMISE THIS FOR YOUR HOST
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
function get_data($host, $port)
|
||||
{
|
||||
$rawdata = null;
|
||||
$fp = @fsockopen($host, $port, $errno, $errstr, 5);
|
||||
if (!$fp) {
|
||||
$connect = 0;
|
||||
|
@@ -5,7 +5,7 @@ used_memory=$(ps -C voipmonitor -o rsz | awk 'FNR==2 {print}')
|
||||
cpu_load=$(ps -C voipmonitor -o %cpu | awk 'FNR==2 {print}')
|
||||
|
||||
pid=$(pidof voipmonitor)
|
||||
total_files=$(ls -l /proc/"${pid}"/fd | wc -l)
|
||||
total_files=$(find /proc/"${pid}"/fd | wc -l)
|
||||
|
||||
echo "Used Memory=""$used_memory"
|
||||
echo "CPU Load=""$cpu_load"
|
||||
|
Reference in New Issue
Block a user