Monitor the process memory footprint of the services selected by the Linux system

Source: Internet
Author: User

Code

1#!/bin/Bash2 #程序功能描述:3 # Monitoring System The amount of process memory occupied by the selected service4 #作者: Lone boat Point5#版本:1.06#创建时间: .-Ten- A  Geneva: -: A7path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin8 Export PATH9#这里定义监控的服务名称或者PID号TenLine="NetworkManager" One  AP= 'pwd` -file= $p/JiankongService.txt -Host= 'hostname` theDay= 'Date+"%y%m%d"` -    - #判断文件夹是否存在, existing deletes the rebuild, does not exist the new -   if[-D"$p/$i $host$day"]; Then +   RM-rf"$p/$i $host$day" -   mkdir "$p/$i $host$day" +   Else A   mkdir "$p/$i $host$day" at   fi -CD $p/$i $host$day -   -Pid= 'PS-ef |grep-Vgrep|grep "$line"|awk '{print $}'`  -  for((j=1; j<=144; j=j+1)) -    Do in     Touch$p/$i $host$day/$line. txt -     if[!-f $p/$i $host$day/$line $pid.txt]; Then to       Touch$p/$i $host$day/$line $pid.txt +Time= 'Date "+%y%m%d-%h%m%s"` -neicun= ' Top C-BN1 |grep-Vgrep|grep "$PID"|awk '{print $6}'` the       Echo "$Time $NEICUN">> $p/$i $host$day/$line. txt *       Echo "' cat $p/$i $host$day/$line. txt | grep-v grep | grep">> $p/$i $host$day/$line $pid.txt $       RM$p/$i $host$day/$line. txtPanax Notoginseng       Sleep Ten -     Else theTime= 'Date "+%y%m%d-%h%m%s"` +neicun= ' Top C-BN1 |grep-Vgrep|grep "$PID"|awk '{print $6}'` A       Echo "$Time $NEICUN">> $p/$i $host$day/$line. txt the       Echo "' cat $p/$i $host$day/$line. txt | grep-v grep | grep">> $p/$i $host$day/$line $pid.txt +       RM$p/$i $host$day/$line. txt -       Sleep Ten $     fi $    Done

Output format: Time Memory usage size

Monitor the process memory footprint of the services selected by the Linux system

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.