Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-WIC-Opencpc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
OpenXG
OpenXG-WIC-Opencpc
Commits
0cb427d5
Commit
0cb427d5
authored
Apr 13, 2018
by
joliu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复更新状态失败的bug,并增加更加详细的网络信息
parent
f10fb15f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
hfv/Dockerfile
hfv/Dockerfile
+2
-1
hfv/testDevice.py
hfv/testDevice.py
+10
-7
No files found.
hfv/Dockerfile
View file @
0cb427d5
...
...
@@ -2,13 +2,14 @@ FROM opengn.org:32333/easypi/alpine-arm
MAINTAINER
joliu<joliu@s-an.org>
ENV
TIME_ZONE Asia/Shanghai
RUN
apk
--update
add python3 py3-pip tzdata
RUN
pip3
install
pymysql
pymysql
-i
https://pypi.douban.com/simple
RUN
pip3
install
pymysql
-i
https://pypi.douban.com/simple
RUN
echo
"
${
TIME_ZONE
}
"
>
/etc/timezone
\
&&
ln
-sf
/usr/share/zoneinfo/
${
TIME_ZONE
}
/etc/localtime
WORKDIR
/data
COPY
listenSer.py /data
COPY
workProcess.py /data
COPY
testDevice.py /data
COPY
start.sh /data
CMD
sh /data/start.sh
hfv/testDevice.py
View file @
0cb427d5
...
...
@@ -20,7 +20,7 @@ def sdnToDatabase(sql):
# 发送sql命令到数据库
cmd
=
sql
.
split
(
' '
)[
0
]
try
:
conn
=
pymysql
.
connect
(
host
=
'
127.0.0.1'
,
port
=
12
306
,
user
=
'root'
,
passwd
=
'Vudo3423'
,
db
=
'HiDockerwifi'
,
charset
=
'utf8'
)
conn
=
pymysql
.
connect
(
host
=
'
test-mysql'
,
port
=
3
306
,
user
=
'root'
,
passwd
=
'Vudo3423'
,
db
=
'HiDockerwifi'
,
charset
=
'utf8'
)
cursor
=
conn
.
cursor
()
cursor
.
execute
(
sql
)
if
cmd
==
'select'
:
...
...
@@ -68,7 +68,7 @@ def updateDeviceInfo(ipaddress, equipid, device_status, delay):
device_status
,
delay
)
else
:
sql
=
"update deviceinfo set status=%d,delay='%s' where ipaddress='%s'"
%
\
(
1
,
delay
,
ipaddress
)
(
device_status
,
delay
,
ipaddress
)
(
status
,
output
)
=
sdnToDatabase
(
sql
)
if
not
status
:
...
...
@@ -81,20 +81,23 @@ def updateDeviceInfo(ipaddress, equipid, device_status, delay):
def
pingTestHost
(
ip
):
# 使用ping检测host设备的网络通信情况
cmd
=
'ping -c
1 -w 1
'
+
ip
cmd
=
'ping -c
4 -w 4
'
+
ip
equipid
=
getDeviceIDByIP
(
ip
)
if
not
equipid
:
return
False
# 执行ping命令
device_status
=
0
(
status
,
output
)
=
subprocess
.
getstatusoutput
(
cmd
)
if
status
==
0
:
# 如果检测设备正常,获取单次检测的时延
delayTime
=
output
.
split
(
'
\n
'
)[
1
].
split
(
' '
)[
-
2
].
split
(
'='
)[
1
]
status
=
1
# delayTime = output.split('\n')[1].split(' ')[-2].split('=')[1]
delayTime
=
output
.
split
(
'
\n
'
)[
-
1
].
split
(
' '
)[
-
2
]
print
(
delayTime
)
device_status
=
1
else
:
delayTime
=
'-'
status
=
0
return
updateDeviceInfo
(
ip
,
equipid
,
status
,
delayTime
)
device_
status
=
0
return
updateDeviceInfo
(
ip
,
equipid
,
device_
status
,
delayTime
)
if
__name__
==
"__main__"
:
host
=
os
.
getenv
(
'HOST'
)
...
...
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