Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nigel Kukard
smradius
Commits
57bded4d
Commit
57bded4d
authored
Sep 10, 2016
by
Nigel Kukard
Browse files
Nicer log output for usage calculations
parent
ed634192
Changes
1
Hide whitespace changes
Inline
Side-by-side
smradius/modules/features/mod_feature_capping.pm
View file @
57bded4d
...
...
@@ -217,7 +217,7 @@ sub post_auth_hook
# Check session time has not exceeded what we're allowed
if
(
$accountingUsage
->
{'
TotalSessionTime
'}
>=
$uptimeLimitWithTopups
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
M
in exceeds allowed limit of
"
.
$uptimeLimitWithTopups
.
"
M
in
. Capped.
");
"
m
in exceeds allowed limit of
"
.
$uptimeLimitWithTopups
.
"
m
in
");
return
MOD_RES_NACK
;
# Setup limits
}
else
{
...
...
@@ -242,7 +242,7 @@ sub post_auth_hook
# Capped
if
(
$accountingUsage
->
{'
TotalDataUsage
'}
>=
$trafficLimitWithTopups
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb exceeds allowed limit of
"
.
$trafficLimitWithTopups
.
"
Mb
. Capped.
");
"
Mb
yte
exceeds allowed limit of
"
.
$trafficLimitWithTopups
.
"
Mb
yte
");
return
MOD_RES_NACK
;
# Setup limits
}
else
{
...
...
@@ -395,7 +395,7 @@ sub post_acct_hook
# Capped
if
(
$accountingUsage
->
{'
TotalSessionTime
'}
>=
$uptimeLimitWithTopups
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
M
in exceeds allowed limit of
"
.
$uptimeLimitWithTopups
.
"
M
in
. Capped.
");
"
m
in exceeds allowed limit of
"
.
$uptimeLimitWithTopups
.
"
m
in
");
return
MOD_RES_NACK
;
}
}
...
...
@@ -406,7 +406,7 @@ sub post_acct_hook
# Capped
if
(
$accountingUsage
->
{'
TotalDataUsage
'}
>=
$trafficLimitWithTopups
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb exceeds allowed limit of
"
.
$trafficLimitWithTopups
.
"
Mb
. Capped.
");
"
Mb
yte
exceeds allowed limit of
"
.
$trafficLimitWithTopups
.
"
Mb
yte
");
return
MOD_RES_NACK
;
}
}
...
...
@@ -482,17 +482,17 @@ sub _logUptimeUsage
# Check if our limit is defined
if
(
!
defined
(
$uptimeLimit
))
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Uptime => Usage total:
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
M
in (
Cap
: Prepaid, Topups:
"
.
$uptimeTopupAmount
.
"
M
in)
");
"
m
in (
Limit
: Prepaid, Topups:
"
.
$uptimeTopupAmount
.
"
m
in)
");
return
;
}
# If so, check if its > 0, which would depict its capped
if
(
$uptimeLimit
>
0
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Uptime => Usage total:
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
M
in (
Cap
:
"
.
$uptimeLimit
.
"
M
in, Topups:
"
.
$uptimeTopupAmount
.
"
M
in)
");
"
m
in (
Limit
:
"
.
$uptimeLimit
.
"
m
in, Topups:
"
.
$uptimeTopupAmount
.
"
m
in)
");
}
else
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Uptime => Usage total:
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
M
in (
Cap: Uncapped
, Topups:
"
.
$uptimeTopupAmount
.
"
M
in)
");
"
m
in (
Limit: none
, Topups:
"
.
$uptimeTopupAmount
.
"
m
in)
");
}
return
;
...
...
@@ -510,17 +510,17 @@ sub _logTrafficUsage
# Check if our limit is defined
if
(
!
defined
(
$trafficLimit
))
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Bandwidth => Usage total:
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb
(Cap
: Prepaid, Topups:
"
.
$trafficTopupAmount
.
"
Mb)
");
"
Mb
yte (Limit
: Prepaid, Topups:
"
.
$trafficTopupAmount
.
"
Mb
yte
)
");
return
;
}
# If so, check if its > 0, which would depict its capped
if
(
$trafficLimit
>
0
)
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Bandwidth => Usage total:
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb
(Cap
:
"
.
$trafficLimit
.
"
Mb, Topups:
"
.
$trafficTopupAmount
.
"
Mb)
");
"
Mb
yte (Limit
:
"
.
$trafficLimit
.
"
Mb
yte
, Topups:
"
.
$trafficTopupAmount
.
"
Mb
yte
)
");
}
else
{
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Bandwidth => Usage total:
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb
(Cap: Uncapped
, Topups:
"
.
$trafficTopupAmount
.
"
Mb)
");
"
Mb
yte (Limit: none
, Topups:
"
.
$trafficTopupAmount
.
"
Mb
yte
)
");
}
return
;
...
...
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