Saturday, July 21, 2018

Introduction to Process Management - Linux


Linux, in general, is a fairly stable system. Occasionally, things do go wrong however and sometimes we also wish to tweak the running of the system to better suit our needs. 

In this section, we will take a brief look at how we may manage programs or processes on a Linux system. So what are they?

A program is a series of instructions that tell the computer what to do. When we run a program, those instructions are copied into memory and space is allocated for variables and other stuff required to manage its execution. This running instance of a program is called a process and it's processed which we manage.

What is Currently Running?

Linux, like most modern OS's, is a multitasking operating system. This means that many processes can be running at the same time. As well as the processes we are running, there may be other users on the system also running stuff and the OS itself will usually also be running various processes which it uses to manage everything in general. If we would like to get a snapshot of what is currently happening on the system we may use a program called top.
top

Below is a simplified version of what you should see when you run this program.
1. top
2. Tasks: 174 total, 3 running, 171 sleeping, 0 stopped
3. KiB Mem: 4050604 total, 3114428 used, 936176 free
4. Kib Swap: 2104476 total, 18132 used, 2086344 free
5.  
6. PID USER %CPU %MEM COMMAND
7. 6978 ryan 3.0  21.2 firefox
8.   11 root 0.3   0.0 rcu_preempt
9. 6601 ryan 2.0   2.4 kwin
10. ...


Here are details 

Line 2 Tasks is just another name for processes. It's typical to have quite a few processes running on your system at any given time. Most of them will be system processes. Many of them will typically be sleeping. This is ok. It just means they are waiting until a particular event occurs, which they will then act upon.
Line 3 This is a breakdown of working memory (RAM). Don't worry if a large amount of your memory is used. Linux keeps recently used programs in memory to speed up performance if they are run again. If another process needs that memory, they can easily be cleared to accommodate this.
Line 4 This is a breakdown of Virtual memory on your system. If a large amount of this is in use, you may want to consider increasing its size. For most people with most modern systems having gigabytes of RAM, you shouldn't experience any issues here.
Lines 6 - 10 Finally is a listing of the most resource intensive processes on the system (in order of resource usage). This list will update in real time and so is interesting to watch to get an idea of what is happening on your system. The two important columns to consider are memory and CPU usage. If either of these is high for a particular process over a period of time, it may be worth looking into why this is so. The USER column shows who owns the process and the PID column identifies a process's Process ID which is a unique identifier for that process.
Top will give you a real-time view of the system and only show the number of processes which will fit on the screen. Another program to look at processes is called ps which stands for processes. In it's normal usage it will show you just the processes running in your current terminal (which is usually not very much). If we add the argument aux then it will show a complete system view which is a bit more helpful.

ps [aux]

It does give quite a bit of output so people usually pipe the output to grep to filter out just the data they are after. We will see in the next bit an example of this.
Killing a Crashed Process

It doesn't happen often, but when a program crashes, it can be quite annoying. Let's say we've got our browser running and all of a sudden it locks up. You try and close the window but nothing happens, it has become completely unresponsive. No worries, we can easily kill Firefox and then reopen it. To start off we need to identify the process id.

1. ps aux | grep 'firefox'
2. ryan 6978 8.8 23.5 2344096 945452 ? Sl 08:03 49:53 /usr/lib64/firefox/firefox


It is the number next to the owner of the process that is the PID (Process ID). We will use this to identify which process to kill. To do so we use a program which is appropriately called kill.
kill [signal] <PID>

1. kill 6978
2. ps aux | grep 'firefox'
3. ryan 6978 8.8 23.5 2344096 945452 ? Sl 08:03 49:53 /usr/lib64/firefox/firefox
.
Sometimes you are lucky and just running kill normally will get the process to stop and exit. When you do this kill sends the default signal ( 1 ) to the process which effectively asks the process nicely to quit. We always try this option first as a clean quit is the best option. Sometimes this does not work, however. In the example above we ran ps again and saw that the process was still running. No worries, we can run kill again but this time supply a signal of 9 which effectively means, go in with a sledgehammer and make sure the process is well and truly gone.

1. kill -9 6978
2. ps aux | grep 'firefox'

Normal users may only kill processes which they are the owner for. The root user on the system may kill anyone processes.


When a process crashes and locks up, it can lock up the entire desktop. If this happens there is still hope.

