Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scripts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Blanc
scripts
Commits
c3e28ac9
Commit
c3e28ac9
authored
May 07, 2013
by
Daniel Stan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[whokfet] ajout d'un plugin munin
parent
75a4d6b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
11 deletions
+52
-11
gestion/tools/__init__.py
gestion/tools/__init__.py
+0
-0
gestion/tools/whokfet.py
gestion/tools/whokfet.py
+35
-11
munin/scripts/hosts_plugins.py
munin/scripts/hosts_plugins.py
+1
-0
munin/whokfet
munin/whokfet
+16
-0
No files found.
gestion/tools/__init__.py
0 → 100644
View file @
c3e28ac9
gestion/tools/whokfet.py
View file @
c3e28ac9
...
...
@@ -27,12 +27,19 @@ def get_wifi_connected_client(host):
f
.
close
()
return
[
mac
.
firstChild
.
nodeValue
for
mac
in
doc
.
getElementsByTagName
(
'mac'
)
]
STATE_DESCR
=
{
'ma'
:
(
'machines de membres actifs'
,
0x00ff00
),
'crans'
:
(
'machines du crans'
,
0x0000ff
),
'adh'
:
(
'autres machines appartenant aux autres adhérents'
,
0xe5ff00
),
'unknown_macs'
:
(
'machines inconnues de la base'
,
0xff0000
),
}
def
get_state
():
sw
=
hpswitch
(
'backbone.adm.crans.org'
)
db
=
crans_ldap
()
res
=
{
'machines'
:
[],
'machines_crans'
:
[],
'unknown'
:
[],
res
=
{
'ma'
:
[],
'crans'
:
[],
'adh'
:
[],
'unknown_macs'
:
[],
'ttyfound'
:
0
,
}
try
:
...
...
@@ -45,27 +52,44 @@ def get_state():
fm
=
db
.
search
(
"mac=
%
s"
%
mac
)
if
fm
[
'machine'
]:
m
=
fm
[
'machine'
][
0
]
if
not
fm
[
'machineCrans'
]
and
hasattr
(
m
.
proprietaire
(),
'droits'
)
and
m
.
proprietaire
()
.
droits
():
# On filtre ceux qui ont des droits et qui sont pas des machines crans
res
[
'machines'
]
.
append
(
m
)
if
fm
[
'machineCrans'
]:
key
=
'crans'
elif
hasattr
(
m
.
proprietaire
(),
'droits'
)
and
m
.
proprietaire
()
.
droits
():
key
=
'ma'
else
:
key
=
'adh'
res
[
key
]
.
append
(
m
)
else
:
res
[
'unknown'
]
.
append
(
mac
)
res
[
'unknown
_macs
'
]
.
append
(
mac
)
return
res
def
summary
(
current
):
u"""Réalise un joli aperçu de l'état donné en paramètre."""
if
current
[
'ma
chines
'
]:
if
current
[
'ma'
]:
cprint
(
'---=== Machines des membres actifs ===---'
,
'bleu'
)
aff
(
current
[
'ma
chines
'
])
aff
(
current
[
'ma'
])
cprint
(
"---=== Il y a du monde à la Kfet ! ===---"
,
'vert'
)
else
:
cprint
(
"---=== Il semble n'y avoir personne à la Kfet ... ===---"
,
'rouge'
)
for
mac
in
current
[
'unknown'
]:
for
mac
in
current
[
'unknown
_macs
'
]:
cprint
(
"Machine inconnue:
%
s"
%
mac
,
'rouge'
)
def
munin_config
():
"""Donne la configuration du graphe munin"""
print
"""graph_title Membres actifs à la kfet
graph_vlabel N
graph_category environnement"""
for
(
name
,(
descr
,
color
))
in
STATE_DESCR
.
iteritems
():
print
"""
%(name)
s.label
%(descr)
s
%(name)
s AREASTACK
%(name)
s.colour
%(color)06
X"""
%
{
'name'
:
name
,
'descr'
:
descr
,
'color'
:
color
}
# Dans le doute, n'affichons pas les adhérents
print
"adh.graph no"
def
munin
(
current
):
"""S'occupe de l'affichage pour munin. TODO: l'écrire."""
pass
for
name
in
STATE_DESCR
.
iterkeys
():
print
"""
%(name)
s.value
%(value)
s"""
%
{
'name'
:
name
,
'value'
:
len
(
current
[
name
])}
if
__name__
==
'__main__'
:
state
=
get_state
()
...
...
munin/scripts/hosts_plugins.py
View file @
c3e28ac9
...
...
@@ -37,6 +37,7 @@ hosts_plugins = {
"webalizer_intranet"
:
"webalizer_"
,
"webalizer_perso"
:
"webalizer_"
,
"who"
:
"who"
,
"whokfet"
:
"whokfet"
,
},
"vert"
:
{
"slapd_bdb_cache_pages"
:
"slapd_bdb_cache_"
,
...
...
munin/whokfet
0 → 100755
View file @
c3e28ac9
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Graphe des membres actifs présents à la Kfet"""
import
sys
sys
.
path
.
append
(
'/usr/scripts'
)
from
gestion.tools
import
whokfet
action
=
''
.
join
(
sys
.
argv
[
1
:
2
])
if
action
==
'autoconfig'
:
print
"yes"
elif
action
==
'config'
:
whokfet
.
munin_config
()
else
:
whokfet
.
munin
(
whokfet
.
get_state
())
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