Tuesday, 31 January 2017

Network Monitoring Application

Nagios

 It is an Open Source system and network monitoring application. It watches hosts and services and alerting you when things go bad and when they get better.

Nagios Features:-

     Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
     Monitoring of host resources (processor load, disk usage, etc.)
     Simple plugin design that allows users to easily develop their own service checks
     Parallelized service checks
     Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
     Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)
     Ability to define event handlers to be run during service or host events for proactive problem resolution
     Automatic log file rotation
     Support for implementing redundant monitoring hosts
     Optional web interface for viewing current network status, notification and problem history, log file, etc.

How Nagios WORKs:-
     Nagios will execute the check_nrpe plugin and tell what service is monitor ,it contacts the NRPE deamon on the remote host through the ssl connection.
     Then the nrpe daemon runs the nagios plugin to monitor the service and the result pass to the nagios back to the monitoring host.

DIRECT CHECK:--
     Monitor the local service of the remote host like disk usage ,memory usage ,current users ,processes, etc.

INDIRECT CHECKS:--
     Monitor the public services of the other systems which is not reachable directly to the monitoring server through the remote host which is directly connect to the monitoring server.

===========================
NRPE:
The NRPE addon consists of two pieces:
– The check_nrpe plugin, which resides on the local monitoring machine
– The NRPE daemon, which runs on the remote Linux/Unix machine.
Process FLOW:-
Nagios Server (check_nrpe) —–> Remote host (NRPE deamon) —–> check_disk
Nagios Server (check_nrpe) <—– Remote host (NRPE deamon) <—– check_disk (returns disk space usage)

Nagios server and nagios plugin installations steps.