Linux actually runs several virtual consoles. Most of the time we only see console 7 which is the GUI but we can easily get to the others. If the GUI has locked up, and we are in luck, we can get to another console and kill the offending process from there. To switch between consoles you use the keyboard sequence CTRL + ALT + F<Console>. So CTRL + ALT F2 will get you to a console (if all goes well) where you can run the commands as above to identify process ids and kill them. Then CTRL + ALT F7 will get you back to the GUI to see if it has been fixed. The general approach is to keep killing processes until the lock up is fixed. Normally you can look for tell tale signs such as high CPU or Memory usage and start with those processes first. Sometimes this approach works, sometimes it doesn't and you need to restart the computer. Just depends how lucky you are.
Foreground and Background Jobs

Friday, May 11, 2018

Why DevOps ?

DevOps is a culture/profession which promotes collaboration between Development and Operations Team to deploy code to production faster in an automated & repeatable way. The word 'DevOps' is a combination of two words 'development' and 'operations.'
DevOps helps to increases an organization's speed to deliver applications and services. It allows organizations to serve their customers better and compete more strongly in the market.
In simple words, DevOps can be defined as an alignment of development and IT operations with better communication and collaboration. 





DevOps = ACCELERATE  software delivery  +  BALANCE speed, cost, quality & risk + REDUCE time to customer feedback

A collaborative DevOps implementation can bring real business benefit:
  • Meet customer expectations 100%
  • Develop new applications for new markets
  • Reduce the cost of IT overhead
  • Enable innovation at a controlled cost
  • Reduce the cost of market entry
  • Lower the risk of software change





Horizon Desktop-as-a-Service Platform ( Vmware DaaS )



Desktop as a Service provides a useful solution that can bring greater flexibility, ease of administration and cost savings to organizations.

A third party hosts the back end of a virtual desktop infrastructure (VDI) deployment.


With DaaS, on the other hand, organizations pay no upfront costs. They only pay for the virtual desktops they use each month. Over time, however, these subscription costs can add up and eventually be higher than the capital expenses of deploying on-premises VDI.




Please message me with your problem or what you want before you order

Do you have a problem with your VMware ESXi Host System or a VMware vCenter?

I will help with your problems for the following systems:
  •  vCenter & ESXi Host System

I will help you to manage your virtual server within:
  • vCenter & ESXi Host System

Do you want to try out VMware ESXi on your dedicated server?
If yes I can help you with the installation or if you want to install it for you :)

Thanks

Thursday, October 29, 2015

Solaris 10 ssh lock after retires policy

Check :-

bash-3.2# cat /etc/security/policy.conf | grep LOCK_AFTER_RETRIES=NO
#LOCK_AFTER_RETRIES=NO
bash-3.2# cat /etc/security/policy.conf | grep LOCK_AFTER_RETRIES
# LOCK_AFTER_RETRIES specifies the default account locking policy for local
#LOCK_AFTER_RETRIES=NO
bash-3.2#

Apply :- 


bash-3.2# cp /etc/security/policy.conf /etc/security/policy.orig
bash-3.2#
bash-3.2#
bash-3.2# echo "LOCK_AFTER_RETRIES=YES" >>  /etc/security/policy.conf
bash-3.2#
bash-3.2# cat /etc/security/policy.conf | grep LOCK_AFTER_RETRIES
# LOCK_AFTER_RETRIES specifies the default account locking policy for local
#LOCK_AFTER_RETRIES=NO
LOCK_AFTER_RETRIES=YES

Now if you have appply the rule below, it should work .. 

bash-3.2# cat /etc/default/login | grep RETRIES
# login will wait after RETRIES failed attempts or the PAM framework returns
# RETRIES determines the number of failed logins that will be
# will be locked if failed logins equals or exceeds RETRIES.
RETRIES=5
bash-3.2#

Saturday, September 19, 2015

How to Enable the Audit Service in Solaris

cd /etc/security

# ./bsmconv
This script is used to enable the Basic Security Module (BSM).
Shall we continue with the conversion now? [y/n] y
bsmconv: INFO: checking startup file.
bsmconv: INFO: turning on audit module.
bsmconv: INFO: initializing device allocation.

The Basic Security Module is ready.
If there were any errors, please fix them now.
Configure BSM by editing files located in /etc/security.
Reboot this system now to come up with BSM enabled.
Reboot:
# init 6
After the reboot, the SMF service: svc:/system/auditd:default will be in online status and the auditd daemon will be running:
# svcs -l auditd
fmri         svc:/system/auditd:default
name         Solaris audit daemon
enabled      true
state        online
next_state   none
state_time   Tue Jul 23 11:11:59 2013
logfile      /var/svc/log/system-auditd:default.log
restarter    svc:/system/svc/restarter:default
contract_id  64
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   require_all/none svc:/milestone/name-services (online)
dependency   require_all/none svc:/system/system-log (online)

