Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
b528add1
Commit
b528add1
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
netio: small fixes
parent
fdeea247
No related branches found
No related tags found
1 merge request
!134
netio: small fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_netio
+39
-39
39 additions, 39 deletions
check_netio
with
39 additions
and
39 deletions
check_netio
+
39
−
39
View file @
b528add1
...
...
@@ -7,12 +7,13 @@
# ----------------------------------------------------------------------
# 2020-07-08 v1.0 <axel.hahn@iml.unibe.ch>
# 2023-08-21 v1.1 <axel.hahn@unibe.ch> add help; add param -i
# 2023-08-22 v1.2 <axel.hahn@unibe.ch> send perf data on single interface too; interfaces in alphabetic order; no more tmp file
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
1.
1
export
self_APPVERSION
=
1.
2
# ----------------------------------------------------------------------
...
...
@@ -62,8 +63,6 @@ if [ $bOptHelp -eq 1 ]; then
exit
0
fi
tmpfile2
=
`
mktemp
`
typeset
-i
iCountInterfaces
typeset
-i
iRead
=
0
...
...
@@ -76,60 +75,61 @@ typeset -i iTotalTrans=0
data
=
$(
cat
/proc/net/dev |
grep
-E
"(eth|en[ops][0-9]*)"
)
allInterfaces
=
$(
cut
-f
1
-d
":"
<<<
"
$data
"
|
tr
-d
" "
)
sInterface
=
$(
ph.getValueWithParam
"
$allInterfaces
"
"i"
"
$@
"
)
sInterface
=
$(
ph.getValueWithParam
"
$allInterfaces
"
"i"
"
$@
"
|
sort
)
# ----- loop over all interfaces
iCountInterfaces
=
$(
wc
-w
<<<
"
$sInterface
"
)
for
myinterface
in
$sInterface
do
echo
>>
"
$tmpfile2
"
echo
"---
${
myinterface
}
:"
>>
"
$tmpfile2
"
line
=
$(
grep
"
${
myinterface
}
:"
<<<
"
$data
"
)
if
[
-n
"
$line
"
]
;
then
out
=
$(
for
myinterface
in
$sInterface
do
echo
echo
"---
${
myinterface
}
:"
line
=
$(
grep
"
${
myinterface
}
:"
<<<
"
$data
"
)
if
[
-n
"
$line
"
]
;
then
# echo "SOURCE: $line"
>> $tmpfile2
# echo "SOURCE: $line"
# total value of byte
iRead
=
$(
echo
"
$line
"
|
awk
'{ print $2 }'
)
iTrans
=
$(
echo
"
$line
"
|
awk
'{ print $10 }'
)
# total value of byte
iRead
=
$(
echo
"
$line
"
|
awk
'{ print $2 }'
)
iTrans
=
$(
echo
"
$line
"
|
awk
'{ print $10 }'
)
# speed in byte per sec based on last stored value and its age
iSpeedRead
=
$(
ph.perfdeltaspeed
"netio-
${
myinterface
}
-rx"
$iRead
)
iSpeedTrans
=
$(
ph.perfdeltaspeed
"netio-
${
myinterface
}
-tx"
$iTrans
)
# speed in byte per sec based on last stored value and its age
iSpeedRead
=
$(
ph.perfdeltaspeed
"netio-
${
myinterface
}
-rx"
$iRead
)
iSpeedTrans
=
$(
ph.perfdeltaspeed
"netio-
${
myinterface
}
-tx"
$iTrans
)
printf
"%15s %15s %10s %-10s
\n
"
"receive:"
$iRead
$iSpeedRead
"byte/s"
>>
"
$tmpfile2
"
printf
"%15s %15s %10s %-10s
\n
"
"transmit:"
$iTrans
$iSpeedTrans
"byte/s"
>>
"
$tmpfile2
"
printf
"%15s %15s %10s %-10s
\n
"
"receive:"
$iRead
$iSpeedRead
"byte/s"
printf
"%15s %15s %10s %-10s
\n
"
"transmit:"
$iTrans
$iSpeedTrans
"byte/s"
# to store data for each interface
if
[
$iCountInterfaces
-gt
1
]
;
then
ph.perfadd
"rx-
${
myinterface
}
"
"
$iSpeedRead
"
ph.perfadd
"tx-
${
myinterface
}
"
"
$iSpeedTrans
"
fi
iTotalRead
=
$iTotalRead
+
$iSpeedRead
iTotalTrans
=
$iTotalTrans
+
$iSpeedTrans
else
ph.setStatus
"unknown"
echo
"UNKNOWN: the interface
${
myinterface
}
does not exist."
>>
"
$tmpfile2
"
fi
done
iTotalRead
=
$iTotalRead
+
$iSpeedRead
iTotalTrans
=
$iTotalTrans
+
$iSpeedTrans
else
ph.setStatus
"unknown"
echo
"The interface [
${
myinterface
}
] does not exist."
fi
echo
""
>>
"
$tmpfile2
"
done
echo
)
# ----- total
if
[
$iCountInterfaces
-gt
1
]
;
then
echo
"--- total:"
printf
"%15s %10s %-10s
\n
"
"receive:"
$iTotalRead
"byte/s"
printf
"%15s %10s %-10s
\n
"
"transmit:"
$iTotalTrans
"byte/s"
fi
>>
"
$tmpfile2
"
out+
=
$(
echo
"--- total:"
printf
"%15s %10s %-10s
\n
"
"receive:"
$iTotalRead
"byte/s"
printf
"%15s %10s %-10s
\n
"
"transmit:"
$iTotalTrans
"byte/s"
)
fi
ph.perfadd
"rx"
"
$iTotalRead
"
ph.perfadd
"tx"
"
$iTotalTrans
"
# ----- output
ph.status
"Network IO ... IN
$(
ph.toUnit
$iTotalRead
M
)
MB/s >> [host] >>
$(
ph.toUnit
$iTotalTrans
M
)
MB/s OUT"
cat
"
$tmpfile2
"
rm
-f
"
$tmpfile2
"
echo
"
$out
"
ph.exit
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment