Posts

Hung Puppet process on Linux

Kill Hung Puppet process . kill -9 `ps -ef |grep "puppet agent: applying configurat" |grep -ve grep |awk '{print $2}'` /etc/init.d/puppet restart ps -ef |grep -i puppet | grep -v grep

What is IP: 0.0.0.0

In the context of a route entry, it usually means the default route. In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.

Linux based file systems become read-only

On a Linux server, when it loses connectivity to underlying storage (even briefly), the server doesn’t typically crash. It keeps running, but switches all the storage to read-only. Most of the OS and applications are running in RAM, so you don’t necessarily see any issues right away. The main issue we see is the OS and applications hold things in the disk-write queues. When you force the reboot after the storage outage, the kernel gets out-of-whack because that disk queue couldn’t clear properly and now doesn’t match the disks. So, we have to reboot and log in with root password under maintenance mode and force a disk check on the root and app file-systems. Once that is done, the host comes back online without issue.

Kernel Panic Error

Recently, I came across the situation where my CentOS server was not booting and displaying Kernel panic error. I have followed the steps mentioned below to make the server online: I spawned the init as bash. This can be done by giving the following boot parameter.   Init=/bin/bash   Once we have the bash prompt we can remount the root partition in read write mode.   Mount –o remount,rw /   Then change the password:   Password root   Once the password is changed reboot the system. It will ask for the fsck and maintenance password. Enter newly changed maintenance password.

Common ports used in Linux

20 FTP data (File Transfer Protocol)  21 FTP (File Transfer Protocol)  22 SSH (Secure Shell)  23 Telnet  25 SMTP (Send Mail Transfer Protocol)  43 whois  53 DNS (Domain Name Service)  68 DHCP (Dynamic Host Control Protocol)  79 Finger  80 HTTP (HyperText Transfer Protocol)  110 POP3 (Post Office Protocol, version 3)  115 SFTP (Secure File Transfer Protocol)  119 NNTP (Network New Transfer Protocol)  123 NTP (Network Time Protocol)  137 NetBIOS-ns  138 NetBIOS-dgm  139 NetBIOS  143 IMAP (Internet Message Access Protocol)  161 SNMP (Simple Network Management Protocol)  194 IRC (Internet Relay Chat)  220 IMAP3 (Internet Message Access Protocol 3)  389 LDAP (Lightweight Directory Access Protocol)  443 SSL (Secure Socket Layer)  445 SMB (NetBIOS over TCP)  666 Doom  993 SIMAP (Secure Internet Message Access Protocol)  995 SPOP (Secure Po...

Find command usage in *nix

• Find all files of a given type from current directory on down: find ./ -name "*.conf" -print • Find all user files larger than 5Mb: find /home -size +5000000c -print • Find all files owned by a user (defined by user id number. see /etc/passwd) on the system: (could take a very long time) find / -user 501 -print • Find all files created or updated in the last five minutes: (Great for finding effects of make install) find / -cmin -5 • Find all users in group 20 and change them to group 102: (execute as root) find / -group 20 -exec chown :102 {} \; • Find all suid and setgid executables: find / \( -perm -4000 -o -perm -2000 \) -type f -exec ls -ldb {} \; find / -type f -perm +6000 -ls Note: suid executable binaries are programs which switch to root privileges to perform their tasks. These are created by applying a "sticky" bit: chmod +s. These programs should be watched as they are often the first point of entry for hackers. Thus it is prud...

Add Swap Memory

You can add Swap memory in the server through creating a swap file. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks (here adding 2 GB to Swap): When you add a swap file, you leave existing alone, just swapon a new one. # dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152   [bs=block size, count= 1024*2048(2gb)=2097152] # mkswap /swapfile1 # chown root:root /swapfile1 # chmod 0600 /swapfile1 # swapon /swapfile1 Now verify the added Swap memory : # free -m  # cat /proc/swaps  Notes:  1. No need of swapoff, if you swapoff the existing swap you can crash the host, because may be the system have not enough memory to take over the current swap in use. (always make sure RAM is free before going to do swapoff -a). 2. Making swap space changes persistent As with filesystems, changes made by swapon are not persistent; to have swap added at boot time, create a line in /etc/fstab like this: ...

High Load on *nix servers

To check and reduce the load, I am pasting the commands which will provide you the outputs concerned with high load. Accordingly, you can troubleshoot the issue to reduce the load. 1.Get server uptime with uptime command: $ uptime 2. Gather information like tasks, memory, cpu and swap through Top command: $ top -cd3 Use "Shift +m" to order the memory usage from maximum to minimum. You can use "Shift +o" to choose different options also. 3. See the Load average, memory usage and CPU usage with Sar command: $ sar $ sar -q $ sar -r 4. Check top 10 memory hungry processes using following command: $ ps auxxx --sort=-rss | head -11 5. Check top 10 cpu hungry processes using following command: $ ps auxxx --sort=-%cpu | head -11 6. Check mpstat result with following: $ /usr/bin/mpstat -P ALL 7. Check iostat with iostat command. $ iostat 8. Check free RAM on the server: $ free -m 9. Use pstree to look for any suspicious processes or u...

It's about Bangalore !!!

Hi Folks, This Blog is not technical, but about my new destination, Bangalore. Earlier I have worked in three different cities Jabalpur, Kochi and Mangalore but Bangalore seem different. The first thing you will notice about this city is It's awesome weather. If you have been in Bangalore, no need to explain it to you. When I reached Bangalore in the morning and put my first step on the Road, a cold breeze of Air has welcomed me with all its warm affection towards the newcomer. I must say, It was a pleasant morning, even after a tiresome journey from Mangalore to Bangalore. I found this city as Blend of different cultures and everything is going in Harmony. There are people from every corner of India. They celebrate every festival with the same Joy and Happiness what you find in your place. Currently, the Ganesha Chaturthi festival is in celebration here and its surprise to see the same ebullience and exhilaration as in Maharastra towards Bappa(Lord Ganesha). Further, I wa...

PHP functions checker code

<?php if (function_exists('imap_open')) {     echo "IMAP functions are available.<br />\n"; } else {     echo "IMAP functions are not available.<br />\n"; } if (function_exists('dir')){     echo "dir functions are available.<br />\n"; } else {     echo "dir functions are not available.<br />\n"; } if (function_exists('readdir')) {         echo "readdir functions are available.<br />\n"; } else {     echo "readdr functions are not available.<br />\n"; } if (function_exists('opendir')) {         echo "opendir functions are available.<br />\n"; } else {     echo "opendir functions are not available.<br />\n"; } if (function_exists('eval')) {         echo "eval functions are available.<br />\n"; } else {     echo "eval functions are not available.<br />\n"; } if ...