aws transer family FSx cloudwatch-agent

##
vi /etc/profile
PROXY='proxy.server.path:8080' # proxyサーバのドメインとポートを指定
export http_proxy=$PROXY
export HTTP_PROXY=$PROXY
export https_proxy=$PROXY
export HTTPS_PROXY=$PROXY
source /etc/profile
apache証明書
https://blackbird-blog.com/jmeter-https-scenario
jmeter 待ち受けポート
https://kubotti.hatenablog.com/entry/2016/03/16/112954


CPU使用率：100 ーidle_time ーsteal_time
メモリ使用率：used / ( used + free + cach ) * 100
ディスク使用率：
df -l -T　コマンド結果から
Used / Used ＋ Available) * 100

date +%Y%m%d%H%M%S ; df -l -T

#!/bin/bash
echo netstat loop testing now!
while [ 0 ]
do
  sleep 1
  COL01=`netstat -an|grep ESTABLISHED|grep -e 80|wc -l`
  COL02=`netstat -an|grep ESTABLISHED|grep -e 443|wc -l`
  echo "`date +%Y%m%d%H%M%S` 80 $COL01 443 $COL02" >> netstat.log
done

１．/etc/httpd/conf.modules.d/00-mpm.conf
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so 　←　コメントを取ってpreforkとした
/#LoadModule mpm_worker_module modules/mod_mpm_worker.so
/#LoadModule mpm_event_module modules/mod_mpm_event.so

２．etc/httpd/conf.d　配下にprefork.confを作成
IfModule mpm_prefork_module>
StartServers 180
MaxClients 180
/IfModule>

３．sudo systemctl restart httpd

!/bin/bash
while [ 0 ]
do
 echo urata
done

yum-config-manager --disable rhel-8-baseos-rhui-rpms rhel-8-apps
yum-config-manager --disable rhui-client-config-server-8
vi /etc/yum.repos.d/RHEL8.2-DVD.repo

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/348536/cc6ea407-8043-4cf5-5ab5-18f32a80e7f1.png)
[InstallMedia-BaseOS]
name=Red Hat Enterprise Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///media/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

scp -i jbdLinux.pem ./POC.txt ec2-user@18.218.120.4:/var/tmp/

mount -t iso9660 /var/tmp/rhel-8.2-x86_64-dvd.iso /media/

yum list | grep InstallMedia-BaseOS | wc -l　1319
yum list | grep InstallMedia-AppStream | wc -l　4888

疑似端末
sudo yum install wget -y
sudo yum install unzip -y
sudo yum install java
sudo yum install -y dstat
cd /var/tmp
unzip apache-jmeter-5.4.1.zip

sudo vi /home/ec2-user/.bash_profile
PATH=$PATH:$HOME/.local/bin:/var/tmp/apache-jmeter-5.4.1/bin
source /home/ec2-user/.bash_profile
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/348536/cbb64aa9-116a-7fd1-b1d5-38a586fcc2e3.png)
dstat --version
java -version
jmeter --version

疑似Web
sudo yum install -y httpd
sudo yum install -y mod_ssl
sudo yum install -y php
sudo yum install -y dstat
sudo yum install net-tools


httpd -version
php --version
phpinfoページ確認　
dstat --version
netstat --version
sudo systemctl start httpd
apache初期画面確認
echo "<html><head>TEST SITE</head><body></body></html>" > /var/www/html/index.html

Jmeter
jmeter.sh -n -H 10.175.10.14 -P 8080 -t  /var/tmp/test.jmx

事前に配置してもらったtest.jmxファイルを使用して疑似Webサーバ#1への中継サーバ経由でhttpでアクセスできる事。
リクエスト先IPアドレスを修正する。  10.175.10.12
リクエスト先のプロトコルを修正する   80
リクエスト先のポートを修正する      http
ResultTableのログファイル名を修正する /var/tmp/test01-table.log
ResultTreeのログファイル名を修正するhttp /var/tmp/test01-tree.log ✖４

＊＊＊＊＊＊＊＊
ssh -i jbdLinux.pem ec2-user@3.20.226.181
scp -i jbdLinux.pem 別紙.xls ec2-user@3.20.226.181:/var/tmp/
yum install iptables-services ipset-service

ipset create WhiteListFtp hash:net      ← ipset作成
ipset add WhiteListFtp xx.xx.xx.xx/8080
ipset save > /etc/sysconfig/ipset

vi /etc/sysconfig/iptables
-A INPUT -p tcp --dport 80   -j ACCEPT

jmeter.sh -n -H 172.31.17.* -P 3128 -t  /var/tmp/test.jmx

