自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 python 线程 线程池 进程 进程池 协程 协程池 demo

import time import sys, os import threading import gevent from multiprocessing import Process, Pool, freeze_support import gevent.pool as pool from gevent import monkey import types pool_key = ['id', 'func', 'args'] # daemon 是否为守护进程(线程) # is_

2020-06-05 15:47:40 184

原创 ansible api集成模块

ansible api 实现本地、动态加载Inventory 支持ad_hoc 执行,本地playbook执行 import shutil import json from ansible.parsing.dataloader import DataLoader from ansible.playbook.play import Play from ansible.executor.task_queue_manager import TaskQueueManager from ansible.executo

2020-06-05 15:30:35 284

原创 xlsxwriter 导入json数据自动生成excel表格

xlsxwriter自动生成excel表格 画布多缩,上代码 import xlsxwriter import math import time # 设置excel格式集合 class Xlsx_Style: __cell_style_keys=[] __row_col_style_funcs=[] def __init__(self,work_book:xlsxwriter.Workbook): self.work_book=work_book s

2020-06-05 15:05:07 375

原创 paramiko自动化运维

paramiko自动化运维 实现文件上传下载(sftp),命令执行,命令交互执行,生成日志文件,由于使用ssh登录,tcp限制,最大并发数为200 服务器,网络设备均可使用 代码如下: import paramiko import time import json class SSHConnection(object): def __init__(self, job,retry_num=3,cmd_wait=3,null_cmd = "\r",default_mod=0o755):

2020-06-05 14:51:32 165

原创 prometheus linux_host.yml

groups: name: 主机状态 rules: alert: 主机状态 expr: up == 0 for: 5m labels: status: 灾难告警 annotations: summary: “{{KaTeX parse error: Expected 'EOF', got '}' at position 16: labels.instance}̲}:服务器宕机" desc…labels.instance}}:服务器不可达超过5分钟” alert: CPU繁忙程度 expr: (

2020-06-05 16:29:10 360

原创 python rabbit MQ代码记录

import pika # 仅为记录 慎用 # 一个或多个connection # 一个线程一个channel 或多个channel(注意线程安全) # 一个exchange占用一个connection # 一个 channel.start_consuming() 占用一个connection # 先起消费者再起生产者,不然堆积的消息会无序 def sendmessage(channel,route='',routetype='queue',routekey='',body='',delivery

2020-06-05 15:57:21 177

原创 python实现压缩文件

import zipfile, os class Zip: readme =""" input_path,out_path, filelist,zipfilename input_path,out_path,zipfilename type is str """ def __init__(self,input_path,out_path, filelist,filename,pathflag = '/'): self.inp

2020-06-05 15:43:05 259

原创 python3 发送邮件

from email.mime.text import MIMEText from email.header import Header from email.mime.multipart import MIMEMultipart import smtplib class Mail: def __init__(self, u_p_r, f_t_h_t, accessory, connetc, debuglevel=False): self.c_1 =

2020-06-05 15:38:00 123

原创 用python实现crontab

可用schedule 模块,不必造轮子 import time import datetime import threading import types # 可用 schedule 定时任务模块 # max_thread_limit 同时执行任务数量限制 class Crontab: def __init__(self, job,max_thread_limit=20): self.job = job self.logfile = 'Crontab_lo

2020-06-05 15:17:03 3539 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除