review|review what i studied `date` - 2017-4-10
写脚本会用到
curl -o /dev/null -s -w %{http_code} http://localhost 200 #返回网站状态码
zabbix 可视化:
一个Graph对应一个Item
simple check
说白了就是手动操作去完成一些简单的操作,例如pingnmap扫端口等
一切都是由zabbix-server自动去操作的
Python json模块
json模块接收到的数据类型只能是字典
devices += [{'name':device,'path':u}]
#其中devices就是字典类型
json.dumps(devices,sort_keys=True,indent=7,separators=(',',':'))
#结果:
[
{
"name":"1.mp4",
"path":"./video"
},
.........
]也可以写成这样:json.dumps({'data':devices},sort_keys=True,indent=7,separators=(',',':'))
#结果:
{
"data":[
{
"name":"1.mp4",
"path":"./video"
},
........
]
}
Python 写入文件:
f=open('./data.json','w').write(string)
example:
#!/bin/python
#!_*_conding:UTF-8_*_
import os
import json
r=os.listdir('./')
u='./video'
devices=[]
#list
for devpath in r:
device = os.path.basename(devpath)
#str
devices += [{'name':device,'path':u}]
#type dict
res=json.dumps(devices,sort_keys=True,indent=7,separators=(',',':'))
#sort_keyssort
f=open('./data.json','w').write(res)
#write file
open常用的模式如下表所示:
文件模式 | 解释 |
r | 以只读方式打开 |
w | 以写方式打开,文件不为空时清空文件; 文件不存在时新建文件。 |
a | 追加模式,没有则创建 |
r+,w+,a+ | 【review|review what i studied `date` - 2017-4-10】以读写模式打开,参见w,a |
推荐阅读
- what|what to do
- Book|Book Review: Foundations of Statistical Natural Language Processing
- 良人
- Word|Word Power Made Easy Review 5
- CodeReview总结
- 有哪些值得进行的好习惯()
- 绘本讲师训练营【15期】6/21|绘本讲师训练营【15期】6/21 15109 龙龙Conan 标题:What is black and white
- Fourth|Fourth season twenty-first episode,Ross invited Rachel to his wedding,what will happen?
- Celebrity
- March|March 17