Monday 5 December 2016

Monitoring Commands For Linux System Administrator Part 1

Top twenty Linux Server Monitoring Commands every Linux System Admin must know: 


 Top   -->  Top commands is used to check cpu most intensive task  running on the server  and process intervals. it can display system summary information as well as a list of task currently being managed by the Linux Kernel.


1#top

option can use:


  • -m     Display floating point value in the memory information.




  • k      kill any high unusable process taken pid  




  • t     display summary information of CPU and task state.




  • z     color 


2#vmstat  (Virtual Memory Statistics)

This command is used to collect and display summary information about operating system memory, processes, interrupts, paging and block i/o. 


  • # vmstat


  • #vmstat -m  (showing cache, number, total, size,  pages,)


  • # vmstat  -a   (showing information of about active/inactive memory swap, io, system ans cpu.)


3# W 

this command displays the information about the users currently logged in on the server from IP and process statistics.



4# uptime

this cmd is used to display the current time, how long the server has been running, how many users are currently logged in the server.



5# ps 

The ps command is used to display information about the currently running processes, including their PID's numbers.  you can take help for more option in man page.



  • # ps -a    


  • #ps -A
    


  • #  ps -AL      showing in long format.

  • # ps -ALF      



  • #ps -ef | grep  (particular name )    this display the particular process id 



  • #   ps -aux    this will provide detailed information



  • #ps -f   -p  (process id )    provide process information 



  • # ps -aux --sort=-pcpu,+pmem   (you can use | less in the last of the commands to make 

results scrollable. you can use also | head -10 in last of the commands to list only numbers ol line only.)


  • # ps -e -o pid,uname,pcpu,pmem,comm



6# Free

free command is use to see the Memory spaces in the system. below is examples to check in different different options:


  • # free 





  • #free -b   (With -b option you will get the memory status in bytes)



  • #free -k  (show in kilobyte)

  • #free -m  (show in megabytes)

  • #free -g (show in gigabytes)

  • #free --tera   (show results in terabyte if you have otherwise cannot show the cmd result)







7#iostat

iostat is system monitoring tool which is used to collect the system i/o for device, physical disks statistics average cpu load stat , it often use to check performance issues with storage devices, local disks and nfs.


    

  • #iostat -c  (will display the cpu statistics)





  • #iostat -d (will display the disk statistics)






  • #iostat -p sda   (it will display the sda HDD all partition status)







  • #iostat -N   (will show you the LVM device, mapper, partition statistics status)






  • # iostat -h  (show the nfs resports)

  • # iostat -k   (show in kb)

  • #iostat -m (show in mb)

  • #iostat -d 2 6   (display six reports at two intervals for devices)

  • # iostat -x (will display extended disk statistics )




8#netstat and ss 

(ss also work smiler netstat )

Netstat is use to display the network connection, routing tables, interface statistics, network interface controller, it list the all tcp,udp sockets connection and socket waiting connections,
it also show musquerade connection.







  • netstat -a    (will show the list of current connections)

  • netstat -at (this option list only tcp connection)

  • netstat -au (for UDP connection)

  • netstat  -ant    (is used to reverse dns lookup.)

  • netstat -tnl (list only network service an open to listen for incoming connections)

  • netstat -tp (will list the PID number of the ESTABLISHED connections)

        netstat -aple (check if a server like http,smtp or ntp)

9#mpstat 
                          Report processors related statistics. The mpstat command writes to standard output activities for each available processor, processor 0 being the first  one. 
                              
                       



mpstat -P ALL 2 5    (list all processes within 2 sec interval for 5 outputs)





There is lot more commands and tools to monitor Linux Servers like:

# iptraf   (need to intall through yum,rpm for first time)
               use to generate various network statistics including tcp info, udp info counts icmp and other protocol information, checksum error.                


10#tcpdump 


tcpdump is used to track network packet analyzer.
prints  out a description of the contents of packets on a network interface that match the boolean expression.  It can also be run with the -w flag, which causes it to save the packet data  to  a  file  for later  analysis,  and/or  with the -r flag, which causes it to read from a saved packet file rather than to read packets from a network interface.  In all cases, only packets that match expression will be  processed by tcpdump.


# tcpdump -i eth0   (it will capture all the packets which is flowing through eth0 interfaces.)


# tcpdump -c 2 -i eth0    (with -c 2 it will capture only 2 counts)



# tcpdump -n -tttt -i eth0 (capture packets with all readable timestamps using -tttt)


# tcpdump -w 000test.pcap -i eth0  (to save the output of the into file 000test.pcap)

# tcpdump -r  000test.pcap  (to read the saved file)



# tcpdump -nl -s 0 -A -i eth0 -c 50 port 80   (this will monitor all port 80 traffic on eth0 and display 50 lines of tcpdump)




Thanks 
your tribute is 

Saturday 12 November 2016

[ Solved ] Broadcom 4312 Wireless Driver For CentOS

I am working on CentOS 6.6 and faced the issue in wireless here share you the findigs how to resolve:

Follow these steps as given below
Step 1 CentOS should be updated through LAN

 # yum update

And then check your device information

#lspci | grep Broadcom


Now if CentOS already updated can check atleast once these required packages:

#yum install kernel-headers kernel-devel gcc

Now Download the CentOS(Linux) Compatibilies Binaries



download in the below directory

#mkdir -p /usr/local/src/hybrid-wl
  
#cd /usr/local/src/hybrid-wl

#chown -R root:root /usr/local/src/hybrid-wl/

Extract Broadcom Driver Archive

#tar -xvzf hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz

Compiling the Broadcom driver module on CentOS

#make -C /lib/modules/`uname -r`/build/ M=`pwd`

#pwd 
/usr/local/src/hybrid-wl/

#make

we hv to run the following sed replacement commands bkz el6 won't compile bkz of the if-then-else clause for kernel Ver check in file wl_cfg802 
   
#sed -i 's/[ >][>=] KERNEL_VERSION(2, 6, 3.)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/[ >][>=] KERNEL_VERSION(3, ., .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/[ >][>=] KERNEL_VERSION(3, 11, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/< KERNEL_VERSION(3, 18, .)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/[ >][>=] KERNEL_VERSION(3, 15, .)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/[ >][>=] KERNEL_VERSION(4, 0, 0)/>= KERNEL_VERSION(2, 6, 32)/' src/wl/sys/wl_cfg80211_hybrid.c

#sed -i 's/< KERNEL_VERSION(4,2,0)/< KERNEL_VERSION(2, 6, 30)/' src/wl/sys/wl_cfg80211_hybrid.c

this replace of sed may not enough for compliation we need to apply this pactch https://wiki.centos.org/HowTos/Laptops/Wireless/Broadcom?action=AttachFile&do=get&target=wl-kmod-fix-ioctl-handling.patch  

#mv /root/Downloads/wl-kmod-fix-ioctl-handling.patch /usr/local/src/

#patch -p1 < ../wl-kmod-fix-ioctl-handling.patch

Compile module again

#make -C /lib/modules/`uname -r`/build/ M=`pwd`

if folder size reduce then your driver is sucussfully complied

#strip --strip-debug wl.ko
  
#modprobe -r bcm43xx

#modprobe -r bcm434312

#modprobe -r b43legacy

#blacklist -r bcma

#blacklist -r brcmsmac

#blacklist -r ssb

#blacklist -r ndiswrapper

copy the file where kernel can read it 

#cp -vi /usr/local/src/hybrid-wl/wl.ko /lib/modules/`uname -r`/extra/

#depmod $(uname -r)

#modprobe wl

with this module load everytime when system boots, by doing this you are prevent these modules from being load into kernel on boot time and may conflict with wl module file.

#vim /etc/modprobe.d/blacklist.conf

blacklist bcm43xx
blacklist b43
blacklist b43legacy
blacklist bcma
blacklist brcmsmac
blacklist ssb
blacklist ndiswrapper

:wq!

                                 Now restart the machine it will work 
Thanks
Vijay Thakur

                                 your contribution for us just Click on Ads.

Thursday 10 November 2016

Nagios Installation Step by Step in Centos

Configuring and Installing Nagios Core 4 on CentOS 6 & 7

Step 1 > download the rpm in /tmp from epel


# wget  http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm      (64bit)

#wget  http://rpms.famillecollet.com/enterprise/remi-release-6.rpm    (64bit)

tmp]#ll -lrt  (you can see the Downloaded rpm)


now change the permission of epel rpm's

#chmod 755 /tmp/epel_press_tab

#chmod 755 /tmp/remi_press_tab

Now you check the permission and install the rpm

#ls -lrt /tmp

#rpm -ivh epel-release*

#rpm -ivh remi-release*

now install the Nagios, Nagios-plugin-all ,nrpe php, httpd


#yum install -y nagios nagios-plugins-all nagios-plugins-nrpe nrpe php httpd 


make sure iptables is off if on then add the following line in iptables

iptables -A INPUT  -m  state  --state NEW -m tcp -p tcp --dport 80  -j ACCEPT


#service iptables restart


now confgiure  the nagios contact file for alerts on email

#vim /etc/nagios/objects/contacts.cfg

go on line number 35

email         replace root@localhost to you email

email        techwithtechie@gmail.com    ;  <<******


:wq!  (Save and exit)


this is optional if you want to access nagios console from particular IP then u can configure


#vi  /etc/httpd/conf.d/nagios.conf


type after open the file   :se nu   (to see line numbers in vim )


after that uncomment the line number 15 and 16


# Order allow, deny
# Allow from all

uncoment both line and now go to the line number 17 18 and 19

# Order deny,allow
# Deny from all
# Allow from 127.0.0.1 10.91.142.101/23

uncomment the all three line

Order deny,allow
Deny from all
Allow from 127.0.0.1 10.91.142.101/23

Now set the password for nagiosadmin user

#htpasswd /etc/nagios/passwd  nagiosadmin
new-passwd:
Re-type-passwd:



Now start the Nagios and httpd services


#/etc/init.d/nagios  start
#/etc/init.d/httpd   start

#chkconfig nagios on
#chkconfig httpd on


now access Nagios Console url:

http://localhost/nagios

http://IP_Address_of_your_system/nagios

http://127.0.0.1/nagios/ 

enter the user name   nagios admin
enter Password what you have set.

Done.




might be someone face error like this

Forbidden

You don't have permission to access /nagios/cgi-bin//status.cgi on this server.
Apache/2.2.15 (CentOS) Server at 10.91.142.101 Port 80

that can be issue of ip conflict issue please set valid IP.

Thanks
Vijay Thakur