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
+125
View File
@@ -0,0 +1,125 @@
#!/bin/bash
# startup checks
if [ -z "$BASH" ]; then
echo "Please use BASH."
exit 3
fi
if [ ! -e "/usr/bin/which" ]; then
echo "/usr/bin/which is missing."
exit 3
fi
snmp=$(which snmpwalk)
if [ $? -ne 0 ]; then
echo "Please install snmpwalk"
exit 3
fi
# Default Values
community="pal-ro"
version="2"
more=""
# State Variables
STATE_OK=0
STATE_WARN=1
STATE_CRIT=2
STATE_UNK=3
# Default Outputs
STATE=$STATE_OK
STATE_STRING=""
PERFDATA=""
# Usage Info
usage() {
echo '''
Usage: check_snmp [OPTIONS]
[OPTIONS]
-p PORT Port to send the snmp request to (default: 161)
-N COMMUNITY SNMP community name (default: public)
-H HOST Hostname to send SNMP queries to
-o OID SNMP OID to query
-V VERSION SNMP Version (default: 2)
-M MORE When using -V 3, pass all required snmpwalk parameters
with -M, i.E. "-u user -a MD5 -A 72d0815....D38 -x AES"
-w WARNING Defines limit for WARNING
-c CRITICAL Defines limit for CRITICAL
'''
}
#main
#get options
while getopts "p:N:H:o:V:M:W:C:w:c:" opt; do
case $opt in
port=$OPTARG
;;
N)
community=$OPTARG
;;
H)
host=$OPTARG
;;
o)
oid=$OPTARG
;;
V)
version=$OPTARG
;;
M)
more=$OPTARG
;;
w)
warning=$OPTARG
;;
c)
critical=$OPTARG
;;
*)
usage
exit 3
;;
esac
done
#required paramters
if [ -z "$host" ]; then
echo "Error: host is required"
usage
exit 3
fi
if [ -z "$oid" ]; then
echo "Error: oid is required"
usage
exit 3
fi
if ! [[ "$version" =~ ^[0-9]+$ ]]; then
echo "Error: -V must be 1 , 2 or 3"
usage
exit 3
fi
if [ $version -lt 1 ] || [ $version -gt 3 ]; then
echo "Error: -V must be 1 , 2 or 3"
usage
exit 3
fi
oversion=$version
if [ $version -eq 2 ];then
version="-v2c"
elif [ $version -eq 1 ]; then
version="-v1"
fi
if [ $oversion -eq 3 ] ; then
rtr=$(snmpwalk $version -c $community $host $oid)
fi
status=$?
rtr=$(echo $rtr | cut -d " " -f 4)
echo "Value is: $rtr"
exit 0
+98
View File
@@ -0,0 +1,98 @@
// -*- mode: icinga -*-
// Template -
template Host "WG" {
address = "172.16.254.240"
check_command = "hostalive"
}
template Service "snmpv2c"{
check_command = "check-snmp"
vars.csnmp_community = "pal-ro"
vars.csnmp_version = "2"
}
// - CheckCommand -
object CheckCommand "check-snmp" {
command = [ ConfigDir + "/scripts/check_snmp.sh" ]
arguments += {
"-H" = {
required = true
value = "$host.address$"
}
"-o" = {
required = true
value = "$csnmp_oid$"
}
"-w" = "$csnmp_warning$"
"-c" = "$csnmp_critical$"
"-p" = "$csnmp_port$"
"-N" = "$csnmp_community$"
"-V" = "$csnmp_version$"
}
}
// - Host -
object Host "WatchGuard" {
import "WG"
}
// - Basic Service -
object Service "ping4" {
display_name = "Ping4"
host_name = "WatchGuard"
check_command = "ping4"
}
object Service "http" {
display_name = "Http"
host_name = "WatchGuard"
check_command = "http"
}
// - SNMPWALK -
object Service "wgSystemTotalSendBytes" {
import "snmpv2c"
display_name = "Total Send Bytes"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.8"
}
object Service "wgSystemTotalRecvBytes" {
import "snmpv2c"
display_name = "Total Recive Bytes"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.9"
}
object Service "wgSystemTotalSendPackets" {
import "snmpv2c"
display_name = "Total Send Packets"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.10"
}
object Service "wgSystemTotalRecvPackets" {
import "snmpv2c"
display_name = "Total Recive Packets"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.11"
}
object Service "wgSystemCpuUtil1" {
import "snmpv2c"
display_name = "Cpu Util"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.77"
}
object Service "wgSystemCurrActiveConns" {
import "snmpv2c"
display_name = "Current Active Connections"
host_name = "WatchGuard"
vars.csnmp_oid = "1.3.6.1.4.1.3097.6.3.80"
}