# pgrep -fl audit
  564 /usr/sbin/auditd


svcadm enable auditd
 ** vi /etc/security/audit_control 
Remove before
## audit_control file
ADD_____________________
flags:lo,ss
naflags:lo,na
plugin:name=audit_binfile.so;p_dir=/var/audit; p_minfree=20;
plugin:name=audit_syslog.so;p_flags=+lo,-ss


Sunday, May 17, 2015

check which port use which service in solaris

#netstat -ua|grep 2321|grep LISTEN
pid is visible in 4th column of the output.


#ps -ef|grep <pid>


If required to kill it ,

 #kill -9 <pid>



LUN Recovery procedure in Solaris

LUN Recovery procedure in Solaris  

Lun discovery using Solaris :-

#sudo mpathadm list lu
#sudo luxadm -e forcelip /dev/cfg/c1
#devfsadm -Cv
#cfgadm -al

Best Practice Before Removing LUN(s) and/or Target(s) From a Solaris Server:-

cfgadm -o unusable_FCP_dev -c unconfigure c #::WWPN (for Solaris 8/9 and above)
or

cfgadm -o unusable_SCSI_LUN -c unconfigure c #::WWPN (for Solaris 10 and above)

................................................................................
................................................................................



# mpathadm list mpath-support
mpath-support: libmpscsi_vhci.so


# mpathadm list mpath-support
mpath-support: libmpscsi_vhci.so





Run the mpathadm list initiator-port command.


# mpathadm list initiator-port
Initiator-Port: iqn.1986-03.com.sun:01:080020b7ac2b.437a3b3e,4000002affff
Initiator-Port: 2000000173018713

ProcedureTo Get the Properties of a Particular Initiator Port
Display the properties of an initiator port by typing the show command.

Run the mpathadm list initiator-port command.


# mpathadm list initiator-port
Initiator-Port: iqn.1986-03.com.sun:01:080020b7ac2b.437a3b3e,4000002affff
Initiator-Port: 2000000173018713

Select an initiator port to use from the output.

Run the mpathadm show initiator-port initiator-port-name command.


# mpathadm show initiator-port 2000000173018713
initiator-port: 2000000173018713
    Transport Type: Fibre Channel
    OS Device File: /devices/pci@1f,2000/SUNW,glc@4/fp@0,0

ProcedureTo Get a List of Logical Units Discovered on the System
The mpathadm list lu command displays the list of logical units attached to the initiator. This list displays the number of paths and the operational path count to each logical unit listed.

Run the mpathadm list lu command.


# mpathadm list lu
    /dev/rdsk/c4t60020F20000035AF4267CCCB0002CEE2d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
        Total Path Count: 2
        Operational Path Count: 2

ProcedureTo Get the Properties and Associated Path Information of a Particular Logical Unit by Name
Display the list of logical units, along with the properties for each logical unit through the mpathadm command. The list of logical units contains logical unit names that in turn can be used to display the properties of a particular logical unit.

Run the mpathadm list lu command.


# mpathadm list lu
    /dev/rdsk/c4t60020F20000035AF4267CCCB0002CEE2d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
        Total Path Count: 2
        Operational Path Count: 2

Select a logical unit name from the output.

Run the mpathadm show lu logical-unit-name command.


# mpathadm show lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
logical unit: /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
    mpath-support libmpscsi_vhci.so
     Vendor:  SUN
     Product:  T4
     Revision:  0301
     Name Type:  SCSI Inquiry VPD page 83 type 3
    Name:  60003ba27d2120004204ac2b000dab00
     Asymmetric:  yes
     Current Load Balance:  round-robin
     Logical Unit Group ID:  NA
     Auto Failback:  on
     Auto Probing:  NA

     Paths:
          Initiator Port Name:  2000000173818713
          Target Port Name:  20030003ba27d212
          Override Path:  NA
          Path State:  OK
          Disabled:  no

         Initiator Port Name:  2000000173018713
          Target Port Name:  20030003ba27d095
          Override path:  NA
          Path State:  OK
          Disabled:  no

     Target Port Groups:
          ID:  2
          Explicit Failover:  yes
          Access State:  standby
          Target Ports:
               Name:  20030003ba27d212
               Relative ID:  0
    
          ID:  5
          Explicit Failover:  yes
          Access State:  active
          Target Ports:
               Name:  20030003ba27d095
          Relative ID:  0

