Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
mirrors
resmon
Commits
fac6e235
Commit
fac6e235
authored
11 years ago
by
Clinton Wolfe
Browse files
Options
Downloads
Patches
Plain Diff
net utilization module
parent
a9944b27
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Core/NetUtilization.pm
+98
-0
98 additions, 0 deletions
lib/Core/NetUtilization.pm
with
98 additions
and
0 deletions
lib/Core/NetUtilization.pm
0 → 100644
+
98
−
0
View file @
fac6e235
package
Core::
NetUtilization
;
use
strict
;
use
warnings
;
use
base
'
Resmon::Module
';
use
Resmon::
ExtComm
qw(run_command cache_command)
;
=pod
=head1 NAME
Core::NetUtilization - get interface in/out byte counts
=head1 SYNOPSIS
Core::NetUtilization {
local: noop
}
=head1 DESCRIPTION
Each instance is the name of a network interface (vnic under solaris).
On linux, uses ifconfig to list interfaces and obtain byte in/out counts.
On solaris, uses kstat.
=head1 CONFIGURATION
None.
=head1 METRICS
=over
=item in_bytes
64-bit Integer, number of inbound bytes
=item out_bytes
64-bit Integer, number of outbound bytes
=back
=cut
sub
handler
{
my
$self
=
shift
;
my
$config
=
$self
->
{
config
};
# All configuration is in here
my
$check_name
=
$self
->
{
check_name
};
# The check name is in here
my
$results
;
if
(
$^O
eq
'
solaris
')
{
my
$output
=
run_command
('
kstat -p ::mac_[tr]x_swlane0:[or]bytes
');
chomp
$output
;
# global0:0:mac_rx_swlane0:rbytes 5858602050
# global0:0:mac_tx_swlane0:obytes 275810267256
# omnibuildil10:0:mac_rx_swlane0:rbytes 340562
# omnibuildil10:0:mac_tx_swlane0:obytes 0
foreach
my
$line
(
split
("
\n
",
$output
))
{
next
unless
$line
;
my
(
$key
,
$val
)
=
split
(
/\s+/
,
$line
);
next
unless
$key
;
my
(
$vnic
,
$dum1
,
$direction
,
$dum2
)
=
split
('
:
',
$key
);
next
unless
$vnic
;
$results
->
{
$vnic
.
'
_
'
.
(
$direction
eq
'
mac_rx_swlane0
'
?
'
in
'
:
'
out
'
)
.
'
_bytes64
'}
=
[
$val
,
'
l
'];
}
}
else
{
# Everything else is obviously linux, right?
my
$output
=
run_command
('
/sbin/ifconfig -a
');
chomp
$output
;
my
$iface
;
foreach
my
$line
(
split
("
\n
",
$output
))
{
next
unless
$line
;
my
(
$name
,
$rest
)
=
$line
=~
/^(\S+)\s+Link encap:(\S+)/
;
if
(
$name
)
{
$iface
=
$name
;
next
;
}
# RX bytes:114925052 (109.6 MiB) TX bytes:5398728 (5.1 MiB)
my
(
$in_bytes
,
$out_bytes
)
=
$line
=~
/^\s+RX bytes:(\d+).+TX bytes:(\d+).+/
;
next
unless
defined
$in_bytes
;
$results
->
{
$iface
.
'
_in_bytes64
'}
=
[
$in_bytes
,
'
l
'];
$results
->
{
$iface
.
'
_out_bytes64
'}
=
[
$out_bytes
,
'
l
'];
}
}
return
$results
;
};
1
;
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