Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuriy
opentrafficshaper
Commits
02d15cfb
Commit
02d15cfb
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up SID (stats ID) functions
parent
033cb56b
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
opentrafficshaper/plugins/statistics/statistics.pm
+82
-24
82 additions, 24 deletions
opentrafficshaper/plugins/statistics/statistics.pm
with
82 additions
and
24 deletions
opentrafficshaper/plugins/statistics/statistics.pm
+
82
−
24
View file @
02d15cfb
...
...
@@ -639,55 +639,55 @@ sub getLastStats
}
# Return stats b
ased on a L
ID
sub
getStatsBy
L
ID
# Return stats b
y S
ID
sub
getStatsBy
S
ID
{
my
$
l
id
=
shift
;
my
$
s
id
=
shift
;
return
_getStatsBySID
(
$sid
);
}
# Max entries
my
$entriesLeft
=
100
;
# Grab stats ID from LID
my
$sid
=
getSIDFromLID
(
$lid
);
if
(
!
defined
(
$sid
))
{
return
{
};
}
# Return basic stats by SID
sub
getStatsBasicBySID
{
my
$sid
=
shift
;
return
_getStatsBySID
(
$sid
);
return
_getStatsB
asicB
ySID
(
$sid
);
}
#
R
et
urn
stats
based on an interface
sub
getS
tatsByClass
#
G
et
the
stats
ID from Class ID
sub
getS
IDFromCID
{
my
(
$iface
,
$cid
)
=
@_
;
# Grab stats ID from LID
my
$sid
=
getSIDFromCID
(
$iface
,
$cid
);
if
(
!
defined
(
$sid
))
{
return
{
};
}
return
_getStatsBySID
(
$sid
);
my
$identifier
=
"
Class:
$iface
:
$cid
";
return
_getSIDFromIdentifier
(
$identifier
);
}
#
G
et the stats ID from Class ID
sub
g
etSIDFromCID
#
S
et the stats ID from Class ID
sub
s
etSIDFromCID
{
my
(
$iface
,
$cid
)
=
@_
;
my
$identifier
=
"
Class:
$iface
:
$cid
";
return
_getSIDFromIdentifier
(
$identifier
);
my
$sid
=
_getSIDFromIdentifier
(
$identifier
);
if
(
!
defined
(
$sid
))
{
$sid
=
_setSIDFromIdentifier
(
$identifier
);
}
return
$sid
;
}
# Get the stats ID from a LID
sub
getSIDFromLID
{
my
(
$lid
)
=
@_
;
my
$lid
=
shift
;
if
(
defined
(
my
$username
=
getLimitUsername
(
$lid
)))
{
my
$identifier
=
"
Username:
$username
";
...
...
@@ -698,6 +698,51 @@ sub getSIDFromLID
}
# Set the stats ID from a LID
sub
setSIDFromLID
{
my
$lid
=
shift
;
if
(
defined
(
my
$username
=
getLimitUsername
(
$lid
)))
{
my
$identifier
=
"
Username:
$username
";
my
$sid
=
_getSIDFromIdentifier
(
$identifier
);
if
(
!
defined
(
$sid
))
{
$sid
=
_setSIDFromIdentifier
(
$identifier
);
}
return
$sid
;
}
return
undef
;
}
# Get the stats ID from a counter
sub
getSIDFromCounter
{
my
$counter
=
shift
;
my
$identifier
=
"
Counter:
$counter
";
return
_getSIDFromIdentifier
(
$identifier
);
}
# Set the stats ID from a counter
sub
setSIDFromCounter
{
my
$counter
=
shift
;
my
$identifier
=
"
Counter:
$counter
";
my
$sid
=
_getSIDFromIdentifier
(
$identifier
);
if
(
!
defined
(
$sid
))
{
$sid
=
_setSIDFromIdentifier
(
$identifier
);
}
return
$sid
;
}
# Return traffic direction
sub
getTrafficDirection
{
...
...
@@ -847,13 +892,26 @@ sub _getSIDFromIdentifier
warn
"
FAILED TO EXECUTE GETUSER:
"
.
$identifierGetSTH
->
errstr
;
}
return
undef
;
}
# Set SID from identifier in DB
sub
_setSIDFromIdentifier
{
my
$identifier
=
shift
;
# Try add it to the DB
my
$identifierAddSTH
=
$statsPreparedStatements
->
{'
identifier_add
'};
if
(
my
$res
=
$identifierAddSTH
->
execute
(
$identifier
))
{
return
$statsDBIdentifierMap
->
{
$identifier
}
=
$dbh
->
last_insert_id
("","","","");
}
else
{
# FIXME
warn
"
DB ADD IDENTIFIER ERROR:
"
.
$identifierAddSTH
->
errstr
;
}
return
undef
;
}
...
...
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