Posts

Showing posts from 2017

High process count notification - shell script

#Author : Jaison # Purpose : To send email to the user when a user hit a specific process count list. process_count="$(ps -u root  -L | wc -l)" if [ "$process_count" -gt "10000" ]; then  Email_Body='Test"   echo "$Email_Body" | /usr/bin/mail -s "Server $HOSTNAME Process Count : $process_count IS A LARGE VALUE FOR  USER. CHECK IMMEDIATELY. " <email_account> fi

useradd shell script - bulk read username and password from file.

# Author : Jaison #Purpose : Add user and set their password from the text file all.txt file_name="all.txt" while read user pass do     #useradd ${user} -p ${pass}     useradd ${user}     echo "${pass}" | passwd --stdin ${user}     echo "Adding user "${user}"  with the password  "${pass} done < $file_name

DNS - A simple explanation.

Hi All, Let me try to throw some pebbles regarding the DNS, one of the simplest concepts on the internet, but if explained properly, it can go into a high level of complexity. DNS is something which is used to identify the devices which are connected to the internet.Before jumping into the concept of DNS, I hope everyone who is reading this chapter is aware of IP Adress. If not, IP Address or in short IP is a set of numbers and symbols used to identify machines connected on the internet. So we already have IP so you might be thinking what is the need of DNS in the world?? Well, that is the problem with the humans, we are good with names but not so good with the numbers. To overcome this problem, we are using DNS. Domain Name System in the point of view of a System Administrator is something unavoidable when it comes to hosting the websites on the server. The simple concept of how it works is explained in my propensity as shown below. When a website is accessed on a web b

Cheat sheet for Hardware RAID health check - Megaraid, Adaptec, 3wareraid and HPraid.

Hi Folks, In another post " raid type " I've mentioned how to find if the server is running with Software or Hardware RAID. Here, we can go ahead and check the health of the Hardware RAID array in the server. The first thing we need to detect is the controller in which the raid is configured and you can easily get it from the another post that I mentioned earlier. However, I'm providing it here again for your convenience. 1. Login to the server as the root user. 2. Execute the following command. /sbin/lspci -vv | grep -i raid 3. This will show the raid controller running on the server. The different types of controller I've worked with includes a. Megaraid which uses megacli b. Adaptec which uses arcconf . c. 3ware raid which uses tw_cli d. HPraid which uses hpacucli . How to check the Megaraid array health status? The Megaraid is usually installed in the /opt/MegaRAID and you can execute the following command to verify the health of the arr

Logical volume vmxxxx_img is used by another device - Error on LVM removal

Hi Folks, I've faced error while trying to remove an LVM from the server. The exact LVM error will be "Logical volume vmxxxx_img is used by another device" on executing the lvremove command. Feel free to remove the following steps to remove the LVM from the server. Note: Please remember to replace <id> with your  VMID in the below section. ---------------------------------------------------------- dmsetup ls dmsetup info -c xen-vm<id>_img dmsetup remove xen-vm<id>_img lvremove -f /dev/xen/vm<id>_img ----------------------------------------------------------

File system corrupted on the OpenVZ container.

It happens rarely but when it does, it is hard to handle. The OpenVZ VM's are usually stable in nature, but I've encountered situations where OpenVZ VM was showing file system error and was refusing to start. You can follow the below steps to recover the VM. 1. ~# vzctl stop ctid 2. # ploop mount /vz/private/ctid/root.hdd/ DiskDescriptor.xml 3. now do a df -h and you will get the ploop id for the VM. 4. fdisk -l /dev/ploop12345 5. e2fsck /dev/ploop12345p1 6. ploop umount -d /dev/ploop12345 7. vzctl start ctid

Change IO Scheduler for SSD and HDD server with Software RAID

Hi Guys, It has been a while... I faced a problem with IO on one of the RAID 1 Linux servers and the IO schedulers were the default cfq in the server. It doesn't matter if the drive is in software RAID or not. If you are using SSD drives, then there are no mechanical parts in the HDD, so you need to change the IO schedulers to noop. If the SSD drive is mounted as /hda, then below command will do it. ---------------------------------------------------------- echo noop > /sys/block/hda/queue/scheduler ---------------------------------------------------------- For the HDD drive, the scheduler that is recommended is `deadline` in case of poor performance problems. ---------------------------------------------------------- echo deadline > /sys/block/hdb/queue/scheduler ---------------------------------------------------------- In case of Software RAID, just make sure that the drive you are changing the scheduler is inside the RAID. You can see the drives ins

Check the number of connections using nf_conntrack or using tcpdump

tcpdump -tnn -ieth0 -c 20000 | awk -F ">" '{print $1}' | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | awk ' $1 > 100 ' Note : If the network interface card in use on the server is eth0 cat /proc/net/nf_conntrack > contoutput && cat  contoutput  | awk '{ print $7,$8 }' | sort | uniq -c | sort -rn | head