Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zyxel Exporter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nico
Zyxel Exporter
Commits
028b1998
Unverified
Commit
028b1998
authored
10 months ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
expose zyxel location
parent
46f3d9b4
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.py
+10
-8
10 additions, 8 deletions
main.py
stats.py
+1
-0
1 addition, 0 deletions
stats.py
zyxel.py
+26
-0
26 additions, 0 deletions
zyxel.py
with
37 additions
and
8 deletions
main.py
+
10
−
8
View file @
028b1998
...
...
@@ -28,10 +28,11 @@ class ZyxelCollector:
self
.
targets
=
targets
def
collect
(
self
):
channel
=
prometheus_client
.
core
.
InfoMetricFamily
(
"
channel
"
,
"
Channel the radio is operating on
"
,
labels
=
[
"
ap
"
,
"
ip
"
,
"
radio
"
])
client_count
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
client_count
'
,
"
Number of clients on this radio
"
,
labels
=
[
"
ap
"
,
"
ip
"
,
"
radio
"
])
uptime
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
zyxel_uptime
'
,
"
Number of seconds device is running
"
,
labels
=
[
"
ap
"
,
"
ip
"
,
"
radio
"
])
util
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
zyxel_chan_util
'
,
"
Utilization of radio channel
"
,
labels
=
[
"
ap
"
,
"
ip
"
,
"
radio
"
])
labels
=
[
"
ap
"
,
"
ip
"
,
"
radio
"
,
"
location
"
]
channel
=
prometheus_client
.
core
.
InfoMetricFamily
(
"
channel
"
,
"
Channel the radio is operating on
"
,
labels
=
labels
)
client_count
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
client_count
'
,
"
Number of clients on this radio
"
,
labels
=
labels
)
uptime
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
zyxel_uptime
'
,
"
Number of seconds device is running
"
,
labels
=
labels
)
util
=
prometheus_client
.
core
.
GaugeMetricFamily
(
'
zyxel_chan_util
'
,
"
Utilization of radio channel
"
,
labels
=
labels
)
for
target
in
self
.
targets
:
try
:
...
...
@@ -40,10 +41,11 @@ class ZyxelCollector:
stats
=
c
.
collect
()
for
stat
in
stats
:
client_count
.
add_metric
([
stat
.
hostname
,
stat
.
ip
,
stat
.
type
],
stat
.
client_count
)
channel
.
add_metric
([
stat
.
hostname
,
stat
.
ip
,
stat
.
type
],
{
"
channel
"
:
stat
.
channel
})
uptime
.
add_metric
([
stat
.
hostname
,
stat
.
ip
,
stat
.
type
],
stat
.
uptime
)
util
.
add_metric
([
stat
.
hostname
,
stat
.
ip
,
stat
.
type
],
stat
.
util
)
label_values
=
[
stat
.
hostname
,
stat
.
ip
,
stat
.
type
,
stat
.
location
]
client_count
.
add_metric
(
label_values
,
stat
.
client_count
)
channel
.
add_metric
(
label_values
,
{
"
channel
"
:
stat
.
channel
})
uptime
.
add_metric
(
label_values
,
stat
.
uptime
)
util
.
add_metric
(
label_values
,
stat
.
util
)
c
.
close
()
logging
.
info
(
"
Done scaping for %s
"
,
target
[
"
host
"
])
except
Exception
as
e
:
...
...
This diff is collapsed.
Click to expand it.
stats.py
+
1
−
0
View file @
028b1998
...
...
@@ -7,6 +7,7 @@ TYPE_5G = "5ghz"
@dataclass
class
WifiStats
:
hostname
:
str
location
:
str
ip
:
str
uptime
:
int
channel
:
str
...
...
This diff is collapsed.
Click to expand it.
zyxel.py
+
26
−
0
View file @
028b1998
...
...
@@ -52,6 +52,32 @@ class ZyxelClient:
_
,
ip
=
line
.
split
(
"
:
"
,
maxsplit
=
1
)
ip
=
ip
.
strip
()
"""
Router> show snmp status
active : no
port : 161
version : v2c
contact : support@zyxel.com.tw
location : Infozelt
get community : public
set community : private
trap : no
informs : no
trap host : none
trap community: public
wireless trap : no
"""
resp
=
self
.
_run_cmd
(
"
show snmp status
"
)
for
line
in
resp
.
split
(
"
\n
"
):
line
=
line
.
strip
()
if
line
.
startswith
(
"
location
"
):
_
,
location
=
line
.
split
(
"
:
"
,
maxsplit
=
1
)
location
=
location
.
strip
()
"""
Router> show system uptime
system uptime: 05:01:57
"""
resp
=
self
.
_run_cmd
(
"
show system uptime
"
)
for
line
in
resp
.
split
(
"
\n
"
):
line
=
line
.
strip
()
...
...
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