Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zabbix
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
infra
zabbix
Commits
095989c9
Commit
095989c9
authored
May 13, 2025
by
devteam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete asterisk.py
parent
ef92a9e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
136 deletions
+0
-136
asterisk.py
zabbix_v2/asterisk.py
+0
-136
No files found.
zabbix_v2/asterisk.py
deleted
100644 → 0
View file @
ef92a9e7
#!/usr/bin/env python
import
sys
import
subprocess
import
re
Metrics
=
[
"ACH"
,
"AC"
,
"PC"
,
"PEERS"
,
"ACP"
,
"ICP"
,
"VR"
,
"STT"
,
"LRT"
,
"DLPDSA"
,
"DLPUSB"
,
"PKDCL"
,
"QC"
,
"HLDT"
,
"TLKT"
,
"QCALLS"
,
"QACALLS"
]
# Descricao das Opcoes
# "ACH" - Canais ativos
# "AC" - Licacoes ativas
# "PC" - Licacoes processadas
# "PEERS" - Peers
# "ACP" - Peers ativos
# "ICP" - Peers inativos
# "VR" - Versao
# "STT" - Startup time
# "DLPDSA" - Dundi DSA
# "PKDCL" - Parked Calls
# "QC" - Queued calls
# "HLDT" - Queue Tempo de espera
# "TLKT" - Queue Tempo de fala
# "QCALLS" - Queue Chamadas
# "QACALLS" - Queue Chamadas Abandonadas
from
subprocess
import
PIPE
,
Popen
def
cmdline
(
command
):
process
=
Popen
(
args
=
command
,
stdout
=
PIPE
,
shell
=
True
)
return
process
.
communicate
()[
0
]
def
get_metric
(
metric
):
if
metric
==
"ACH"
:
command
=
cmdline
(
"sudo asterisk -rx 'sip show channels'"
)
active_calls
=
(
len
(
command
.
split
(
'
\n
'
)))
-
2
return
active_calls
elif
metric
==
"AC"
:
command
=
cmdline
(
"sudo asterisk -rx 'core show calls' | grep 'active call'"
)
active_calls
=
[
int
(
s
)
for
s
in
command
.
split
()
if
s
.
isdigit
()]
return
active_calls
[
0
]
elif
metric
==
"PC"
:
command
=
cmdline
(
"sudo asterisk -rx 'core show calls' | grep 'calls processed'"
)
calls_processed
=
[
int
(
s
)
for
s
in
command
.
split
()
if
s
.
isdigit
()]
return
calls_processed
[
0
]
elif
metric
==
"PEERS"
:
command
=
cmdline
(
"sudo asterisk -rx 'sip show peers'"
)
peers
=
len
((
command
.
split
(
'
\n
'
)))
-
3
return
peers
elif
metric
==
"ACP"
:
command
=
cmdline
(
"sudo asterisk -rx 'sip show peers'"
)
active_peers
=
command
.
count
(
"OK"
)
return
active_peers
elif
metric
==
"ICP"
:
command
=
cmdline
(
"sudo asterisk -rx 'sip show peers'"
)
inactive_peers
=
command
.
count
(
"UNKNOWN"
)
return
inactive_peers
elif
metric
==
"VR"
:
command
=
cmdline
(
"sudo asterisk -rx 'core show settings' | grep 'Version:'"
)
version
=
command
.
split
()
return
version
[
1
]
elif
metric
==
"STT"
:
command
=
cmdline
(
"sudo asterisk -rx 'core show settings' | grep 'Startup time:'"
)
stt
=
command
.
split
()
return
stt
[
2
]
elif
metric
==
"LRT"
:
command
=
cmdline
(
"sudo asterisk -rx 'core show settings' | grep 'Last reload time:'"
)
lrt
=
command
.
split
()
return
lrt
[
1
]
elif
metric
==
"DLPDSA"
:
command
=
cmdline
(
"sudo asterisk -rx 'dundi lookup 0201000@priv' | grep 'DUNDi lookup returned no results.'"
)
if
command
==
"DUNDi lookup returned no results."
:
dundi_dsa
=
0
else
:
dundi_dsa
=
1
return
dundi_dsa
elif
metric
==
"DLPUSB"
:
command
=
cmdline
(
"sudo asterisk -rx 'dundi lookup 0701600@priv' | grep 'DUNDi lookup returned no results.'"
)
if
command
==
"DUNDi lookup returned no results."
:
dundi_usb
=
0
else
:
dundi_usb
=
1
return
dundi_usb
elif
metric
==
"PKDCL"
:
command
=
cmdline
(
"sudo asterisk -rx 'parkedcalls show' | grep 'parked calls in total'"
)
pkdcl
=
command
.
split
()
return
pkdcl
[
0
]
elif
metric
==
"QC"
:
command
=
cmdline
(
"sudo asterisk -rx 'queue show' | grep '[0-9] has [0-9] calls'"
)
qc
=
command
.
split
()
return
qc
[
2
]
elif
metric
==
"HLDT"
:
command
=
cmdline
(
"sudo asterisk -rx 'queue show' | grep '[0-9] has [0-9] calls'"
)
a
=
command
.
split
()
hldt
=
a
[
9
]
hldt
=
hldt
.
replace
(
"("
,
""
)
hldt
=
hldt
.
replace
(
"s"
,
""
)
return
hldt
elif
metric
==
"TLKT"
:
command
=
cmdline
(
"sudo asterisk -rx 'queue show' | grep '[0-9] has [0-9] calls'"
)
a
=
command
.
split
()
tlkt
=
a
[
11
]
tlkt
=
tlkt
.
replace
(
"s"
,
""
)
return
tlkt
elif
metric
==
"QCALLS"
:
command
=
cmdline
(
"sudo asterisk -rx 'queue show' | grep '[0-9] has [0-9] calls'"
)
a
=
command
.
split
()
qcalls
=
a
[
14
]
qcalls
=
qcalls
.
replace
(
"C:"
,
""
)
qcalls
=
qcalls
.
replace
(
","
,
""
)
return
qcalls
elif
metric
==
"QACALLS"
:
command
=
cmdline
(
"sudo asterisk -rx 'queue show' | grep '[0-9] has [0-9] calls'"
)
a
=
command
.
split
()
qcalls
=
a
[
15
]
qcalls
=
qcalls
.
replace
(
"A:"
,
""
)
qcalls
=
qcalls
.
replace
(
","
,
""
)
return
qcalls
if
__name__
==
"__main__"
:
try
:
metric
=
sys
.
argv
[
1
]
if
metric
not
in
Metrics
:
print
(
"Opcao Invalida"
)
sys
.
exit
(
1
)
else
:
print
(
get_metric
(
metric
))
except
:
print
(
"Dados nao disponiveis"
)
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