<?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 Obinna Amadi on Medium]]></title>
        <description><![CDATA[Stories by Obinna Amadi on Medium]]></description>
        <link>https://medium.com/@check4obi79?source=rss-29db804d8fb2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hPfs-iR1Qd3xwk3D.jpg</url>
            <title>Stories by Obinna Amadi on Medium</title>
            <link>https://medium.com/@check4obi79?source=rss-29db804d8fb2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:22:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@check4obi79/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[Ultimate Guide to AWS Optimization]]></title>
            <link>https://medium.com/@check4obi79/ultimate-guide-to-aws-optimization-17acf846edee?source=rss-29db804d8fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/17acf846edee</guid>
            <dc:creator><![CDATA[Obinna Amadi]]></dc:creator>
            <pubDate>Fri, 02 May 2025 12:01:38 GMT</pubDate>
            <atom:updated>2025-05-02T12:01:38.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2A-g8pOcc4aLIKypIqIIHw.png" /></figure><h4>Why AWS Optimization Matters More Than Ever</h4><p>Most companies overspend on AWS by 30–40% due to underutilized resources, misconfigured instances, and lack of monitoring. With the right strategy, you can reduce costs by up to 60%, increase performance, scale<br>efficiently, and free up engineering time.</p><h4>Top AWS Optimization Areas</h4><p>1. Right-Sizing EC2 Instances: Use Compute Optimizer to adjust instances.<br>2. Reserved and Spot Instances: Cut EC2 costs by up to 75%.<br>3. Smart Auto-Scaling: Use predictive scaling to handle traffic patterns.<br>4. Storage Optimization: Use lifecycle policies for S3, remove unused EBS.<br>5. Cost Explorer &amp; Budgets: Visualize spend and get alerts.</p><h4>Advanced Optimization Tactic</h4><p>Use specialized tools like Lambda Power Tuning and RDS Performance Insights. Set lifecycle policies for S3 and configure CloudFront caching.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17acf846edee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO INSTALL APACHE WITH ANSIBLE]]></title>
            <link>https://medium.com/@check4obi79/how-to-install-apache-with-ansible-81d6ef8adf47?source=rss-29db804d8fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/81d6ef8adf47</guid>
            <dc:creator><![CDATA[Obinna Amadi]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 02:31:00 GMT</pubDate>
            <atom:updated>2024-10-06T02:31:00.360Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>.</strong></p><p>INTRODUCTION</p><p>Ansible is an IT automation configuration management and provisioning tool that can be used to deploy applications, manage systems, and write infrastructure as code. Infrastructure as code (IAC) is the term used to describe managing infrastructure using a code base. Ansible is one of the tools that can be used to manage infrastructure through code that can be versioned as well as reusable. There are a couple of other infrastructures as code tools such as PUPPET and CHEF but Ansible’s agentless feature is a huge edge over others. This implies that there is no need to run any kind of Ansible agent in the target nodes, all that needs to be done is to get the master node ready and use Ansible to install our application or make configuration changes as well as use Ansible to provision our infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*V9s3bBCChrUYU66LRTsIyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*LVqNc2atshvywoSuYaCrFA.png" /></figure><p>Ansible uses playbooks that are made of tasks and roles. Tasks are steps written to define the activity in the system and roles are generic, a modulated version of the task. Once a role is created, it can be applied to as many systems as we want. Roles apply to the target system as per our requirements. Ansible playbooks are written in a mark-up language called YAML (Yet Another Mark-up Language). In YAML, items of the same indentation level are sibling elements. Items that begin with a dash are list items. Items with a key-value format are dictionaries.</p><p>INSTALLING ANSIBLE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*IReey3Mbo4EpH-XKnqLZgg.png" /></figure><p>Installing Ansible is a straightforward process. Thin involves installing certain packages on the Linux machine. Ansible does not run as a service. You can start executing Ansible commands once the related packages are installed. The Linux runs on the Ubuntu distribution so we will use the apt-get command to install the packages. Use the commands specified below to install Ansible. Three EC2 instances named Host01, Web01, and Db01 are already running in our AWS console. Ansible will be installed only on Host01.</p><p>N//B The root user was used to install Ansible in the example but it is not recommended in a production environment. use an elevated user instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgwOm3V9TjnNtUeAVURb1w.png" /></figure><p>Verify Ansible installation. You should see a similar screenshot as below. Take note of the configuration file</p><p>ANSIBLE CONFIGURATION.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*GZJ6vJ52rAhGTHq6cmuC4A.png" /></figure><p>Some settings of Ansible are adjustable via a configuration file. The default configuration should suffice for most users but there may be a need to change them. The Ansible configuration takes charge of the behavior via different configuration elements which include the local directory path where Ansible should look for certain dependencies that are quite important. The information about remote users to log into remote machines. Settings related to SSH connections like the private key required to login to a remote server. From the confirmation screenshot, we can see the location of our Ansible file which is <em>/etc/ansible/ansible.cfg.</em></p><p>ANSIBLE INVENTORY.</p><p>Ansible inventory is a file with information about a series of hosts that can be grouped. The file can also have different host-specific variables defined in it. The default location for Ansible inventory is /etc/ansible/hosts. In this file, a series of hosts can be grouped so that when we run the Ansible playbook, we can choose any of the groups or target all hosts in the Ansible inventory. Ansible inventory supports Host variables (applied only to a specific Host), Group variables (Applied to a group of hosts), and Group of Groups (Applied to a group containing other groups.) Our Web01 and Db01 have been added to the inventory file under the hosts_for_demo group, as shown below.</p><p>To test for connectivity between our host and target machine. Run the command <em>‘ansible –m ping all’ </em>You should get the output below otherwise check to make sure that the key pair from AWS is copied to the host machine and has been added using the ssh-add command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*WKW-WWLpYt00-QT94iobAg.png" /></figure><p>You get the same output if you run a ping command on the group configured in the inventory file. In our case it is hosts_for_demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*Xx4ILKxVtCA7cpLFbtezyQ.png" /></figure><p>APACHE WEBSERVER</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*w2-hk5Lv7wo3t46dWb5bcg.png" /></figure><p>Finally, let&#39;s create a simple playbook to install Apache2 and update the cache. We have looked into the documentation to know which module is suitable for each task we want to perform. No one is expected to learn all the modules that Ansible ships with. Documentation is a great tool that we should leverage at all times. Below is the simple playbook created for this purpose.</p><p>APACHE VERIFICATION</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*pJyxnSfR_A9SS_rs7xG51w.png" /></figure><p>Now we have to verify our installation. We will SSH into Web01 and check if Apache2 is running.</p><p>And as expected, the Web01 machine has Apache running on it. There are other ways to verify this installation.</p><p>CONCLUSION</p><p>On a final note, Ansible provides a simple and powerful package for configuration management and automation. This article is only a small fraction of the many benefits Ansible offers. You can explore further by going through the current Ansible documentation online.</p><p>Thank you for reading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81d6ef8adf47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO INTERACT WITH OS USING PYTHON]]></title>
            <link>https://medium.com/@check4obi79/how-to-i-interact-with-os-using-python-d58559ce1956?source=rss-29db804d8fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d58559ce1956</guid>
            <dc:creator><![CDATA[Obinna Amadi]]></dc:creator>
            <pubDate>Sun, 20 Nov 2022 00:20:12 GMT</pubDate>
            <atom:updated>2024-10-06T02:21:34.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*CrLO3qo__0jg6Uvj1dm0KQ.png" /></figure><p>Interaction with surrounding environs has become necessary in today’s information technology circle as solutions now come from different technology stacks. Python is one of the most popular and frequently used languages of recent times, being used for various tasks such as data science, data analytics, web development, machine learning, and automating many tasks. In these processes, many tasks are operating system-dependent and at some point, you might feel this urge to connect directly to the OS instead of clicking through with the mouse to perform a task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*taX6GtgZ6ssC9ObNWGDhlg.png" /></figure><p>The OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system-dependent functionality. To begin we need to import the OS module otherwise python will not recognize the commands. Let&#39;s head over to the terminal for a demo. I have launched PowerShell and issued and moved to python as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*7cHGWM0HTq_cFr-YdB3x7A.png" /></figure><p>If we issue the CPU count command, python will come back with not defined error because we are yet to import the OS module. When we do import the os module, the output is as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*Qh2gD8KI53wU_nN5SOOA9A.png" /></figure><p>We could pretty much perform all the Linux commands using the python OS module like the ping, os name, who is logged in, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*NjJ6GzPRCymmiCQ5Kb6gNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*ixzHwa-Sx055heNawLriOA.png" /></figure><p>You can also edit the system date if your OS is windows, check your environment variables “<em>os.environ</em>”, make a new dir ‘<em>os.mkdir(“dir location”)</em>’, get the current directory ‘<em>os.getcwd()</em>’, List directories “<em>os.listdir()</em>”, view directories in the system “<em>os.system(“dir”)”</em>, delete a file “<em>os.remove(file name / file path)</em>”, delete directory <em>os.rmdir(dir name /dir path),</em>and a whole lot more that you could research and learn.</p><p><strong>WORKING WITH FILES AND DIRECTORIES.</strong></p><p>In information technology, we work with files all the time. It’s such a useful task that most programming languages have the ability to work with files baked into the core set of features. Python is no exception. It gives us a file<br>objects which we can use to read and write to files.</p><p>READ FILE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*WrV8c3j9J5pUyIKZ6Trg2A.png" /></figure><p>What we’re doing here is creating a new file object and assigning it to a<br>a variable called File. The parameters passed to the open function are the name of the file and the mode of the file, in this case in read mode. When we open a file, like we’re doing in this example, the operating system checks that we have permission to access that file and then gives our code a file descriptor. This is a token generated by the OS that allows programs to do more operations with the file. In Python, this file descriptor is stored as an attribute of the file object. The file object gives us a bunch of methods that we can use to operate with the file. Now, with this file object, we can read the contents of the file and print them to the screen. In the shot above, we create a file demo.txt and wrote some text into the file for demo purposes.</p><p><strong>READLINE AND READ METHOD.</strong></p><p>The reading method reads the file one line on each call. That is to say, the first <em>readline</em> method call reads the first line of the file, and the second <em>readline</em> method call will read the next line of the file. The read method reads the file all the way through to the end from the current position on the file. Another way we can work with the contents of the file is to read the file lines into a list by calling the <em>readlines()</em> method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*kjnyYycX10OKGmBYaZ6P6A.png" /></figure><p>Finally, the file is closed with the close method. This open-use-close pattern is the typical way to work with files in most languages. For the sake of avoiding wastage of system resources, and security, among other concerns, it is a great idea to close files after working with them. We can also create a block of code that closes the file by using the keyword “with”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*P8VhQ0rbQnDWVX3CuaaIwg.png" /></figure><p><strong>ITERATING THROUGH FILES</strong>.</p><p>File objects can be iterated in the same way as other Python sequences like list or strings. This is really useful when you want to process a file line by line. Say for example you want to make a whole line uppercase before printing it. You can do that with something like this. The strip method is added to remove the newline character that python adds when we call the read method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*x4WmpZjNGFtOGa9s8ZlWQQ.png" /></figure><p><strong>WRITING TO FILES</strong>.</p><p>File objects can be opened in several different modes. A mode is similar to file permission. It governs what you can do with the file you’ve just opened. By default, the open function uses the r mode, which stands for read-only. If you open a file for writing and the file already exists, the initial contents will be deleted as soon as the file is opened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43EFOQrTlHGreiSTdrPxbg.png" /></figure><p><strong>WORKING WITH CSV FILES.</strong></p><p>Data comes in a bunch of different formats besides text. And you may need to deal with some of these in your scripts. Formats give data structure. And computers love structure and precision. To be able to process a data set, it helps to know ahead of time how that data set will be arranged. CSV or comma-separated values is a very common data format used to store data as segments of text separated by commas. In the Python standard library, there are classes and modules for working with many of these data formats, including CSV and HTML. For less common file formats or more advanced manipulation techniques. Let&#39;s iterate through the csv file created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*fd0R3rRKKQYdbyeETPszwg.png" /></figure><p>We opened the CSV file using the CSV module so that it could be parsed. With that, we now have an instance of the CSV reader class. We now iterated through the file contents and accessed the information that is parsed. Finally, we closed the file.</p><p>GENERATING CSV FILE.</p><p>The writer function can be used to generate content to a file. This can be really helpful if you process some data in your script and you must store it in a file. Perhaps you want to import it into a spreadsheet or use it later on in your script. To begin, we need to store the data to be written into a list, which will be a list of lists. We will open the file in write mode using the ‘with’ block of code so we don&#39;t forget to close the file. The writer function of the CSV module was called using this file as a parameter. There are two functions that we can use: write row, which we’ll write one row at a time; and write rows, which we’ll write all of them together. We used the write rows as we already have all the data we want to write. If we view the file outside python, it should look like the screenshot below(<em>I, out of error omitted the comma to separate web.local and Db.local from their IP addresses respectively</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vU7hNqA1n3T0GMWQkZ0cAg.png" /></figure><p>READING AND WRITING CSV WITH DICTIONARIES.</p><p>Our previous method of reading and writing to CSV which is using the list as datatype at the python end works well when we know what<br>the fields are going to be, but it can become inconvenient when there are lots of columns and we have to remember which is which. We have modified our previous CSV file to add Location and username rows. Let&#39;s say we want to view the location of each employee. We can profit from this additional information by using DictReader, a slightly different reader that’s also provided by the CSV module. This reader turns each row of the data in a CSV file into a dictionary. We can then access the data by using the column names instead of the position in the row. The output gives us the information as desired, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*L-iHY-ybRbXr1zwGWyxw7Q.png" /></figure><p>CONCLUSION</p><p>We have seen in this article, how we can use Python programs can interact with the operating system, and read and write CSV files as well as text files. Python is pretty much the programming language to go with, and it offers tons of amazing functions and modules that can help ease our different jobs in many different ways. You can read the official documentation to learn more.</p><p>THANK YOU FOR READING.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d58559ce1956" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW I LOAD BALANCE WITH NGINX ON AWS.]]></title>
            <link>https://medium.com/@check4obi79/how-i-load-balance-with-nginx-on-aws-f03dff2782a?source=rss-29db804d8fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f03dff2782a</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[web-server]]></category>
            <dc:creator><![CDATA[Obinna Amadi]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 21:08:51 GMT</pubDate>
            <atom:updated>2022-10-02T21:08:51.021Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>LOAD BALANCING</strong></p><p>The act of efficiently distributing incoming network traffic across a group of servers in the server pool or server farm is called load balancing. High-traffic websites nowadays get millions of requests from clients or users who are expecting text, videos, or application data all in a quick and reliable technique. The general practice to cost-effectively scale to meet the high demands would be to add more servers. A load balancer makes sure the high traffic is evenly distributed among these servers.</p><p><strong>FUNCTIONS OF A LOAD BALANCER</strong></p><ul><li>Distributes client requests or network load efficiently across multiple servers</li><li>Ensures high availability and reliability by sending requests only to servers that are online</li><li>Provides the flexibility to add or subtract servers as demand dictates</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*wKUNJj6KLFrSaLbhywqoLQ.png" /></figure><p><strong>LOAD BALANCING ALGORITHMS</strong></p><ul><li><strong>Least Connection Method. </strong>A<strong> </strong>New<strong> </strong>request is sent to the server with the least current connections to clients. The algorithm makes this evaluation and delivers superior performance as a result.</li><li><strong>Round Robin.</strong> Requests are distributed across the group of servers in sequence. This is quite an easy implementation for the load balancer but the snag is that the load balancer can not provide a record of the current load on the server.</li><li><strong>Least Response Time Method.</strong> Requests are sent to the server using a formula that combines the fastest response time and the fewest active connections. This is more advanced than the least connection method and is used by NGINX Plus.</li><li><strong>Hashing Method.</strong> Requests are distributed based on a key you have defined, such as the IP address of the client or URL. NGINX Plus applies this optionally to reduce redistribution of loads in the case of changes in the upstream servers.</li><li><strong>Least Bandwidth Method.</strong> With this method, there is a search for the server currently serving the least amount of traffic measured in megabits per second (Mbps)</li></ul><p><strong>Related Basics with load balancing:</strong></p><ul><li>Sticky Session. Session stickiness, a.k.a., session persistence, is a process in which a load balancer creates an affinity between a client and a specific network server for the duration of a session, (i.e., the time a specific IP spends on a website). Using sticky sessions can help improve user experience and optimize network resource usage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*jRWydnqFRh57_FhbzpTCVw.png" /><figcaption>session persistence</figcaption></figure><ul><li>Dynamic server configuration(Auto scaling groups) Many applications require a new server spun or taken down as the rises or drops. Commonly used in the cloud service provider environment. This enables users to pay only for the computing service they have consumed as well as ensures the capacity scale up and down in response to user/client traffic requests.</li></ul><p>Load balancers, once almost exclusive to the realm of hardware devices, can now be implemented effectively in software on another server. The line between hardware and software load balancers is fading fast. The principle difference between hardware versus software load balancers lies in the available capacity and the amount of labor invested in the platform.</p><p><strong>NGINX AS A LOAD BALANCER.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-QWsMpUF74BGgiDcdkftw.png" /><figcaption>nginx load balancer</figcaption></figure><p>As a load balancer, NGINX receives traffic from clients/users and then distributes the traffic using configured algorithm across the servers in the pool. NGINX is also responsible for the delivery of the server responses to different clients/users.</p><p>To wrap this up, we are going to create a simple Nginx load balancer. We have already spun up three EC2 instances in AWS web App1, web App2, and NGINX Load Balancer. In each instance, Nginx has been installed and running. we have also created custom default index.html pages on web app1 and web app2 machines for the purpose of testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1trelJfyL1R26CID2G_XjQ.png" /></figure><p>Below are the IP address details of our EC2 instances for demonstration. Take note of the public IP address which we will use for configuration and verification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5N4l6x4Xis0FATR6Mt-uyA.png" /><figcaption>Nginx IP details</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3u5GY4fIYEhOdQL1UolROA.png" /><figcaption>Web App1 IP details</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*802H3A-0V2dn1TS4nnN-xA.png" /><figcaption>Web App2 IP details</figcaption></figure><p>The load balancing configuration file is located at <em>/etc/nginx/nginx.conf</em> in our load balancer EC2 instance. Use the cat command to have a view of the already configured file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*FyQudxeLDYIcxsqDuFFu6g.png" /></figure><p>Nginx upstream is used for proxy requests to other servers. Our upstream configuration name is the webserver. Note that the config setting is under HTTP simply because it is expected to operate on the application (layer 7) load balance. More parameters can be added to the server address such as custom port numbers as well as weight values. On the server settings, it basically means when a proxy request is received from port 80, Nginx will proxy pass to the webserver which contains the server IP address details, in a simple round-robin pattern. And finally, pass the log details to the log file.</p><p>Let&#39;s head over to the browser first to see the Nginx page on web app1 and web app2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJ6k1wgi8E_6J-iLiYb6KQ.png" /><figcaption>web app1</figcaption></figure><p>Web app1 Nginx works perfectly, let us perform the same test for web app2 Nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*dQxweNXtZbCqH-tHbmTpRA.png" /><figcaption>web app2</figcaption></figure><p>We have confirmed that Nginx works on web app1 and web app2 by connecting through their public IP respectively on the web browser. Now we verify if the load balancer is serving the same web pages as we see above using the load balancer&#39;s public IP address on the web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EbeSE8ehcHGkpqr6UXD4Q.png" /></figure><p>As expected, the load balancer serves the same web page seen from web app1 public IP on the browser. When the web browser is refreshed, the load balancer will now serve the same web page as seen from the public IP of web app2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6eDxrF4x1auLSKcdmuRQzg.png" /></figure><p>We can also curl the public IP address of the load balancer EC2 instance on the terminal window to further test our load balance configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*7f4BljLuMopclS0FNzWQew.png" /></figure><p>On the first curl command, the load balancer serves the web page from web app1 and on the second curl command, it will serve the webpage for web app2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*HtZKh1U1x3pz5-xvNSFD3A.png" /></figure><p>Lastly, if we cat the log file specified in the Nginx.conf file, we will find log records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*CDHrXYR9GTFG6lV6fjKyXA.png" /></figure><p><strong>SUMMARY</strong>.</p><p>Nginx is a great tool to perform layer 4 and 7 load balancing tasks. In this article, we have seen how to create a simple application load balancer on EC2 machines. However, a lot more can be done with Nginx load balancing. More information can be found <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/">here</a>.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f03dff2782a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TASK AUTOMATION AND SCHEDULING WITH SHELL SCRIPT AND CRONTAB]]></title>
            <link>https://medium.com/@check4obi79/task-automation-and-scheduling-with-shell-script-and-crontab-a6bd3210e031?source=rss-29db804d8fb2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6bd3210e031</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[shell-script]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[crontab]]></category>
            <dc:creator><![CDATA[Obinna Amadi]]></dc:creator>
            <pubDate>Sun, 25 Sep 2022 23:56:58 GMT</pubDate>
            <atom:updated>2022-09-26T07:32:38.475Z</atom:updated>
            <content:encoded><![CDATA[<p>Automation has indeed proven to be an efficient way of carrying out tasks and workflows over the last decade across several industries. While the benefits of automation may seem infinite, it has really improved the quality of products as well as eradicated human errors. In Nutshell, automated workflows are effective, reliable, and time-saving. In this article, we will be combining the use of two super tools(Shell Scripts and Linux cron) for task automation.</p><p><strong>BASH</strong></p><p>Bash in some cases may not be considered a programming language. It is not only the command-line interpreter that executes, it is also a scripting language and is commonly used in Linux. Bash (Bourne Again SHell) came as a replacement for the original Bourne Shell. Shell scripts can come in handy, especially when troubleshooting a system. let’s see a simple example.</p><p><strong>CREATING A BASH SCRIPT</strong></p><p>We will be creating our scripts using Bash and of course, there are other shell interpreters like the Korn shell, Cshell, and Bourne Shell. The first line should have the shebang and the interpreter path. #!/bin/bash. This tells the system to read the following lines as code using the bash shell. It is a good practice to add other comments like description, date, and modification status for the sake of readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*KEoQAkrcT9OTIAeKzfX5Wg.png" /><figcaption>Simple Script</figcaption></figure><p>when we run the script above the result should look exactly like the shot below on our terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*NRmZBNy7vyTTJZwQwsvxIw.png" /><figcaption>Script Script Result</figcaption></figure><p>Task automation is the use of software to complete repetitive work activities, which significantly improves the accuracy and consistency of workflows and energizes efficient processes. Task automation has become very popular thanks to user-focused tools that make complex series of tasks much easier.</p><p>Let’s see another simple but powerful script that can save us while debugging a system. The“ps” command displays the processes running in a system and the “who” command displays the current user. These and much more can be combined to give us valuable information while troubleshooting a system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*stHs83L4uMpMWUvJETBTHA.png" /><figcaption>Debug Script</figcaption></figure><p>The result of executing the above switch should look similar to the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*gBeT2WEIgpjiz4Mk7IpVCQ.png" /></figure><p><strong>CRON</strong></p><p>Cron is the default task scheduler utility on Linux-based operating systems. It is a daemon to execute scheduled commands and it is widely used to automate recurring tasks. Cron has quite a good name for a task scheduler as its name is derived from the Greek word “CHRONUS” which means time.</p><p><strong>Crontab</strong> stands for “cron table”. It allows using a job scheduler (cron) to execute tasks. Crontab is also the name of the program, which is used to edit that schedule. With cron, Admins can be incredibly specific with how you schedule your commands to run as well as be very general and relaxed. Cron jobs can be created in two ways:</p><ul><li><strong>User crontab. </strong>Allows the authenticated user to create and edit cron jobs applicable only to the user.</li><li><strong>System crontab.</strong> Used to schedule essential tasks across the entire system, however, the user must be logged into the root account.</li></ul><p>A crontab file is a file containing the list of command(s) to be executed at specified times. The crontab file is made up of six rows. Going from left to right. We have minutes(0–59), hour(0–23), Day Of Month DOM(1–31), Month(1–12), Day Of Week DOW(0–6 DAy 0 will be Sunday), Task or path to Command to be executed. For example, if I want to execute ‘Hello World’ every minute, for every hour, every day of the month, every month of the year. A simple cron file to do this would be [* * * * * echo “Hello World”]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*tquepYUm490eLYiCFFwUGA.png" /><figcaption>cron file</figcaption></figure><ul><li>To create or edit a crontab enter <em>crontab -e</em></li><li>To view a list of active crontab enter <em>crontab -l</em></li><li>To delete all tasks and start all over enter <em>crontab -i</em></li></ul><p>In addition to crontab, the root user can also add cron jobs to the, <strong>etc/cron.d</strong> directory. It’s most suitable for running scripts for automatic installations and updates.</p><h4><strong>PUTTING ALL TOGETHER</strong></h4><p>For the purpose of this article, we have modified our script to log timestamps to a file named debug.log. We have also created our crontab to execute every minute just for demonstration as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*rTTeKBu2sD-9TRaDxS6ZVA.png" /><figcaption>script_debug</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*0kpAukwjc3_4So5bYlDs3Q.png" /></figure><p>Now, let us view our debug.log file to verify if the cronjob is running as desired.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*ZvvfrsA4sM07H3YTSN6LCQ.png" /><figcaption>log file</figcaption></figure><p>Just as anticipated, crontab is executing our script every minute and exporting each executed time stamp to debug.log as specified in the script.</p><p><strong>SUMMARY</strong></p><p>The cron job is a perfect way to automate repetitive tasks, completely eliminating human error. The benefits of cron jobs cut across many job roles in the information technology industry as well as many other sectors. System administrators, DevOps, infrastructure engineers, and others should leverage this extremely amazing tool to life and job less stressful. This article is in no way comprehensive, you can access tons of resources on the internet to learn further.</p><p>Thank you for reading.!</p><p>#devops #Linux #Crontab #aws</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6bd3210e031" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>