ProcedureTo List All Logical Units Associated With a Particular Target Port
To list paths through a target port use the show command of a logical unit. 
First, retrieve the list of target ports associated with a logical unit. 
Then, use the target port to list all logical units associated with this target port.

Run the mpathadm list lu command.


# mpathadm list lu
    /dev/rdsk/c4t60020F20000035AF4267CCCB0002CEE2d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
        Total Path Count: 2
        Operational Path Count: 2

Select a logical unit name from the output.

Run the mpathadm show lu command.


# mpathadm show lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
logical unit: /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
    mpath-support libmpscsi_vhci.so
     Vendor:  SUN
     Product:  T4
     Revision:  0301
     Name Type:  SCSI Inquiry VPD page 83 type 3
    Name:  60003ba27d2120004204ac2b000dab00
     Asymmetric:  yes
     Current Load Balance:  round-robin
     Logical Unit Group ID:  NA
     Auto Failback:  on
     Auto Probing:  NA

     Paths:
          Initiator Port Name:  2000000173818713
          Target Port Name:  20030003ba27d212
          Override Path:  NA
          Path State:  OK
          Disabled:  no

         Initiator Port Name:  2000000173018713
          Target Port Name:  20030003ba27d095
          Override path:  NA
          Path State:  OK
          Disabled:  no

     Target Port Groups:
          ID:  2
          Explicit Failover:  yes
          Access State:  standby
          Target Ports:
               Name:  20030003ba27d212
               Relative ID:  0
    
          ID:  5
          Explicit Failover:  yes
          Access State:  active
          Target Ports:
               Name:  20030003ba27d095
          Relative ID:  0

Select a target port from the output list.

Run the mpathadm list lu -t command.


# mpathadm list lu -t 20030003ba27d212
     /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
          Total Path Count: 2
          Operational Path Count: 2
     /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
          Total Path Count: 2
          Operational Path Count: 2

ProcedureTo List a Logical Unit With a Particular Name Derived From the Hardware Used by the System
Run the mpathadm list lu command.


# mpathadm list lu
    /dev/rdsk/c4t60020F20000035AF4267CCCB0002CEE2d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
        Total Path Count: 2
        Operational Path Count: 2

Select a logical unit name from the output.

Run the mpathadm show lu logical-unit-name command.


# mpathadm show lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
logical unit: /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
    mpath-support libmpscsi_vhci.so
     Vendor:  SUN
     Product:  T4
     Revision:  0301
     Name Type:  SCSI Inquiry VPD page 83 type 3
    Name:  60003ba27d2120004204ac2b000dab00
     Asymmetric:  yes
     Current Load Balance:  round-robin
     Logical Unit Group ID:  NA
     Auto Failback:  on
     Auto Probing:  NA

     Paths:
          Initiator Port Name:  2000000173818713
          Target Port Name:  20030003ba27d212
          Override Path:  NA
          Path State:  OK
          Disabled:  no

         Initiator Port Name:  2000000173018713
          Target Port Name:  20030003ba27d095
          Override path:  NA
          Path State:  OK
          Disabled:  no

     Target Port Groups:
          ID:  2
          Explicit Failover:  yes
          Access State:  standby
          Target Ports:
               Name:  20030003ba27d212
               Relative ID:  0
    
          ID:  5
          Explicit Failover:  yes
          Access State:  active
          Target Ports:
               Name:  20030003ba27d095
          Relative ID:  0

Select an inquiry-string-name from the output.

Run the mpathadm list Lu -n inquiry-string-name command.


# mpathadm list lu -n 60003ba27d2120004204ac2b000dab00
mpath-support: libmpscsi_vhci.so
     /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
          Total Path Count: 2
          Operational Path Count: 2
ProcedureTo Configure Auto-Failback for a Particular Multipathing Support
Symmetrical devices allow for automatic failback to a possible optimal path. If a failover occurs on the initial path, the standby path becomes the new online path. Usually the standby path is a suboptimal path. When auto-failback is enabled, the initial path comes back online, failover to the initial path automatically occurs.

Run the mpathadm list mpath-support command.


# mpathadm list mpath-support
mpath-support: libmpscsi_vhci.so

Select an mpath support name from the output list.

Run the mpathadm modify mpath-support -a [on | off] mpath-support-name command.


# mpathadm modify mpath-support -a off libmpscsi_vhci.so

Run the mpathadm show mpath-support mpath-support-name command to check the change.


