Tech Junkie Blog - Real World Tutorials, Happy Coding!: April 2022

Monday, April 25, 2022

An ASP.NET MVC can get big, and it could be overwhelming.  Areas are a way to break up the application into smaller segments,  A perfect candidate for an Area is the Administrative features of the site because it has multiple pages, and functionalities.  So it is a good idea to segment off the Administration area to its own area (no pun intended).

Monday, April 18, 2022

 In the previous post we created an EC2 instance in AWS in this post we are going to connect to that instance on a Linux workstation or server with SSH.

Here are the steps to connect to the EC2 instance using SSH on Linux, this will also work on a Mac as well:

1. Navigate to the folder that contains the key pair file that you've downloaded in the previous post, I store it in the folder /aws/EC2/KeyPair/ folder , so I would type cd /aws/EC2/KeyPair then type ls to see the file in the folder

Monday, April 11, 2022

 In this post we are going to look at another performance related command, which is the uptime command.

First let's look at the uptime command, as the name implies the uptime command shows you what the uptime is for the system:

[root@cent7 jhuynh]# uptime
 12:41:20 up  1:29,  2 users,  load average: 0.05, 0.04, 0.06

The command shows you the uptime for the system, the number of users who are using the system, and the system load average (Number of CPU used) in intervals of 5 minutes.

If you type w, you can see which users are using the system

[root@cent7 jhuynh]# w
 12:41:29 up  1:29,  2 users,  load average: 0.04, 0.04, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jhuynh   :0       :0               11:15   ?xdm?   3:02   0.49s /usr/libexec/gnome-session-binary --session gnome-classic
jhuynh   pts/0    :0               11:21    1.00s  0.42s 11.27s /usr/libexec/gnome-terminal-server

The load average is the most important stat in the uptime command however, it is currently static, and to get updates you need to run the uptime every 5 minutes.  There's a better way to monitor your Linux system.  But you have to call now, and for a limited time only for just $19.99 you can have the answer.  Since I am such a nice guy I am going to give you the answer for free.

What you can do is type the command tload and it will monitor the load average time in real-time. Before we run the tload command a good command to run is the lscpu command to see how many CPU you have.  For instance you have just one CPU and your load average is 1+ then you have got a problem.

[root@cent7 jhuynh]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel

Now let's run the tload command



There are two parts to the tload utility, at the top you will see the average load time in real time instead of the 1, 5, 15 minute interval like before.  But it will be dynamic and updates automatically based on the load.

On the bottom you will see a graphical representation of the load average, it's probably not going to win any awards for best graphics 


 







Everything looks fine right now, but if you open another terminal and run the dnf update -y command you will see the load changing accordingly. Or some tasks that would put stress on the system.

Monday, April 4, 2022

 In this post we are going to look at the procps-ng package commands to get some performance related information on our Linux system.

The first command we are going to look at is the free command, which shows the free memory available

[root@cent7 jhuynh]# free
              total        used        free      shared  buff/cache   available
Mem:        1882072      754028      404848       33544      723196      942276
Swap:        978940           0      978940

We can use the free command with the -m option to show the free memory in megabytes

[root@cent7 jhuynh]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1837         734         397          32         706         922
Swap:           955           0         955

Or free -g for gigabytes

[root@cent7 jhuynh]# free -g
              total        used        free      shared  buff/cache   available
Mem:              1           0           0           0           0           0
Swap:             0           0           0

The next command we are going to look at is the pmap command, let's grab a process id for this one with the ps -l  command

[root@cent7 jhuynh]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  3358  3315  0  80   0 - 68658 poll_s pts/0    00:00:00 sudo
4 S     0  3365  3358  0  80   0 - 58056 do_wai pts/0    00:00:00 su
4 S     0  3368  3365  0  80   0 - 29107 do_wai pts/0    00:00:00 bash
0 R     0  4238  3368  0  80   0 - 38332 -      pts/0    00:00:00 ps

Let's run the pmap command on the bash process, the pmap command displays the memory map of a process, besides the memory usage it's nice to see the shared libraries used for the process

[root@cent7 jhuynh]# pmap 3368
3368:   bash
0000000000400000    888K r-x-- bash
00000000006dd000      4K r---- bash
00000000006de000     36K rw--- bash
00000000006e7000     24K rw---   [ anon ]
00000000021b3000   1144K rw---   [ anon ]
00007f53b0616000     48K r-x-- libnss_files-2.17.so
00007f53b0622000   2044K ----- libnss_files-2.17.so
00007f53b0821000      4K r---- libnss_files-2.17.so
00007f53b0822000      4K rw--- libnss_files-2.17.so

Another useful command is the pwdx command, this command finds the home working directory of a process.  So if we run the command pwdx 3368 we will find out what the home working directory of the bash shell is

[root@cent7 jhuynh]# pwdx 3368
3368: /home/jhuynh
[root@cent7 jhuynh]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  3358  3315  0  80   0 - 68658 poll_s pts/0    00:00:00 sudo
4 S     0  3365  3358  0  80   0 - 58056 do_wai pts/0    00:00:00 su
4 S     0  3368  3365  0  80   0 - 29107 do_wai pts/0    00:00:00 bash
0 R     0  4345  3368  0  80   0 - 38332 -      pts/0    00:00:00 ps


Search This Blog