Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
JR Dalrymple
/
pf_interface_usage
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a8afec84
authored
Nov 01, 2015
by
JR Dalrymple
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test the interface list
parent
6ad4bf47
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
check_snmp_usage.sh
+29
-18
No files found.
check_snmp_usage.sh
View file @
a8afec84
...
@@ -7,8 +7,18 @@ interfaceTableOID="IF-MIB::ifDescr"
...
@@ -7,8 +7,18 @@ interfaceTableOID="IF-MIB::ifDescr"
interfaceInBytesOID
=
"IF-MIB::ifInOctets"
interfaceInBytesOID
=
"IF-MIB::ifInOctets"
interfaceOutBytesOID
=
"IF-MIB::ifOutOctets"
interfaceOutBytesOID
=
"IF-MIB::ifOutOctets"
snmpget
=
`
which snmpget
`
snmpwalk
=
`
which snmpwalk
`
status
=
""
status
=
""
usage
()
{
echo
" Usage:
$0
-i interface -l limit"
echo
"
$0
-h (shows this message)"
echo
"Replace <interface> with the interface you want to monitor"
echo
"Replace <limit> with your monthly badwidth allotment measured in bytes"
}
nagiosExit
()
{
nagiosExit
()
{
echo
$2
echo
$2
...
@@ -27,30 +37,31 @@ fi
...
@@ -27,30 +37,31 @@ fi
# GET ARGS
# GET ARGS
while
getopts
r:i:w
:h o
while
getopts
H:i:l
:h o
do case
"
$o
"
in
do case
"
$o
"
in
r
)
resetdate
=
"
$OPTARG
"
;;
H
)
host
=
"
$OPTARG
"
;;
i
)
interface
=
"
$OPTARG
"
;;
i
)
interface
=
"
$OPTARG
"
;;
w
)
warning
=
"
$OPTARG
"
;;
l
)
limit
=
"
$OPTARG
"
;;
h
)
print
>
&2
" Usage:
$0
-r date -i interface [-w warning threshold]"
\
h
)
usage
"
\n\t
$0
-h (shows this message)"
\
nagiosExit UNKNOWN
" "
;;
"
\n\n\t
date should be the time you want the counters to reset"
\
"
\n\t
it will use the format <m|d>[dd]HHMM"
\
"
\n\t
so if you want to reset at the start of the month use m010000"
\
"
\n\t
or if you want to reset daily at 3:00 AM use d0300"
\
"
\n\t
warning threshold is optional and measured in bytes."
exit
1
;;
esac
esac
done
done
shift
$OPTIND
-1
shift
$OPTIND
-1
period
=
"
$(
echo
"
$resetdate
"
| cut
-c1
)
"
case
"
$period
"
in
m
|
M
)
monthlogic
;;
d
|
D
)
daylogic
;;
*
)
status
=
"You didn't specify a valid date"
nagiosExit UNKNOWN
"
$status
"
;;
esac
# Grab the list of interfaces from the host and figure out
# the index of the array we're interested in
walk
=
"
$snmpwalk
-v2c -c public
$host
$interfaceTableOID
"
echo
$walk
i
=
0
$walk
|
while
read
line
do
interfaceList[
$i
]=
"
$line
"
((
i++
))
done
echo
${
interfaceList
[@]
}
nagiosExit
"OK"
"Wowsers, I have don't anything"
nagiosExit
"OK"
"Wowsers, I have don't anything"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment