Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
31234e71
Commit
31234e71
authored
Oct 27, 2017
by
Gabriel Detraz
Committed by
root
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rajoute des données en statistiques
parent
241d2462
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
22 deletions
+112
-22
logs/views.py
logs/views.py
+112
-22
No files found.
logs/views.py
View file @
31234e71
...
...
@@ -46,13 +46,50 @@ from django.db.models import Count
from
reversion.models
import
Revision
from
reversion.models
import
Version
,
ContentType
from
users.models
import
User
,
ServiceUser
,
Right
,
School
,
ListRight
,
ListShell
from
users.models
import
Ban
,
Whitelist
from
cotisations.models
import
Facture
,
Vente
,
Article
,
Banque
,
Paiement
from
cotisations.models
import
Cotisation
from
machines.models
import
Machine
,
MachineType
,
IpType
,
Extension
,
Interface
from
machines.models
import
Domain
,
IpList
from
topologie.models
import
Switch
,
Port
,
Room
from
users.models
import
(
User
,
ServiceUser
,
Right
,
School
,
ListRight
,
ListShell
,
Ban
,
Whitelist
,
Adherent
,
Club
)
from
cotisations.models
import
(
Facture
,
Vente
,
Article
,
Banque
,
Paiement
,
Cotisation
)
from
machines.models
import
(
Machine
,
MachineType
,
IpType
,
Extension
,
Interface
,
Domain
,
IpList
,
OuverturePortList
,
Service
,
Vlan
,
Nas
,
SOA
,
Mx
,
Ns
)
from
topologie.models
import
(
Switch
,
Port
,
Room
,
Stack
,
ModelSwitch
,
ConstructorSwitch
)
from
preferences.models
import
GeneralOption
from
re2o.views
import
form
from
re2o.utils
import
all_whitelisted
,
all_baned
,
all_has_access
,
all_adherent
...
...
@@ -183,45 +220,77 @@ def stats_general(request):
range, et les statistiques générales sur les users : users actifs,
cotisants, activés, archivés, etc"""
ip_dict
=
dict
()
for
ip_range
in
IpType
.
objects
.
all
():
for
ip_range
in
IpType
.
objects
.
select_related
(
'vlan'
).
all
():
all_ip
=
IpList
.
objects
.
filter
(
ip_type
=
ip_range
)
used_ip
=
Interface
.
objects
.
filter
(
ipv4__in
=
all_ip
).
count
()
active_ip
=
all_active_assigned_interfaces_count
().
filter
(
ipv4__in
=
IpList
.
objects
.
filter
(
ip_type
=
ip_range
)
).
count
()
ip_dict
[
ip_range
]
=
[
ip_range
,
all_ip
.
count
(),
ip_dict
[
ip_range
]
=
[
ip_range
,
ip_range
.
vlan
,
all_ip
.
count
(),
used_ip
,
active_ip
,
all_ip
.
count
()
-
used_ip
]
_all_adherent
=
all_adherent
()
_all_has_access
=
all_has_access
()
_all_baned
=
all_baned
()
_all_whitelisted
=
all_whitelisted
()
_all_active_interfaces_count
=
all_active_interfaces_count
()
_all_active_assigned_interfaces_count
=
all_active_assigned_interfaces_count
()
stats
=
[
[[
"Categorie"
,
"Nombre d'utilisateurs"
],
{
[[
"Categorie"
,
"Nombre d'utilisateurs
(total club et adhérents)"
,
"Nombre d'adhérents"
,
"Nombre de clubs
"
],
{
'active_users'
:
[
"Users actifs"
,
User
.
objects
.
filter
(
state
=
User
.
STATE_ACTIVE
).
count
()],
'inactive_users'
:
[
User
.
objects
.
filter
(
state
=
User
.
STATE_ACTIVE
).
count
(),
Adherent
.
objects
.
filter
(
state
=
Adherent
.
STATE_ACTIVE
).
count
(),
Club
.
objects
.
filter
(
state
=
Club
.
STATE_ACTIVE
).
count
()],
'inactive_users'
:
[
"Users désactivés"
,
User
.
objects
.
filter
(
state
=
User
.
STATE_DISABLED
).
count
()],
User
.
objects
.
filter
(
state
=
User
.
STATE_DISABLED
).
count
(),
Adherent
.
objects
.
filter
(
state
=
Adherent
.
STATE_DISABLED
).
count
(),
Club
.
objects
.
filter
(
state
=
Club
.
STATE_DISABLED
).
count
()],
'archive_users'
:
[
"Users archivés"
,
User
.
objects
.
filter
(
state
=
User
.
STATE_ARCHIVE
).
count
()],
User
.
objects
.
filter
(
state
=
User
.
STATE_ARCHIVE
).
count
(),
Adherent
.
objects
.
filter
(
state
=
Adherent
.
STATE_ARCHIVE
).
count
(),
Club
.
objects
.
filter
(
state
=
Club
.
STATE_ARCHIVE
).
count
()],
'adherent_users'
:
[
"Adhérents à l'association"
,
all_adherent
().
count
()],
"Cotisant à l'association"
,
_all_adherent
.
count
(),
_all_adherent
.
exclude
(
adherent__isnull
=
True
).
count
(),
_all_adherent
.
exclude
(
club__isnull
=
True
).
count
()],
'connexion_users'
:
[
"Utilisateurs bénéficiant d'une connexion"
,
all_has_access
().
count
()],
_all_has_access
.
count
(),
_all_has_access
.
exclude
(
adherent__isnull
=
True
).
count
(),
_all_has_access
.
exclude
(
club__isnull
=
True
).
count
()],
'ban_users'
:
[
"Utilisateurs bannis"
,
all_baned
().
count
()],
_all_baned
.
count
(),
_all_baned
.
exclude
(
adherent__isnull
=
True
).
count
(),
_all_baned
.
exclude
(
club__isnull
=
True
).
count
()],
'whitelisted_user'
:
[
"Utilisateurs bénéficiant d'une connexion gracieuse"
,
all_whitelisted
().
count
()],
_all_whitelisted
.
count
(),
_all_whitelisted
.
exclude
(
adherent__isnull
=
True
).
count
(),
_all_whitelisted
.
exclude
(
club__isnull
=
True
).
count
()],
'actives_interfaces'
:
[
"Interfaces actives (ayant accès au reseau)"
,
all_active_interfaces_count
().
count
()],
_all_active_interfaces_count
.
count
(),
_all_active_interfaces_count
.
exclude
(
machine__user__adherent__isnull
=
True
).
count
(),
_all_active_interfaces_count
.
exclude
(
machine__user__club__isnull
=
True
).
count
()],
'actives_assigned_interfaces'
:
[
"Interfaces actives et assignées ipv4"
,
all_active_assigned_interfaces_count
().
count
()]
_all_active_assigned_interfaces_count
.
count
(),
_all_active_assigned_interfaces_count
.
exclude
(
machine__user__adherent__isnull
=
True
).
count
(),
_all_active_assigned_interfaces_count
.
exclude
(
machine__user__club__isnull
=
True
).
count
()]
}],
[[
"Range d'ip"
,
"Nombre d'ip totales"
,
"Ip assignées"
,
[[
"Range d'ip"
,
"
Vlan"
,
"
Nombre d'ip totales"
,
"Ip assignées"
,
"Ip assignées à une machine active"
,
"Ip non assignées"
],
ip_dict
]
]
return
render
(
request
,
'logs/stats_general.html'
,
{
'stats_list'
:
stats
})
...
...
@@ -236,6 +305,8 @@ def stats_models(request):
stats
=
{
'Users'
:
{
'users'
:
[
User
.
PRETTY_NAME
,
User
.
objects
.
count
()],
'adherents'
:
[
Adherent
.
PRETTY_NAME
,
Adherent
.
objects
.
count
()],
'clubs'
:
[
Club
.
PRETTY_NAME
,
Club
.
objects
.
count
()],
'serviceuser'
:
[
ServiceUser
.
PRETTY_NAME
,
ServiceUser
.
objects
.
count
()],
'right'
:
[
Right
.
PRETTY_NAME
,
Right
.
objects
.
count
()],
...
...
@@ -262,11 +333,30 @@ def stats_models(request):
'alias'
:
[
Domain
.
PRETTY_NAME
,
Domain
.
objects
.
exclude
(
cname
=
None
).
count
()],
'iplist'
:
[
IpList
.
PRETTY_NAME
,
IpList
.
objects
.
count
()],
'service'
:
[
Service
.
PRETTY_NAME
,
Service
.
objects
.
count
()],
'ouvertureportlist'
:
[
OuverturePortList
.
PRETTY_NAME
,
OuverturePortList
.
objects
.
count
()
],
'vlan'
:
[
Vlan
.
PRETTY_NAME
,
Vlan
.
objects
.
count
()],
'SOA'
:
[
Mx
.
PRETTY_NAME
,
Mx
.
objects
.
count
()],
'Mx'
:
[
Mx
.
PRETTY_NAME
,
Mx
.
objects
.
count
()],
'Ns'
:
[
Ns
.
PRETTY_NAME
,
Ns
.
objects
.
count
()],
'nas'
:
[
Nas
.
PRETTY_NAME
,
Nas
.
objects
.
count
()],
},
'Topologie'
:
{
'switch'
:
[
Switch
.
PRETTY_NAME
,
Switch
.
objects
.
count
()],
'port'
:
[
Port
.
PRETTY_NAME
,
Port
.
objects
.
count
()],
'chambre'
:
[
Room
.
PRETTY_NAME
,
Room
.
objects
.
count
()],
'stack'
:
[
Stack
.
PRETTY_NAME
,
Stack
.
objects
.
count
()],
'modelswitch'
:
[
ModelSwitch
.
PRETTY_NAME
,
ModelSwitch
.
objects
.
count
()
],
'constructorswitch'
:
[
ConstructorSwitch
.
PRETTY_NAME
,
ConstructorSwitch
.
objects
.
count
()
],
},
'Actions effectuées sur la base'
:
{
...
...
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