File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ #_*_ coding:utf-8 _*_
3
+
4
+ import MySQLdb
5
+
6
+
7
+ with open ('/var/logs/install.log' ) as f :
8
+ a = f .read ().strip ().split ('\n ' )
9
+ hostl = []
10
+ for i in a :
11
+ b = i .split ('\t ' )
12
+ if b [3 ] == 'stop' :
13
+ hostl .append (b [1 ])
14
+ else :
15
+ pass
16
+ for host in list (set (hostl )):
17
+ conn = MySQLdb .connect (
18
+ host = 'localhost' ,
19
+ port = 3306 ,
20
+ user = 'root' ,
21
+ passwd = '111111' ,
22
+ db = 'pj_install' ,
23
+ )
24
+ try :
25
+ #select
26
+ sql = "select * from automsg where HostName='{0}'" .format (host )
27
+ cur = conn .cursor ()
28
+ cur .execute (sql )
29
+ ret = cur .fetchone ()
30
+
31
+ #update
32
+ update_sql = "update installretmsg set status=2, msg=u'安装成功!' where id={0}" .format (int (ret [0 ]))
33
+ cur .execute (update_sql )
34
+
35
+ cur .close ()
36
+ conn .commit ()
37
+ conn .close ()
38
+ except :
39
+ pass
You can’t perform that action at this time.
0 commit comments