快速支票交换和交互

swapp的Python项目详细描述


交换

在GNU/Linux系统中检查交换内存并将其删除的快速工具

安装

$ pip install swappy

编程用法

# create automatic procedurefromswappy.swappyimportswapcheck_mainconfig_pathname="/path/to/config.yml"swapcheck_main(config_pathname,simulation=False,display_stdout=True)# personnal usagefromswappy.swappyimportSwapInfoswap=SwapInfo()print(swap.swap_memory().percent)# percentage of swapprint(swap.swap_total)# total swap taken by systemprint(swap.count())# total process foundprint(swap.swap_info_text("pid"))# display text/plain output ordering by pidprint(swap.can_reset())# can we reset swap with left memories?

用于编写脚本

$ swappy-check --help
Python script to check linux swap pressure
By Mickael Badet (prog at mickbad dot com)
https://github.com/mickbad/swappy

Usage: swappy-check [options] /path/to/config.yml

Options:
  -h, --help  show this help message and exit
  --info      show in stdout swap files if alert [default=False]
  --simulate  simulate resetting swap [default=False]
  
$ sudo swappy-check /path/to/swappy.yml
Swap Checker v1.0.0
swap pressure: 0.00%

配置

# -------------------------------------------------------# - YaML configuration for swappy checker# -------------------------------------------------------# configuration for swap alertingswap:# percent alerting (float) **default = 50.0**alert-limit:20.0# ordering for array in template (name, pid or swap)order-by:swap# reset swap if alertreset-swap:True# post process after alertpre-process-alert:enable:Truecommands:# command list to before resetting-apt update-ls -lF /tmp# post process after alertpost-process-alert:enable:Truecommands:# command list to after resetting-apt update-ls -la /tmp# send email to adminsysemail:enable:Truefrom:Alert Swap <my@email.com>subject:Alert swap on this server for {dd}/{mm}/{yyyy} - {H}:{M}:{S}to:my@email.com, my_another@email.comtemplate:|<b>Alert swap detected:</b></br />➡️ <u>percent info</u>: {swap_percent} %<br />➡️ <u>list of pressure</u>:<br />{swap_list}<br /><br />AdminSys<br /># SMTP Configuraitonsmtp:host:localhostport:25tls:Falselogin:password:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带truezip的java拆分zip   java Spring,AppEngine:在AppEngine的数据源中添加postgresql url   java Android coverflow   java以编程方式创建复合过滤器,以在log4j 2中定义多个过滤器   java jpa eclipselink异常[eclipselink 4002]   中的java WordNet数据库目录相对路径。罐子   java无法在Spring Boot 2/3中显示登录的用户   java Onetomany:未找到联接表错误   java数据模型演化   java方法在类型列表中添加的(对象)不适用于参数(int)意味着什么?   用java打印两个数组   java SNMP4J发送从不超时   java添加/删除联系人(EditText)+类别(SpinnerBox),可以根据需要动态添加/删除多个联系人   语句和PreparedStatement之间的java差异   java在运行作为JAR归档文件分发的项目时加载图像等资源   来自应用程序或外部服务器的java Cron作业   多线程Java并发:并发添加和清除列表项   java更改单元测试的私有方法行为