# mpathadm show mpath-support libmpscsi_vhci.so
mpath-support: libmpscsi_vhci.so
     Vendor: Sun Microsystems
     Driver Name:  scsi_vhci
     Default Load Balance:  round-robin
     Supported Load Balance Types:
          round-robin
          logical-block
     Allows To Activate Target Port Group Access:  yes
     Allows path Override:  no
     Supported Auto Failback Config: yes
     Auto Failback:  on
     Failback Polling Rate (current/max):  0/0
     Supported Auto Probing config: no
     Auto Probing:  NA
     probing Polling Rate (current/max):  NA/NA
     Supported Devices:
          Vendor:  SUN
          Product:  T300
          Revision:
          Supported Load Balance Types:
               round-robin
          Vendor:  SUN
          Product:  T4
          Revision:
          Supported Load Balance Types:
               round-robin
Note –
The auto-failback display initiated by the mpathadm modify command setting is effective while the system is running. However, to keep the changed setting persistent, you must update the /kernel/drv/scsi_vhci.conf file. Refer to Configuring Automatic Failback.

ProcedureTo Fail Over a Logical Unit
This operation is applicable only to devices in the following two categories:

Asymmetric devices with a proprietary failover mechanism recognized and supported by multipathing support

Devices conforming to the T10 Standard Target Port Group Support libmpscsi_vhci.so and providing explicit mode asymmetric logical unit access

Run the mpathadm list lu command.


# mpathadm list lu
    /dev/rdsk/c4t60020F20000035AF4267CCCB0002CEE2d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
        Total Path Count: 2
        Operational Path Count: 2
    /dev/rdsk/c4t60003BA27D2120004204AC1A000F1D6Cd0s2
        Total Path Count: 2
        Operational Path Count: 2

Select a logical unit name from the output.

Run the mpathadm show lu logical-unit-name command.


# mpathadm show lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
logical unit: /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
    mpath-support libmpscsi_vhci.so
     Vendor:  SUN
     Product:  T4
     Revision:  0301
     Name Type:  SCSI Inquiry VPD page 83 type 3
    Name:  60003ba27d2120004204ac2b000dab00
     Asymmetric:  yes
     Current Load Balance:  round-robin
     Logical Unit Group ID:  NA
     Auto Failback:  on
     Auto Probing:  NA

     Paths:
          Initiator Port Name:  2000000173818713
          Target Port Name:  20030003ba27d212
          Override Path:  NA
          Path State:  OK
          Disabled:  no

         Initiator Port Name:  2000000173018713
          Target Port Name:  20030003ba27d095
          Override path:  NA
          Path State:  OK
          Disabled:  no

     Target Port Groups:
          ID:  2
          Explicit Failover:  yes
          Access State:  standby
          Target Ports:
               Name:  20030003ba27d212
               Relative ID:  0
    
          ID:  5
          Explicit Failover:  yes
          Access State:  active
          Target Ports:
               Name:  20030003ba27d095
          Relative ID:  0
Run the mpathadm failover lu logical-unit-name command.


# mpathadm failover lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
If this operation is successful, the access state of the devices’ target port groups changes as a result of the logical unit failover.

Run the mpathadm show lu logical-unit-name command to verify the access state change.


# mpathadm show lu /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
logical unit: /dev/rdsk/c4t60003BA27D2120004204AC2B000DAB00d0s2
    mpath-support libmpscsi_vhci.so
     Vendor:  SUN
     Product:  T4
     Revision:  0301
     Name Type:  SCSI Inquiry VPD page 83 type 3
    Name:  60003ba27d2120004204ac2b000dab00
     Asymmetric:  yes
     Current Load Balance:  round-robin
     Logical Unit Group ID:  NA
     Auto Failback:  on
     Auto Probing:  NA

     Paths:
          Initiator Port Name:  2000000173818713
          Target Port Name:  20030003ba27d212
          Override Path:  NA
          Path State:  OK
          Disabled:  no

         Initiator Port Name:  2000000173018713
          Target Port Name:  20030003ba27d095
          Override path:  NA
          Path State:  OK
          Disabled:  no

     Target Port Groups:
          ID:  2
          Explicit Failover:  yes
          Access State: active
          Target Ports:
               Name:  20030003ba27d212
               Relative ID:  0
    
          ID:  5
          Explicit Failover:  yes
          Access State: standby
          Target Ports:
               Name:  20030003ba27d095
          Relative ID:  0

Featured Post

Managing CA Certificates on Red Hat Linux 9: Understanding update-ca-trust extract

  Managing CA Certificates on RHEL9 RHEL8 OracleLinux9 OracleLinux8 In today's digital landscape, securing communications and verifying ...