Skip to content

Commit

Permalink
nas info
Browse files Browse the repository at this point in the history
  • Loading branch information
seanenck committed Feb 8, 2017
1 parent 0f0fe32 commit 82176d1
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions mods-config/python/utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,37 @@

ALL_USERS_REPORT = "select user from ({0}) group by user"

NAS_INFO_COLS = """
ifnull(nasipaddr.val, 'n/a') as nip,
ifnull(nasport.val, 'n/a') as np,
ifnull(nasporttype.val, 'n/a') as npt
"""

NAS_INFO = """
left join
(
select line, val from data where key = 'NAS-IP-Address'
) as nasipaddr
on nasipaddr.line = data.line
left join
(
select line, val from data where key = 'NAS-Port'
) as nasport
on nasport.line = data.line
left outer join
(
select line, val from data where key = 'NAS-Port-Type'
) as nasporttype
on nasporttype.line = data.line
"""

FAILED_AUTHS = """
select user as userfqdn, max(date) as date from
select user as user, max(date) as date, nip as IP, np as Port, npt as Method
from
(
select date, val as user from data
select date, user, {0} from data
inner join users on users.line = data.line
{1}
where
instance not in
(
Expand All @@ -107,37 +134,20 @@
select distinct instance from data
where key = 'FreeRADIUS-Proxied-To'
)
and key = '{0}'
and key = '{2}'
) as auths
group by user
group by user, np, npt, nip
order by date
""".format(store.USER_NAME)
""".format(NAS_INFO_COLS, NAS_INFO, store.USER_NAME)

SIGNATURES = """
select distinct user, mac,
ifnull(nasipaddr.val, 'n/a') as nip,
ifnull(nasport.val, 'n/a') as np,
ifnull(nasporttype.val, 'n/a') as npt
select distinct user, mac, {0}
from data
inner join users on users.line = data.line
inner join macs on macs.line = data.line
left join
(
select line, val from data where key = 'NAS-IP-Address'
) as nasipaddr
on nasipaddr.line = data.line
left join
(
select line, val from data where key = 'NAS-Port'
) as nasport
on nasport.line = data.line
left outer join
(
select line, val from data where key = 'NAS-Port-Type'
) as nasporttype
on nasporttype.line = data.line
{1}
order by user, mac, nip, np, npt
"""
""".format(NAS_INFO_COLS, NAS_INFO)


def _packets_daily(cursor, opts):
Expand Down Expand Up @@ -214,9 +224,9 @@ def _gen():
format_str = []
for col in cols:
use_format = "15"
if col in ["attr", "userfqdn"]:
if col in ["attr", "user"]:
use_format = "25"
if col in ["signature", "userfqdn"]:
if col in ["signature"]:
use_format = "50"
if col == "mac":
use_format = "20"
Expand Down

0 comments on commit 82176d1

Please sign in to comment.