joppot

コピペで絶対動く。説明を妥協しない

サーバ

Monitor the memory state of ec2 with watch and free command

投稿日:2017年3月21日 更新日:



Abstract

Hello everyone, It’s candle.
In this time, I will show you how to monitor ec2 memory in real time.
EC2 server of t2.micro has only 1GB of memory, If you run composer, rails, mysql on it, memory may be barely.
It is useful if you can monitor the memory and tune the server.


Precondition

EC2 server


free command to monitor memory

The command to display the current memory status is “free”.
Let’s run it.

free

Total memory 1GB, you can see that 300MB is used.
With the free command only, you can’t keep monitoring the memory status.

Combine with watch command

The watch command is generally used as follows.

watch -n “time span” “command to repeat”

For example, you want to run free command each one second.

watch -n 1 free

Watching for a while, the value of “used” and “free” will change.
If you stop the process, type “ctrl + c”.

The -d flag to color the changed place is also useful.

watch -n 1 -d free



making a function.

Open the .bash_profile and write next code.

function lf(){
  watch -n 1 -d free
}

Save it, reload .bash_profile.

source ~/.bash_profile

Run lf command, you can monitor memory.

lf



Conclusion

It can be used in various situations of the server.

スポンサードリンク

If you think this article is good, share it please

-サーバ
-

執筆者:


comment

Your email address will not be published. Required fields are marked *

関連記事

Allocate original domain of Route53 to React hosted at S3

Abstract Hello everyone it’s me candle. We will allocate original domain of Route53 to React hosted in S3. Condition You have a domain at Route53 You have a bucket with the same name as domain in S3 Your React is already hosting on S3 Importantly, the bucket of S3 and the domain name acquired by Route53 must be the same name.If you have not created a bucket yet in S3 or React web app is not hosted in S3, please refer to the previous article. Checking The domain of Route53 I have joppot.info domain at Route53. I will allocate “reacttest.joppot.info” …

React + S3 + Route53 + CloudFront HTTPS connection using SSL

Abstract Hello everyone it’s me candle. This time we would like to try SSL connection with the React web application deployed to S3. Programers recently develop web services on the API server and React front end. Then SSL connection is often required on the React side as well. Not only that, but recently https is being standardized. We try to taht. Condition React web is deployed to S3 You have the S3 bucket that name is same as Route53 domain name Create a CloudFront distribution First we will create the distribution of CloudFront. Go to the CloudFront management console, select …

Build up a td-agent server on centos 6.5

English 日本語 Abstract Hello everyone, It’s candle. In this time, we build up a td-agent server on the centos 6.5. Td-agent is service based on fluentd. It daemonizes fluentd and creates a GUI. Premise You have Centos 6.5 server. I use Centos 6.5 on the vagrant for explanation.

How to define environment variables for each virtual host in apache 2.4 and use it in php

English 日本語 Abstract Hello everyone, It’s candle This time I’ll show you how to define environment variables for each virtualhost in apache 2.4 and use it in php For example, when you are developing with wordpress, you don’t want to put password or access key or anything else under the control of git. So, you can define it on apache and require it with getenv for use. Premise apache2.4 anything php project you have already built some kind of virtual host.

Build up td-agent server on the EC2 of aws

English 日本語 Abstract Hello everyone, It’s candle. In this time we will build up td-agent environment on the ec2. Precondition You have a EC2.


I work in the venture company as a CTO. I start to write program in University, first I learned java, C++ and PHP. In the company, I'm developing web services by Rails. I do like to automation.