Code backup
This commit is contained in:
2026-05-10 16:59:01 +02:00
commit 368d6fafea
796 changed files with 315310 additions and 0 deletions
@@ -0,0 +1,110 @@
#!/bin/bash
# - VAR
# - Bash info
APPNAME=$(basename $0)
NAME="Check SpectraLink"
AUTHOR="Kalarumeth"
VERSION="v0.1"
URL="https://github.com/Kalarumeth"
# - Default settings for connection
COMMUNITY="public"
HOST_NAME="localhost"
SNMPVERSION="2c"
# - State Variables
STATE_OK=0
STATE_WARN=1
STATE_CRIT=2
STATE_UNK=3
STATE=$STATE_OK
# - OID
SL.OIDS() {
OID_pUptime="1.3.6.1.2.1.1.3.0" #String The uptime of SL.
}
# - MAIN CODE
Script.HostAlive() {
for server in $HOST_NAME; do
ping -c1 -W1 -q $server &>/dev/null
if [[ $? != 0 ]] ; then
printf "%s\n" "$server is unreachable"
exit $STATE_UNK
fi
done
}
Script.SNMP() {
snmpwalk -v $SNMPVERSION -c $COMMUNITY -r 1 -t 10 -Oev $HOST_NAME $1
}
SL.Main() {
Script.HostAlive
case $1 in
uptime)
SL.UpTime
exit $STATE ;;
*)
echo "Unknown check!"
Help.SL
exit $STATE_UNK ;;
esac
}
SL.GetData() {
SL.OIDS
case $1 in
uptime)
sysUptimeIstance=$(Script.SNMP $OID_pUptime | cut -d ')' -f 2 )
;;
esac
}
# Device Information
SL.UpTime() {
SL.GetData uptime
printf "%s\n" "UpTime: $sysUptimeIstance"
}
# - HELP
Help.Main(){
printf "%s\n" "OPTIONS:"
printf "%s\t%s\t\t%s\n\t\t\t%s\n" "-t" "--type" "[REQUIRED OPTION] Field for select element to check." " { uptime } "
}
# - COMMAND LINE ENCODER
while test -n "$1"; do
case "$1" in
--host | -h)
HOST_NAME=$2
shift ;;
--community | -c)
COMMUNITY=$2
shift ;;
--type | -t)
SL.Main $2
shift ;;
--help | -H)
Help.Main ;;
--version | -V)
Help.Info
exit $STATE ;;
*)
echo "Unknown argument: $1"
print_help
exit $STATE_UNK ;;
esac
shift
done
SL.Main