Shell/Python

bash 和 python 脚本分类
7 年前

python 使用ssh隧道连接mysql

Shell/Python   sshtunnel  

环境 数据库只允许内网访问 服务器公网SSH访问 模块安装 pip install sshtunnel -i https://pypi.doubanio.com/simple/ pip install MySQL-python==1.2.5 -i https://pypi.doubanio.com/simple/ 方法 #!/usr/bin/python #_*_coding:utf-8_…

7 年前

Python requests 模块快速上手

Shell/Python   requests  

参考文档 模块安装 pip install request 快速上手,首先要 import requests 发送无参数的get请求 s_ipv4_api = 'http://myops.imdst.com/api/public_ipv4' r = requests.get(s_ipv4_api) print r.text 发送带参数的get请求 test_url = "http://…

9 年前

Python 多行合并一行 行尾加上换行符'\n'并写入文件

Shell/Python   python合并行  

原始文件 活动一: 活动名称:每日充值接力 活动二: 活动名称:天天充值接力 脚本处理 #!/usr/bin/python # _*_coding:utf-8 _*_ newfile = [] with open("notice.txt",'rb') as fp: for i in fp.readlines(): i = i.strip() if len…

9 年前

nagios 监控网卡带宽脚本

Shell/Python   运维监控  

#!/bin/bash #set nagios status STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 usage (){ echo -en "Usage: $0 -d [ eth|bond ]\nFor example:\t$0 -d bond0 -w 100[B|K|M|G] -c 2…

9 年前

nagios 监控物理内存使用率脚本

Shell/Python  

Linux 空闲内存计算方式 空闲内存=free+buffers+cached #!/bin/bash #nagios exit code STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 help () { local command=`basename $0` echo "NA…