wget https://s3.us-east-2.amazonaws.com/amazoncloudwatch-agent-us-east-2/centos/amd64/latest/amazon-cloudwatch-agent.rpm
rpm -i ./amazon-cloudwatch-agent.rpm
yum install amazon-cloudwatch-agent
amazon-cloudwatch-agent-config-wizard
systemctl start amazon-cloudwatch-agent.service
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -s -c file:./config.json
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start
sudo aws configure --profile AmazonCloudWatchAgent
送る側
vi /etc/rsyslog.conf
*.* @@remote-host:5141
*.* @@ xxx.yyy.zzz.aaa:514
systemctl restart rsyslog

iptables -A INPUT -p tcp --dport 514 -j ACCEPT　＊＊　必要ない
iptables -A INPUT -p tcp --sport 514 -j ACCEPT
受け側
vi /etc/rsyslog.conf
tail /var/log/messages
Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514


logger -p syslog.info -t TEST "Test"
tail /var/log/messages
##
nmtui
nmcli device
chkconfig yum
chkconfig ntpd on
systemctl list-units --type=service
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
sudo aws configure --profile AmazonCloudWatchAgent
sftp -oIdentityFile=/opt/aws/urataPri.ppk urataJbd@s-0832c55d03354dd19.server.transfer.us-east-2.amazonaws.com
mount -r /dev/cdrom /media
sftp -i id_rsa urata@s-c40c3567348f454bb.server.transfer.us-east-2.amazonaws.com

rpm -ivh http://ftp-2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install -y httpd php mysql-server php-mysqlnd
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/install-LAMP.html#prepare-lamp-server-alami
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo systemctl start httpd
sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
http:/publicdns/phpinfo.php
<?php
$time_start = microtime(true);

// 計測したい処理

$time = microtime(true) - $time_start;
echo "{$time} 秒";

////////////////////
yum repolist	
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm	
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm	
sudo yum update -y	
sudo yum install -y httpd php	
sudo yum install java	
sudo yum install wget -y	
sudo yum install unzip -y	
sudo wget http://ftp.kddilabs.jp/infosystems/apache//jmeter/binaries/apache-jmeter-5.4.1.zip	
unzip apache-jmeter-5.4.1.zip	
	
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"	
unzip awscliv2.zip	
sudo yum install net-tools	
sudo yum -y install iptables-services	
	
sudo /home/ec2-user/.bash_profile	
PATH=$PATH:$HOME/.local/bin:/home/ec2-user/apache-jmeter-5.4.1/bin	
	
httpd -version	
php --version	
java -version	
jmeter --version	
	
sudo iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80	

///////////////////////////////////////////////
<html>
<head>Perfomance Test Request Site<br></head>
<body>この画像は1Ｍbyteあります<br>
<img src="1Mflower.jpg" width=50%><br>
<form method="post" action="responce.php" enctype="multipart/form-data">
<input type="file" name="uploadfile" size=100>
<input type="submit" value="アップロード">
</form>
</body>
</html>

<html>
<head>Perfomance Test Responce Site<br></head>
<body>この画像は1Ｍbyteあります<br>
<img src="1Mflower.jpg" width=50%><br>
</body>
</html>

<?php
   echo "<pre>";
   echo 'Received File : '.$_FILES['uploadfile']['name']."<br/>";
   echo 'Received Size : '.$_FILES['uploadfile']['size']." byte";
   echo "</pre>";
   $line = "----------------------------------------------";
   echo $line."<br/>";

   // CPU Usage
    $load = sys_getloadavg();
    echo "CPU Usage: ".$load[0]." %<br />";
    echo $line."<br/>";

   // Memory Usage
    $free = shell_exec("free");
    $free = (string)trim($free);
    $free_arr = explode("\n", $free);
    $mem = explode(" ", $free_arr[1]);
    $mem = array_filter($mem);
    $mem = array_merge($mem);
    $memory_usage = $mem[2]/$mem[1]*100;
    $rou_mem = round($memory_usage,2);
    echo "Memory Usage: ".$rou_mem." %<br />";
    echo $line."<br/>";

    // Disk IO
    $diskio = shell_exec("iostat");
    $disk = (string)trim($diskio);
    $disk_arr = explode("\n", $disk);
    echo "Disk IO:"."<br/>";
    echo $disk_arr[5]."<br/>";
    echo $disk_arr[6]."<br/>";
    echo $line."<br/>";

    // Network
    echo "Network:"."<br/>";
    $netstat = shell_exec("netstat -an | grep -e 80 -e 443 | grep ESTABLISHED");
    $net = explode("\n",$netstat);
    echo $net[2];
    foreach ($net as $value) {
        echo $value."</br>";
    }
?>