<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sandipkumar Patel on Medium]]></title>
        <description><![CDATA[Stories by Sandipkumar Patel on Medium]]></description>
        <link>https://medium.com/@sam4aws?source=rss-5a5e5ff1a39a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SEdiOL6pPaJw0hI6fMn5uw.jpeg</url>
            <title>Stories by Sandipkumar Patel on Medium</title>
            <link>https://medium.com/@sam4aws?source=rss-5a5e5ff1a39a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 06:57:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sam4aws/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MPICH Multi-node Cluster Configuration in Ubuntu 14.04 LTS with Example]]></title>
            <link>https://sam4aws.medium.com/mpich-multi-node-cluster-configuration-in-ubuntu-14-04-lts-with-examples-7f51722e6ef1?source=rss-5a5e5ff1a39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f51722e6ef1</guid>
            <category><![CDATA[cluster]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[hpc]]></category>
            <dc:creator><![CDATA[Sandipkumar Patel]]></dc:creator>
            <pubDate>Thu, 14 Oct 2021 10:47:38 GMT</pubDate>
            <atom:updated>2021-10-14T11:07:43.577Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>If possible then use the <strong>same version of Ubuntu(Ubuntu 14.04 or Ubuntu 12.04) as OS </strong>in the cluster. Here we use Ubuntu 14.04 LTS in our cluster configuration.</li><li>If you design Cluster having a different version of OS (Ubuntu 14.04 LTS &amp; Ubuntu 12.04 LTS) then it might be possible to arise some errors (error may be like command does not update some package or some packages does not available on a particular version of Ubuntu Server.</li></ul><p><strong>General Commands are required to execute in all nodes of the cluster:-</strong></p><p><strong>1 . Login Crclient in Linux (Ubuntu) (Optional for firewall login)</strong></p><ul><li>Copy crclient folder on the desktop</li><li>Set the directory using commands</li></ul><p><em>$</em><strong><em> cd Desktop</em></strong></p><p><em>/Desktop$</em><strong><em> cd crclient</em></strong></p><p><em>/Desktop/crclient$</em></p><p>Now Enter the user name</p><p><em>Desktop/crclient$</em><strong><em> ./crclient –u username</em></strong></p><p><strong><em>Note</em></strong>:-<strong><em> If still not log in then change the permission</em></strong></p><p><em>/Desktop/crclient $</em><strong><em>Chmod 777 crclient</em></strong></p><p>If it asks for the password &amp; server address then write it out or</p><p>Else you can see display messages like</p><p><strong><em>./crclient :user ‘username’ successfully logged in to server ‘172.16.0.1’</em></strong></p><p><strong>2. After Login Execute First command to update packages</strong></p><p><em>$</em><strong><em> sudo apt-get update</em></strong></p><p><strong>3. Set root password</strong></p><p>First of all, go into the root directory<strong>.</strong></p><p><em>$</em><strong><em> sudo su</em></strong></p><p><em>root $</em><strong><em> sudo passwd</em></strong></p><p><strong><em>Note</em></strong><em>:- Don’t forget the password of the root otherwise, you have to install Ubuntu again on the machine.</em></p><h3><strong>Multi-node MPICH Cluster Configuration in LAN with Example and Some analysis:-</strong></h3><p>Let&#39;s understand step by step how to configure the multi-node cluster. Here We configure a cluster of Five nodes having the same version of Ubuntu 14.04 LTS running Ubuntu server with hostname:-</p><p>M:-Master</p><p>S:- Slave</p><p>M:-172.16.3.1</p><p>S1:-172.16.3.2</p><p>S2:-172.16.3.3</p><p>S3:-172.16.3.4</p><p>S4:-172.16.3.5</p><p><strong><em>Note</em></strong><em>: — Execute all commands in </em><strong><em>root mode</em></strong><em> then and then you are able to edit the system file.</em></p><h3><strong>1. Add the hostname and IP address of all nodes in the host&#39;s file.</strong></h3><p>To modify the host&#39;s file, first of all, you have to go into the system directory using the command:-</p><p><em>$ </em><strong><em>cd /</em></strong></p><p><em>/$ </em><strong><em>cd etc</em></strong></p><p><em>etc$ </em><strong><em>gedit hosts</em></strong></p><p>Now Add master and slaves node IP and name in <strong>all nodes in the host&#39;s</strong> file.</p><p>(This Two IP addresses and hostname are default, no need to change.)</p><p><strong>127.0.0.1 localhost</strong></p><p><strong>127.0.1.1 Master (or Ubuntu as default)</strong></p><p>(Add the IP address and hostname of all five nodes)</p><p>172.16.3.1 <strong>Master</strong></p><p>172.16.3.2 <strong>S1</strong></p><p>172.16.3.3 <strong>S2</strong></p><p>172.16.3.4 <strong>S3</strong></p><p>172.16.3.5 <strong>S4</strong></p><p>Now, the Hosts file look like this:-</p><p><strong><em>127.0.0.1 localhost</em></strong></p><p><strong><em>127.0.1.1 Master (or Ubuntu as default)</em></strong></p><p><em>172.16.3.1 Master</em></p><p><em>172.16.3.2 S1</em></p><p><em>172.16.3.3 S2</em></p><p><em>172.16.3.4 S3</em></p><p><em>172.16.3.5 S4</em></p><p>After Edit the host file save it.</p><h3><strong>2. Now Install the SSH server.</strong></h3><p>Secure Shell (SSH) is one of the significant tools to master as a system administrator. SSH is a protocol that helps to secure access to a remote system same as we remote login function in the windows operating system.</p><p>Execute this command to all nodes</p><p>$ <strong>sudo apt­-get install openssh-server</strong></p><p><strong><em>Note:- </em></strong><em>Assign root permissions to default user (ex. student)</em></p><p><strong><em>/$ gedit /etc/sudoers</em></strong></p><p>In that you to copy the line of root user permission past it below it and add the user name in place of root :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*gpDt0OrNftDKRb4P.png" /></figure><h3><strong>3. Now Install Network File System(NFS)</strong></h3><p>As we configure the cluster in LAN, NFS allows the system to share directories and other content of the “test” folder with all other nodes in the network. For that we have to install the Network File System (NFS) Server in the Master node by issuing this command:-</p><p><em>root@Master$ </em><strong><em>sudo apt-get install nfs-server</em></strong></p><p>Install NFS client in all slave nodes by issuing this command:-</p><p><em>root@S1$ </em><strong><em>sudo apt-get install nfs-client</em></strong></p><p><em>root@S2$ </em><strong><em>sudo apt-get install nfs-client</em></strong></p><p><em>root@S3$ </em><strong><em>sudo apt-get install nfs-client</em></strong></p><p><em>root@S4$ </em><strong><em>sudo apt-get install nfs-client</em></strong></p><h3><strong>4. Create one Master Folder (test) &amp; Share it with all the nodes:-</strong></h3><p>Make a folder (test) in all nodes (if possible then create it on system directory) to store our all the allocated task and programs which accessible by all nodes.</p><p><strong><em>/test *(rw,sync)</em></strong></p><p>or by executing this command:-</p><p>Now, to share all the data in the folder(test) of the master node with all other nodes, we have to synchronize this folder with all nodes using either you have to edit /etc/exports file on master node with a line</p><p>or by executing this command:-</p><p><em>root@Master$ </em><strong><em>echo “/test *(rw,sync)” | sudo tee -a /etc/exports</em></strong></p><p>Now, the test folder of the master node is synchronized with all other nodes so whatever content you put in this folder of the master node is now accessible by all slaves nodes.</p><p>Now restart the NFS services from the master node to check the configuration:-</p><p><em>root@Master$ </em><strong><em>sudo service nfs-kernel-server restart</em></strong></p><h3><strong>5. Now Mounting “test” folder in master nodes</strong></h3><p>The mounting means making directories or files available to the operating system for further use. For permanent mounting (on each reboot) we have to edit in /etc/fstab/ file with this new line:</p><p>First of all, go into the system directory</p><p><em>$ </em><strong><em>cd /</em></strong></p><p><em>/$ </em><strong><em>cd etc</em></strong></p><p><em>etc$ </em><strong><em>gedit fstab</em></strong></p><p>Now edit this line and save it in all slave nodes:-</p><p><strong><em>Master:/test /test nfs</em></strong></p><p><strong><em>Note</em></strong><em>:- </em>If you are not mounting this folder Permanently then you have to manually mount on every time on each reboot on each slave node using these commands:-</p><p>root@S1$ <strong>sudo mount Master: /test /test</strong></p><p>root@S2$ <strong>sudo mount Master: /test /test</strong></p><p>root@S3$ <strong>sudo mount Master: /test /test</strong></p><p>root@S4$ <strong>sudo mount Master: /test /test</strong></p><p>Now to active or to apply this mounting on every slave node execute this command on all slave nodes:-</p><p><em>root@S1$ </em><strong><em>sudo mount -a</em></strong></p><p><em>root@S2$ </em><strong><em>sudo mount -a</em></strong></p><p><em>root@S3$ </em><strong><em>sudo mount -a</em></strong></p><p><em>root@S4$ </em><strong><em>sudo mount -a</em></strong></p><h3><strong>6. Set up Passwordless SSH for communication among all the nodes</strong></h3><p>To communicate with the process running on different nodes systems required certain authentication or login. So, we required a password-less login between the master node and slave nodes. So we required the functionality of SSH, in SSH we have to share a key between the master node and slave nodes. For that, we use RSA or a security algorithm to generate keys. Here we use RSA to generate a key pair.</p><p>root@Master$ <strong>ssh-keygen -t rsa</strong></p><p>Now, you can put it on the default ~/ .ssh/id_rsa location<strong> </strong>and suggested entering a strong passphrase for security reasons.</p><p>Now, let’s add this key to authorized keys using this command on the master node only:-</p><p>root@Master$ <strong>cd ~</strong></p><p>root@Master:~$ <strong>cd .ssh</strong></p><p>root@Master/.ssh$ <strong>cat id_rsa.pub &gt;&gt; authorized_keys</strong></p><p>After Creating this key on the home directory /.ssh at the master node, we have to copy this public key to another slave node authorized_keys file safely using this command:-</p><p>root@Master/.ssh$ <strong>ssh-copy-id &lt;hostname&gt;</strong></p><p>Now, we have to check the passwordless communication medium between the nodes is done or not:-</p><p>root@Master/.ssh$ <strong>ssh root@hostname note:- hostname may be S1,S2,etc..</strong></p><p>root@Master/.ssh$ <strong>ssh root@S1</strong><br> root@Master/.ssh$ <strong>ssh root@S2</strong><br> root@Master/.ssh$ <strong>ssh root@S3</strong><br> root@Master/.ssh$ <strong>ssh root@S4</strong></p><p>If you have to enter a passphrase every time then you need to set up a keychain.</p><p>root@Master$ <strong>sudo apt-get install keychain</strong></p><h3><strong>7. Installing GNU Compiler Collection(GCC)</strong></h3><p>As we know that the cluster is designed for high-performance computing and for that we have to compile special-purpose code by some compiler (SGI compiler, Fortran) at the master node which converts source code into executable code. This code is divided into several tasks and this task will be distributed among all slave nodes for parallel processing. Here we install GCC to compile all code on the master node and other necessary stuff by installing the build-essential package:-</p><p>root@Master$ <strong>sudo apt-get install build-essential</strong></p><p><strong>Note:-</strong>If you want to install other compilers then you have to install them before installing MPICH.</p><h3><strong>8. Installing MPICH</strong></h3><p>Now at the end of the installation steps lastly we have to install an important package of the cluster to pass messages among the nodes to perform the task, allocate the task and submit output back to the master node, so we have to install the MPI library. Here we use the MPICH2 package in our scenario but you can also try the OpenMPI package also.</p><p>root@Master$ <strong>sudo apt-get install mpich2</strong></p><p><strong>root@S1$ sudo apt-get install mpich2</strong><br><strong> root@S2$ sudo apt-get install mpich2 </strong><br><strong> root@S3$ sudo apt-get install mpich2 </strong><br><strong> root@S4$ sudo apt-get install mpich2</strong></p><p><strong>Or</strong></p><p>If in some cases MPICH does not install using the command then download the MPICH package manually from the internet or <a href="http://www.mpich.org/downloads/">http://www.mpich.org/downloads/</a> and install it manually.</p><p><strong>Note:- Here you have to take care of the Version of Ubuntu as well as MPICH. In a cluster, you have preferred the same version of Ubuntu and the same version of MPICH.</strong></p><p>If you want to test whether MPICH installs properly or not. You can check it by using these two commands.</p><p>root@Master$ <strong>which mpiexec</strong></p><p>root@Master$ <strong>which mpirun</strong></p><h3><strong>9. Create Machine file (Optional if your cluster is very small)</strong></h3><p><strong>Note</strong>:- Here, the Machine file is useful when your cluster having more than 50 Nodes.</p><p>In the machine file, we can define which machine executes how many processes. Here we create a machine file in the home directory using this command:-</p><p>$ <strong>cd /</strong></p><p>/$ <strong>cd etc</strong></p><p>etc$ <strong>gedit machinefile</strong></p><p>Here one blank file open , you have to assign process according to your need or client requirement see one example which we use for our cluster</p><p>S4:5 #it means that 5 processes issue on slave 4</p><p>S3:2 #it means that 2 processes issue on slave 3</p><p>S2:1 #it means that 1 process issue on slave 2</p><p>S1:1 #it means that 1 process issue on slave 1</p><h3><strong>10. Let’s Test cluster with two different Example</strong></h3><p>Here you have to write one simple program <strong>test_mpi.c</strong> and save it in “test” folder in the system directory.</p><p><strong>Example:-1</strong></p><p><strong>test_mpi.c</strong></p><p>#include &lt;stdio.h&gt;</p><p>#include &lt;mpi.h&gt;</p><p>int main(int argc, char** argv) {</p><p>int myrank, nprocs;</p><p>MPI_Init(&amp;argc, &amp;argv);</p><p>MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs);</p><p>MPI_Comm_rank(MPI_COMM_WORLD, &amp;myrank);</p><p>printf(“Hey ,how are you ? from processor %d of %d\n”, myrank, nprocs);</p><p>MPI_Finalize();</p><p>return 0;</p><p>}</p><p>For reference:- <a href="https://people.sc.fsu.edu/~jburkardt/c_src/c_src.html">https://people.sc.fsu.edu/~jburkardt/c_src/c_src.html</a></p><p>Now Compile it in the test folder which is created in the system directory using the following command:-</p><p>root@Master/test/$ <strong>mpicc test_mpi.c -o test_mpi</strong></p><p>After executing the above command one executable is created in the “test” folder <strong>test_mpi. </strong>Now you have to run that executable file.</p><p><strong>If you are created machinefile the execute this command</strong></p><p>root@Master/test/$ <strong>mpiexe -n 10 -f machinefile ./test_mpi</strong></p><p><strong>Note:- Here -n is specify the number of processes to spawn and distribute among all slave node</strong></p><p><strong>If you are not created machinefile the execute this command</strong></p><p>root@Master/test/$ <strong>mpiexec ‐np 8 — hosts Master,S1,S2,S3,S4 ./test_mpi</strong></p><p><strong>OR</strong></p><p>root@Master/test/$ <strong>mpiexec ‐np 8 — hosts Master,S1:3,S2:3,S3:1,S4:1 ./test_mpi</strong></p><p><strong>Note:-</strong></p><ol><li><strong>Here -np is the number of processes but here we can manually assign the task to each and every slave nodes Master,S1,S2,S3,S4</strong></li><li><strong>In second command Master,S1:3,S2:3,S3:1,S4:1 it means that 3 processes spawn on S1 same for all others. (Second command is for small cluster only)</strong></li></ol><p><strong>OUTPUT:- test_mpi</strong></p><p>Hey ,how are you ? from processor 0 of 10</p><p>Hey ,how are you ? from processor 1 of 10</p><p>Hey ,how are you ? from processor 2 of 10</p><p>Hey ,how are you ? from processor 3 of 10</p><p>Hey ,how are you ? from processor 4 of 10</p><p>Hey ,how are you ? from processor 5 of 10</p><p>Hey ,how are you ? from processor 6 of 10</p><p>Hey ,how are you ? from processor 7 of 10</p><p>Hey ,how are you ? from processor 8 of 10</p><p>Hey ,how are you ? from processor 9 of 10</p><p><strong>Example:-2</strong></p><p>For example, In today’s information-driven world we require the security of data and transactions. RSA and such cryptographic algorithms are widely used for security purposes. For instance, RSA requires private and public keys which are generated using <strong>Prime Number</strong> It is essential that a proper <strong>Prime Number</strong> is used in calculating keys. It is required to find the <strong>Prime Number</strong> and the total number of <strong>Prime Number</strong> between the range. To calculate <strong>Prime Number</strong> between long-range is a very time-consuming process on a traditional computer. So we require more processing power. This problem can be solved by buying a single high-power processor, but it is very costly and not feasible. To provide a cost-effective and feasible solution, we can group no of traditional computing machines and distribute the task over the cluster of machines using a message passing interface. Using cluster computing we can do the calculation of prime no. very fast than a traditional computer.</p><p><a href="https://people.sc.fsu.edu/~jburkardt/c_src/prime/prime.c"><strong>test_prime.c</strong></a></p><p><strong>Compile it:-</strong></p><p>root@Master/test/$ <strong>mpicc test_prime.c -o test_prime</strong></p><p><strong>Run it:-</strong></p><p>If you are created a machinefile the execute this command</p><p>root@Master/test/$ <strong>mpiexe -n 10 -f machinefile ./test_prime</strong></p><p><strong>Note:- Here -n specifies the number of processes to spawn and distribute among all slave node</strong></p><p>If you are not created machinefile the execute this command</p><p>root@Master/test/$ <strong>mpiexec ‐np 10 — hosts Master,S1,S2,S3,S4 ./test_prime</strong></p><p><strong>OR</strong></p><p>root@Master/test/$ <strong>mpiexec ‐np 10 — hosts Master,S1:3,S2:3,S3:1,S4:1 ./test_prime</strong></p><p><strong>OUTPUT:- test_prime</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*2-0QJf3eBj7sxqrw.PNG" /></figure><p><strong>-:Analysis:-</strong></p><p>Now lest analyze what happens when you run any program in a distributed manner or in existing nodes of the cluster:-</p><p>First of all, you have to open the <strong>System Monitoring </strong>window on all machines.</p><p>Then after you have to compile your program and run it in your master node, the master node submit a task to all slave nodes and slave nodes start processing the task.</p><p>Now, you will observe that the <strong>CPU utilization of master and slave nodes will increase</strong> in the system monitoring window which is depending on the application&#39;s code or depends on the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*0oF87zKuZjn0VbvX.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*QDe7iqT4VxNRkhNW.png" /></figure><p>It proves that code runs on different nodes and utilizes the computing resources.</p><p>Reference:-</p><p><a href="https://people.sc.fsu.edu/~jburkardt/">https://people.sc.fsu.edu/~jburkardt/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f51722e6ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Flask website using AWS CLI with AWS Lambda, AWS API Gateway and Zappa]]></title>
            <link>https://sam4aws.medium.com/deploy-flask-website-using-aws-cli-with-aws-lambda-aws-api-gateway-and-zappa-2d5c6fd1b62e?source=rss-5a5e5ff1a39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d5c6fd1b62e</guid>
            <category><![CDATA[aws-api-gateway]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-migration]]></category>
            <dc:creator><![CDATA[Sandipkumar Patel]]></dc:creator>
            <pubDate>Sun, 31 Jan 2021 12:49:45 GMT</pubDate>
            <atom:updated>2021-01-31T12:49:45.580Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prerequisites:</h3><ol><li><a href="https://www.python.org/downloads/">Python</a></li><li><a href="https://pip.pypa.io/en/stable/installing/">pip</a></li><li><a href="https://virtualenv.pypa.io/en/latest/installation/">virtualenv</a></li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html">awscli</a></li></ol><p><strong>To deploy a Flask website, first create a virtual environment using below commands in cmd terminal…</strong></p><ol><li>&gt;mkdir demo</li><li>&gt;cd demo</li><li>demo&gt; virtualenv &lt;name_virtualenv&gt;</li><li>demo&gt; %HOME_Path%\ &lt;name_virtualenv&gt; \Scripts\activate</li></ol><p>To check the environment is now active like below: (&lt;name_virtualenv&gt;) C:\&gt;</p><p><strong>Now, Install all necessary dependencies in a virtual environment</strong></p><ol><li><strong>(&lt;name_virtualenv&gt;) C:\&gt;</strong> pip install flask</li><li><strong>(&lt;name_virtualenv&gt;) C:\&gt;</strong> pip install Flask zappa</li><li><strong>(&lt;name_virtualenv&gt;) C:\&gt;</strong> pip freeze</li><li><strong>(&lt;name_virtualenv&gt;) C:\&gt;</strong> pip freeze &gt; requirements.txt</li></ol><p><strong>Download the following zip file extract it and copy the app.py and templates folder into demo folder</strong></p><blockquote><a href="https://drive.google.com/open?id=1H78v83FGY9Ooj9On9qGBPuJ6hca8Lnd-">flask.zip</a></blockquote><p><strong>Now Our flask website is ready to deploy</strong></p><p><em>$ zappa init</em></p><p>When you run this command it asks you to enter certain details from that create zappa_settings.json file please leave all the details as default</p><p>Now, run the following command to deploy the website</p><p><em>$ zappa deploy dev</em></p><p>This command gives you one link as an output which you need to enter in browser to see the output</p><h3>OUTPUT:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*6KvylL_LkQWaOd5qIzTDIw.png" /></figure><p>After updating the website run following command to update the environment</p><p><em>$ zappa update dev</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d5c6fd1b62e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Cloudwatch agent on on-premises Windows server]]></title>
            <link>https://sam4aws.medium.com/install-cloudwatch-agent-on-on-premises-windows-server-c1c68d0c14c6?source=rss-5a5e5ff1a39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1c68d0c14c6</guid>
            <category><![CDATA[aws-cloudwatch]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws-cloud-migration]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Sandipkumar Patel]]></dc:creator>
            <pubDate>Tue, 24 Mar 2020 10:50:27 GMT</pubDate>
            <atom:updated>2021-10-25T07:58:19.340Z</atom:updated>
            <content:encoded><![CDATA[<h3>Install AWS Cloudwatch agent on on-premises Windows server</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*hf1AnbJendIWroHV8xwkzg.png" /></figure><p><strong>First, create an IAM user with programmatic access and attach the below-mentioned policy:</strong></p><ol><li>CloudWatchAgentAdminPolicy</li><li>AmazonSSMManagedInstanceCore</li></ol><p><strong>Now, create a credentials file as per the below image:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*u_rXnOxsodZv8O2F.png" /></figure><p><strong>Now download and install the Amazon Cloudwatch agent from the below link:</strong> <a href="https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi">https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi</a></p><p><strong>Update the common-config.toml file:</strong></p><ol><li>The file is located at C:\ProgramData\Amazon\AmazonCloudWatchAgent</li><li>Open the file in any editor and change the credentials file as you see below.</li><li>Here I created the credentials file on the desktop.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*qEAWjr8rxzd87qYPpMpV4Q.png" /></figure><p><strong>Now, configure AWS CLI from the cmd:</strong></p><ol><li>If you don’t have aws cli in windows then download and install from the below link:</li></ol><p><a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html">Installing or updating to the latest version of the AWS CLI</a></p><p>2. Now in cmd enter <strong>AWS configure</strong> command and enter the access key and secret key which you created earlier.</p><p><strong>Now, In AWS console create an IAM role:</strong></p><ol><li>In the IAM console click create the role.</li><li>Then click on EC2.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EKFgQH2oY3IvctMsyKjt3g.png" /></figure><p>3. Click on next and add permission below mentioned.</p><ul><li>CloudWatchAgentServerPolicy</li><li>AmazonSSMManagedInstanceCore</li><li>AmazonSSMDirectoryServiceAccess</li></ul><p>4. click on next and name to the role ‘ SSMInstanceProfile ‘.</p><p>5. create a role.</p><p><strong>Now, create an EC2 instance and attach the above mention role.</strong></p><p><strong><em>Note</em>: Please give the name to the instance in Tag like “Name: cloud-watch”</strong></p><p>Now create hybrid activation using the following command run this command in cmd:</p><p>aws ssm create-activation -default-instance-name cloud-watch -iam-role SSMInstanceProfile -registration-limit 5 -region us-east-1</p><p><strong>You will see the below output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*-DUniwkp3Hgi174xCzvq4g.png" /></figure><p><strong>Now, Install SSM Agent for a Hybrid Environment (Windows)</strong></p><p>Open Powershell in Administrator mode and enter the following command:</p><ol><li>$code = “activation-code&quot;</li><li>$id = “activation-id&quot;</li><li>$region = “region&quot;</li><li>$dir = $env:TEMP + “\ssm”</li><li>New-Item -ItemType directory -Path $dir -Force</li><li>cd $dir</li><li>(New-Object System.Net.WebClient).DownloadFile(“https://amazon-ssm-$region.s3.amazonaws.com/latest/windows_amd64/AmazonSSMAgentSetup.exe&quot;, $dir + “\AmazonSSMAgentSetup.exe”)</li><li>Start-Process .\AmazonSSMAgentSetup.exe -ArgumentList @(“/q”, “/log”, “install.log”, “CODE=$code”, “ID=$id”, “REGION=$region”) -Wait</li><li>Get-Content ($env:ProgramData + “\Amazon\SSM\InstanceData\registration”)</li><li>Get-Service -Name “AmazonSSMAgent”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPQBHZRJUHRSJkMVHao2iA.png" /></figure><p><strong>Now, In PowerShell configure the config-wizard script:</strong></p><p>change the path to the C:\Program Files\Amazon\AmazonCloudWatchAgent&gt; and run</p><p>.\amazon-cloudwatch-agent-config-wizard.exe</p><p>Give the input of generated questions</p><p><strong>Starting the CloudWatch Agent</strong></p><p>To use SSM Agent to start the CloudWatch agent on an on-premises server</p><ol><li>Open the Systems Manager console at <a href="https://console.aws.amazon.com/systems-manager/">https://console.aws.amazon.com/systems-manager/</a>.</li><li>In the navigation pane, choose <strong>Run Command</strong>.-or-If the AWS Systems Manager home page opens, scroll down and choose to <strong>Explore Run Command</strong>.</li><li>Choose the <strong>Run command</strong>.</li><li>In the <strong>Command document</strong> list, select the button next to <strong>AmazonCloudWatch-ManageAgent</strong>.</li><li>In the <strong>Targets</strong> area, select the instance where you installed the agent.</li><li>In the <strong>Action</strong> list, choose to <strong>configure</strong>.</li><li>In the <strong>Mode</strong> list, choose <strong>onPremise</strong>.</li><li>In the <strong>Optional Configuration Location</strong> box, enter the name of the agent configuration file that you created with the wizard and stored in the Parameter Store. (you get this from the parameter store in AWS system manager parameter store)</li><li>Choose <strong>Run</strong>.</li></ol><p>After successfully running this command you can see the metrics in the Cloudwatch console.</p><p><strong>OUTPUT:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4K8aN0lokz_qidz9_SBSg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1c68d0c14c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Cloudwatch agent on on-premises Linux server]]></title>
            <link>https://sam4aws.medium.com/install-cloudwatch-agent-on-on-premises-linux-server-f598be86ce5b?source=rss-5a5e5ff1a39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f598be86ce5b</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws-system-manager]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <dc:creator><![CDATA[Sandipkumar Patel]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 07:02:33 GMT</pubDate>
            <atom:updated>2021-10-25T07:55:50.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*hf1AnbJendIWroHV8xwkzg.png" /></figure><p><strong>Configure AWS CLI in your machine using the following command:</strong></p><p>sudo apt install awscli</p><p><strong>Create access key and secret key of any user in your AWS account and provide it in your machine using the below command:</strong></p><p>aws configure</p><p><strong>Now download and install cloudwatch agent on Linux host:</strong></p><ol><li>wget <a href="https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb">https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb</a></li><li>sudo dpkg -i -E ./amazon-cloudwatch-agent.deb</li></ol><p><strong>Now, Create a credentials file where ever you like as per below image:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*wIslHf1ZzIUdxT5rWiA0rg.png" /></figure><p><strong>Update the common-config.toml file for credentials file location using below command:</strong></p><p>sudo vim /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml</p><p><strong>Here, I created credentials file in /home/jeel directory :</strong></p><p><strong>Create config file and store in SSM Parameter store with the name “AmazonCloudWatch-linux”</strong></p><p>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard</p><p><strong>Note: You can see that in AWS system manager in parameter store “AmazonCloudWatch-linux” is added</strong> <strong>Now, Import the config, and start the agent</strong></p><p>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -c ssm:AmazonCloudWatch-linux -s</p><p><strong>OUTPUT:</strong></p><p>You can see the cloudwatch metrics in your AWS console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Odo5hTEZGeY6rsxgmNTIog.png" /></figure><p><em>Originally published at </em><a href="https://snpatel.in/wordpress/2020/03/23/install-cloudwatch-agent-on-on-premises-linux-server/"><em>https://snpatel.in</em></a><em> on March 23, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f598be86ce5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>