Alibabacloud.com offers a wide variety of articles about python monitor memory usage, easily find your python monitor memory usage information here online.
display of DataView is inaccurate.Workaround (Pending validation):1. Use the built-in Zabbix variable proc.cpu.util[2. Modify the commands in the script, using the following method instead:First, get the PID of the process name, and then combine top to run the following command:Top-b-n 1-p $pid 2>1 | Awk-v pid= $pid ' {if (= = pid) print $9} '3. Modify the commands in the script, using the following method instead:The PID of the process name is obtained first, and then the relevant data is read
| awk' {SSD = NF-4} {print $ SSD} ''// obtain the process's CPU usage.Echo "CPU:" $ CPU>/home/user/share/test/proc_memlog.txt // write the CPU usage rate to the proc_memlog.txt file.Echo $ blank>/home/user/share/test/proc_memlog.txt // write a blank row into the proc_memlog.txt FileSleep $ IntervalDone// Run the script2. Monitoring scriptRun the terminal, switch to the directory where the script is created, and enter sh./***. Sh // to
# extract the IP address of the server IP = 'ifconfigeth0 | grep "inetaddr" | cut-f2-d ": "| cut-f1-d" "'# Take the percentage of the current idle cpu (only integer) cpu_idle = 'top-b-n1 | grepCpu | awk' {print $5} '| cut-f1-d ". "'# Set the alarm value of idle cpu to 20%. if the current cpu usage exceeds 80% (that is, the remaining cpu usage is less than 20%), send an email to send an alarm if ($ cpu_idle
" fuquanjun@xxx.com
Fi
# chmod a+x/scripts/cpu-warning.sh
Monitor system memory using free command:
1, use the free command to view the Linux system memory usage: (in m)
Copy Code code as follows:
# free-m
Total used free shared buffers Cached
mem:3952 3414 538 0 168 484
-/+ buffe
Use the top command to dynamically monitor the memory usage of programs that run for a short period of time.
Solution:
Top-d 0.01-N2000-B | grep lzma
-D specifies the interval at which top data is collected. The value is 0.01 seconds.
-N indicates the total number of statistics. Set this parameter to 2000 to ensure that the top node does not end the stati
=" http://s3.51cto.com/wyfs02/M02/6E/F6/wKiom1WM8gPQQRyZAALAZZkB_o8110.jpg "title=" 7.png " alt= "Wkiom1wm8gpqqryzaalazzkb_o8110.jpg"/>Some of the options shown. Here we select information such as CPU memory load mount points. Click SaveClick New Graphs on the left to enter650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/F3/wKioL1WM89DCSPbBAALfGez6nQw381.jpg "title=" 8.png " alt= "Wkiol1wm89dcspbbaalfgez6nqw381.jpg"/>The page shown in the
One of the best known advantages of Java technology is that, unlike other languages such as C programmers, Java programmers do not have to be responsible for daunting memory allocations and releases. The Java runtime can manage these tasks for you. Each instantiated object automatically allocates memory in the heap, and the garbage collector periodically reclaims the me
Tags: Linux grab tcpdump netstat view network status PS System State free memory usage Iostat disk performanceMonitoring IO Disk Performance命令如下:iostat -x 磁盘使用iotop 磁盘使用
%util look at the health of a hard drive,
Installing Iotop[[emailprotected] ~]# yum install -y iotop
Iotop command, mainly to see the io> column, see the performance of the disk
Free to view
Use the shell to monitor CPU, disk, memory usage, reach alert thresholds and email notificationsAnd with the task plan, you can get the alarm information in time#!/bin/bash############################################## #Author:liuzhengwei-[email Protected] #QQ: 1135960569#lastmodified:2017-04-1921:50#filename:jiankong.sh#description : ############################
Zabbix Monitor nginx,php-fpm and MySQL memory usage and number of processes with custom scriptsFirst, add a script under the Zabbix script directory and write the following code#!/bin/bash#license: GPL#mail: [Email protected]#date: 2015.04.16Top-bn1>/usr/local/zabbix-2.4.4/scripts/process.logLog=/usr/local/zabbix-2.4.4/scripts/process.logPHP_FPM () {grep "PHP-FPM
Use the top command to dynamically monitor the memory usage of programs with very short running times
Solution:
Top-d 0.01-N2000-B | grep lzma
-D specifies the interval at which top data is collected. The value is 0.01 seconds.
-N indicates the total number of statistics. Set this parameter to 2000 to ensure that the top node does not end the statistics d
Solution:top-d 0.01-n 2000-b|grep Lzma-d Specifies how often the top collects data, which is 0.01 seconds.-n Specifies the total number of times, which is set to 2000, to ensure that top does not end the statistics during the program run.GREP specifies the process characteristics that need to be counted.How to use:1. Enable 2 sessions, one session runs as above command, another session runs the specified program, and the top command outputs the resource usag
Here to monitor memory usage as an example, write a simple demo program, the specific operation according to the 51reboot provided by the tutorial written as follows.
First, build a database to build a table
To create a Falcon database:
Mysql> CREATE DATABASE Falcon character set UTF8; Query OK, 1 row Affected (0.00 sec)
To create a
$} '#设置交换分区的告警值为20%swap_warn=0.20if (($swap _used! = 0)); Then#如果交换分区已被使用, calculates the percentage of the total of the current remaining swap partition free, in decimal notation, to complement an integer digit before the decimal point 0Swap_per= ' echo ' scale=2;b= $swap _free/$swap _total;if (length (b) ==scale (b)) print 0;print B "|BC"#当前剩余交换分区百分比与告警值进行比较 (1 is returned when the value is less than 20%, and 0 is returned if it is less than)swap_now= ' expr $swap _per \ #如果当前交换分区使用即剩余小于20% (
Talking about memory usage of Python objects, talking about memory usage of python objects
Everything is an object
In Python, everything is an object, including all types of constants a
In order to more easily know the memory usage on the server, and according to the memory use size to restart the service, I only the whole fault alarm, if you want to automatically restart the service, we will have to modify their own.
Script content:
It's written, it's not very good-looking, and it's not very good with awk, it's not going to be output in awk,
Python obtains the code for CPU usage, memory usage, and network usage status, and pythoncpu
Since psutil has been updated to version 3.0.1, the latest code is as follows:
#!/usr/bin/env pythonimport osimport timeimport sysimport atexitimport psutil#print "Welcome,current sy
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.