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,100 @@
#!/bin/bash
# - VAR
# - Bash info
APPNAME=$(basename $0)
NAME="Check MGE Galaxy ups"
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
MGE.OIDS() {
OID_sysInfo="1.3.6.1.2.1.1.1.0"
OID_curTemp="1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1"
OID_=""
}
# - 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
}
MGE.Main() {
Script.HostAlive
MGE.GetData
exit $STATE
}
MGE.GetData() {
MGE.OIDS
sysInfo=$(Script.SNMP $OID_sysInfo | cut -d ' ' -f 2 )
curTemp=$(Script.SNMP $OID_curTemp | cut -d ' ' -f 2 )
}
# Device Information
# MGE.UpTime() {
# MGE.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 ;;
--help | -H)
Help.Main ;;
--version | -V)
Help.Info
exit $STATE ;;
*)
echo "Unknown argument: $1"
print_help
exit $STATE_UNK ;;
esac
shift
done
MGE.Main