Step 1: Install Required Dependencies
We need to install ApachePHP and some libraries like gccglibcglibc-common and GDlibraries and its development libraries before installing Nagios 4.0.1 with source. And to do so we can use yum default package installer.
[root@soni-laptop]# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp 
Step 2: Create Nagios User and Group
Create a new nagios user and nagcmd group account and set a password.
[root@soni-laptop]# useradd nagios
[root@soni-laptop]# groupadd nagcmd
Next, add both the nagios user and the apache user to the nagcmd group.
[root@soni-laptop]# usermod -G nagcmd nagios
[root@soni-laptop]# usermod -G nagcmd apache
Step 3: Download Nagios Core 4.0.1 and Nagios Plugin 1.5
Create a directory for your Nagios installation and all its future downloads.
[root@soni-Kmint]# mkdir /root/nagios
[root@soni-Kmint]# cd /root/nagios
Now download latest Nagios Core 4.0.1 and Nagios plugins 1.5 packages with wget command.
[root@soni-Kmint nagios~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz
[root@soni-Kmint nagios~]# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
Step 4: Extract Nagios Core and its Plugins
We need to extract downloaded package with tar command as follows.
[root@soni-Kmint nagios~]# tar –xvf nagios-4.0.1.tar.gz
[root@soni-Kmint nagios~]# tar –xvf nagios-plugins-1.5.tar.gz
When you extract these tarballs with tar command, two new folders will appear in that directory.
[root@soni-Kmint nagios ~]# ll
total 3712
drwxrwxr-x 18 root root    4096 Oct 17 03:28 nagios-4.0.1
-rw-r--r--  1 root root 1695367 Oct 15 19:49 nagios-4.0.1.tar.gz
drwxr-xr-x 15  200  300    4096 Oct 14 10:18 nagios-plugins-1.5
-rw-r--r--  1 root root 2428258 Oct  2 11:27 nagios-plugins-1.5.tar.gz
Configure Nagios Core
Now, first we will configure Nagios Core and to do so we need to go to Nagios directory and run configure file and if everything goes fine, it will show the output in the end as sample output. Please see below.
[root@soni-Kmint nagios~]# cd nagios-4.0.1
[root@soni-Kmint nagios-4.0.1 ]# ./configure --with-command-group=nagcmd
Sample output:
Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu
  Web Interface Options:
HTML URL:  http://localhost/nagios/
CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /bin/traceroute
 Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.
Now, after configuring we need to Compile and install all the binaries with make command and make install command will install all the needed libraries in your machine and we can proceed further.
[root@soni-Kmint nagios-4.0.1 ]# make all
[root@soni-Kmint nagios-4.0.1 ]# make install
Sample output:
*** Main program, CGIs and HTML files installed ***
 You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
 make install-init
 - This installs the init script in /etc/rc.d/init.d
  make install-commandmode
This installs and configures permissions on the
directory for holding the external command file
 =>  make install-config #This installs sample config files in /usr/local/nagios/etc
Following command will install the init scripts for Nagios..
[root@soni-Kmint nagios-4.0.1 ]# make install-init
To make nagios work from command line we need to install command-mode.
[root@soni-Kmint nagios-4.0.1 ]# make install-commandmode
Next, install sample nagios files, please run following command.
[root@soni-Kmint nagios-4.0.1 ]# make install-config
Sample output:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
Step 5: Customizing Nagios Configuration
Open the “contacts.cfg” file with your choice of editor and set the email addressassociated with the nagiosadmin contact definition to receiving email alerts.
# vi /usr/local/nagios/etc/objects/contacts.cfg
Sample Output
# CONTACTS
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
 define contact{
       contact_name                    nagiosadmin             ; Short name of user
       use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
       alias                           Nagios Admin            ; Full name of user
  email                           soni-Kmint@soni-Kmint.com     ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****
       }
Step 6: Install and Configure Web Interface for Nagios
We are done with all configuration in the backend, now we will configure Web Interface For Nagios with following command. The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.
[root@soni-Kmint nagios-4.0.1 ]# make install-webconf
In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when you login in the Nagios Web interface.
[root@soni-Kmint nagios-4.0.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
Restart Apache to make the new settings take effect.
[root@soni-Kmint ]# service httpd start (On RedHat / CentOS)
[root@soni-Kmint ]# systemctl start httpd.service (On Fedora)
Step 7: Compile and Install Nagios Plugin
We have downloaded nagios plugins in /root/nagios, Go there and configure and install it as directed below.
[root@soni-Kmint nagios]# cd /root/nagios
[root@soni-Kmint nagios]# cd nagios-plugins-1.5
[root@soni-Kmint nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@soni-Kmint nagios]# make
[root@soni-Kmint nagios]# make install
Step 8: Verify Nagios Configuration Files
Now we are all done with Nagios configuration and its time to verify it and to do so please insert following command. If everything goes smooth it will show up similar to below output.
[root@soni-Kmint nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Sample Output
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
 *** Nagios/Apache conf file installed ***
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Step 9: Add Nagios Services to System Startup
To make Nagios work across reboots, we need to add nagios and httpd with chkconfigcommand.
[root@soni-Kmint ]# chkconfig --add nagios
[root@soni-Kmint ]# chkconfig --level 35 nagios on
[root@soni-Kmint ]# chkconfig --add httpd
[root@soni-Kmint ]# chkconfig --level 35 httpd on
Restart Nagios to make the new settings take effect.
[root@soni-Kmint ]# service nagios start (On RedHat / CentOS)
[root@soni-Kmint ]# systemctl start nagios.service (On Fedora)

Friday, 13 January 2017

AD Domain Join by Windows 7

                                         How to join the domain by windows 7 client machine

In this article I will be showing you how to successfully join Windows 7 to a domain, and then how to log on to the machine with your domain credentials.
You will have first to configure your networking settings, so that your machine would be able to properly communicate with your Domain Controller.

1.       First of all go to run and then cmd then type ipconfig here you will get the ip address like 192.168.0.60



2.       Then ping with samba server 192.168.0.253 if you get reply you can join the domain if you cannot get reply check your lan cable .




3.Then go to run and type edit group policy –then go on computer configuration then double click on administrative templetes then double click on systems then double click on user profiles.

(a)    Right click on only allow users of local profiles then edit then click on enable and apply and ok.
(b)   right click on only do not log user with on with temporary profiles then edit then click on enable and apply and ok


4.Then again go to start run and type gpupdate. then it will give the message your policy is updated 


5.       now go to start –run – regedit –then go to HKEY_LOCAL_MACHINE  then click on system then you will find a option current control set  then click on services  and you will find a  option lan man work station then click on parameter.












(a)    on the right sight right click on white screen you find new then select  D-WORD (32 bit) value and type DNSNameResolutionRequired and right click on this and click on modify and put binary value 0.
(b)   Again  on the right sight right click on white screen you find new then select  D-WORD (32 bit) value and type DomainCompatibilityMode  and right click on this and click on modify and put binary value 1.

6.       Right Click on network on desktop then click on properties , then you will find the option local area    connection click on this then click on properties and double click on ipv4  then click on advance here you find three tabs dns ,wins  and ipsetting . Click on wins and click on add give the ip of samba server 192.168.0.253 and click ok.










7.   Now restart you pc.
      8. Then start my computer ---> properties----advance system setting then click on   computer name     

      here you will get the option change. Click on change then you will find two options Domain an
      Work   group click on domain and give the domain name hcsindin then ok.







9. Then it will give the message welcome to hcsindin domain then it will ask to restart the pc
            10. Then restart the pc and you will find that you have joined in domain.
            11. Now press ctl+atl+Del and enter your user name and password.