ManyCodes.com – codes & scripts Get free programming codes and tutorials!

21Aug/093

Ubuntu / Debian Linux: Install Monit Linux Server Monitoring Utility

How do I install monit to monitor my server under Debian / Ubuntu Linux?

Monit is a utility for managing and monitoring processes, files, directories and devices on a Debian / Ubuntu Linux server system. Here a few common uses of monit:

  1. Monit can start a process if it does not run
  2. Restart a process if it does not respond
  3. Stop a process if it uses to much resources etc

How do I install monit utility for monitoring services?

Type the following command as the root user:

$ sudo apt-get update
 $ sudo apt-get install monit

Configure monit

Open monit configuration file /etc/monit/monitrc using vi text editor or nano command in linux:

# vi /etc/monit/monitrc

OR

# nano /etc/monit/monitrc

You need to set following parameters:

set daemon  120
 set logfile syslog facility log_daemon
 set mailserver localhost               # primary mailserver
 set alert vivek@nixcraft.com                       # receive all alerts

The next step is to save and close this file. Where,

  • set daemon 120 : Start monit in background as daemon and check the services at 2-minute intervals.
  • set logfile syslog facility log_daemon : Log messages in /var/log/messsages file
  • set mailserver localhost : Send email alert via localmail server such as sendmail. Set list of mailservers for alert delivery. Multiple servers may be specified using comma separator. By default monit uses port 25 - it is possible to override it with the PORT option.
  • set alert vivek@nixcraft.com : You can set the alert recipients here, which will receive the alert for each service. The event alerts may be restricted using the list.

Now open /etc/default/monit file to turn on monit service:

# vi /etc/default/monit

OR

# nano /etc/default/monit

Set startup to 1, so monit can start:

startup=1

Save and close the file.

Start the monit Linux monitor tool / service:

# /etc/init.d/monit start
10Aug/090

How to install webmin on your Linux web server (Redhat Fedora Caldera Mandrake SuSE MSC)

Installing webmin on your linux webserver is easy. With webmin, you can use ispconfig which is a web hosting script that you can use to host many website in one server.
Webmin website: http://www.webmin.com/

Since I have fedora I can install like this:
(this tutorial is suitable for Redhat, SuSE, Caldera, Mandrake or MSC Linux, 13M)

Login to your shell, i will be using ssh so i send this command:

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.350-1.noarch.rpm

Once it has finished downloadin i send this command:

rpm -U webmin-1.350-1.noarch.rpm

(make sure to use upper case U above)

The rest of the install will be done automatically to the directory /usr/libexec/webmin, the administration username set to root and the password to your current root password. You should now be able to login to Webmin at the URL http://localhost:10000/ .

Webmin install complete. You can now login to https://hostname.domain:10000/
as root with your root password.

NOTE: the default login and password is your root and root password. this is the same login you used with you ssh to your server or whatever your root password is, so your login will be like this:

Username: root
Password: xxxx (what ever your root password is)

5Aug/091

Install the Latest PostgreSQL Yum Repository for CentOS

Keeping PostgreSQL updated via yum should be done via the pgdg yum repository supplied by pgsqlrpms.org.

The latest CentOS PostgreSQL repo can be viewed here.

You will need to download the repo and then install using rpm as shown below.

wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-1.noarch.rpm</span></div>
<div style="width: 506px;">rpm<span> -Uhv</span><span> pgdg-centos-8.4-1.noarch.rpm

wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-1.noarch.rpm
rpm -Uhv pgdg-centos-8.4-1.noarch.rpm

Another helpful postgresql install and management link is located here.

5Aug/090

How to Install the Latest git on CentOS 5 from Source

To install the latest git on CentOS 5 you will need to install from source since the yum repos are typically fairly far behind. Follow the instructions below and installing git will be a snap.

  1. Install Dependencies: First we need to install a couple packages via yum to cover the dependencies for building git from source.
  2. [root@server ~]#yum install curl-devel
    [root@server ~]#yum install expat-devel
    [root@server ~]#yum install gettext-devel
    [root@server ~]#yum install openssl-devel
    [root@server ~]#yum install zlib-devel 
[root@server ~]#yum install curl-devel
[root@server ~]#yum install expat-devel
[root@server ~]#yum install gettext-devel
[root@server ~]#yum install openssl-devel
[root@server ~]#yum install zlib-devel
  • Download git Source: Now download the git source by issuing the below command. Verify the latest source here.
  • [root@server ~]#cd /usr/local/src
    [root@server ~]# wget http://www.kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz
    

    [root@server ~]#cd /usr/local/src
    [root@server ~]# wget http://www.kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz
  • Build Source:Unpack the file that has been downloaded and compile the source using the “make” command.
  • [root@server ~]#tar -zxvf git-1.6.0.4.tar.gz
    [root@server ~]#cd git-1.6.0.4
    [root@server ~]#make prefix=/usr/local all
    
    [root@server ~]#tar -zxvf git-1.6.0.4.tar.gz
    [root@server ~]#cd git-1.6.0.4
    [root@server ~]#make prefix=/usr/local all
  • Install git: After successfully compiling the source you need to install git.
  • [root@server ~]#make prefix=/usr/local/ install
    
    [root@server ~]#make prefix=/usr/local/ install
  • Download git Manpages:Now let’s download the manpages. Verify the latest manpages here.
  • [root@server ~]#cd /usr/local/src
    [root@server ~]#wget http://www.kernel.org/pub/software/scm/git/git-manpages-1.6.0.4.tar.gz
    [root@server ~]#cd /usr/local/src
    [root@server ~]#wget http://www.kernel.org/pub/software/scm/git/git-manpages-1.6.0.4.tar.gz
  • Install git Manpages:Now change into the share directory and unpack the git manpages.
  • [root@server ~]#cd /usr/local/share/man
    [root@server ~]#tar -zxvf /usr/local/src/git-manpages-1.6.0.4.tar.gz
    
    [root@server ~]#cd /usr/local/share/man
    [root@server ~]#tar -zxvf /usr/local/src/git-manpages-1.6.0.4.tar.gz
  • Verify:Lets verify that git was installed successfully and the manpages are working properly.
  • [root@server ~]#git --version
    [root@server ~]#man git
    
    [root@server ~]#git --version
    [root@server ~]#man git

    After following the above steps you should be able to successfully use git.

    [root@server ~]#yum install curl-devel
    [root@server ~]#yum install expat-devel
    [root@server ~]#yum install gettext-devel
    [root@server ~]#yum install openssl-devel
    [root@server ~]#yum install zlib-devel

    5Aug/090

    Install istat On a CentOS Linux to Monitor Server from iPhone or Touch

    The istat application is a monitoring application that can be used to obtain basic Linux server information from your iPhone or iPod Touch phone. This application has the ability to monitor CPU Usage, Memory Usage, Disk Usage, CPU Load, and Server  Uptime among many others.

    istat: Linux Server Monitor From iPhone

    To install istat on CentOS Linux follow the directions below.

    1. Download istat: Download istat for Linux here.
    2. Configure istat: Unpack the istat package you downloaded from Google Code and change the directory into the newly created istat directory. Once in this directory type the below command to configure istat for your server.
      1. ./configure
      ./configure
    3. Install istat: Now issue the make and make install commands to compile and install istat on your server.
      1. make
      2. make install
      make
      make install
    4. Create istat User: Now issue the below command to create a istat user to run istat.
      1. useradd istat
      useradd istat
    5. Create istat Directory: Use the below syntax to create a directory to store the istat.pid file which needs to be readable/writeable by the istat user you just created.
      1. mkdir /var/run/istat
      2. chown istat.istat /var/run/istat
      mkdir /var/run/istat
      chown istat.istat /var/run/istat
    6. Configure istat: Now make necessary configuration changes to the /usr/local/etc/istat.conf configuration file. The typical changes include modifying the server_code which is the access code used by your iDevice to obtain the server information, monitor_net which is the interface istat will listen for incoming connections, and monitor_disk which needs to be changed to the proper mounts such as /dev/hdb1, /dev/hdc1, etc.
    7. Launch istat: Now launch the istat daemon by issuing the below command.
      1. /usr/local/bin/istatd &
      /usr/local/bin/istatd &

      The server will automatically launch with the istat user and listen on port 5109.

    8. Connect From iPhone: Now configure the new server within istat on your iPod Touch or iPhone. Once you do so click on the server, type in the password you set in step 6, and verify you are collecting all of the server statistics properly.

    The istat application is a nifty little application to provide you a quick view of servers on your network or servers that you monitor outside of your network. More information about the iPhone version of istat can be located here.

    21Jul/090

    Install easy_install Via yum on Linux CentOS Server

    To install easy_install on Linux using yum you will need to install the python-setuptools package. Installing this package with yum is easy by following the directions below.

    Run this command in your ssh termianl bash:

    yum install python-setuptools 

    An example of a python-setuptools install is below.

    [root@server ~]# yum install python-setuptools
    Loading "fastestmirror" plugin
    Loading mirror speeds from cached hostfile
    * base: pubmirrors.reflected.net
    * updates: mirrors.serveraxis.net
    * addons: mirror.anl.gov
    * ruby: repo.premiumhelp.eu
    * extras: mirror.sanctuaryhost.com
    Setting up Install Process
    Parsing package install arguments
    Resolving Dependencies
    --> Running transaction check
    ---> Package python-setuptools.noarch 0:0.6c5-2.el5 set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================
    Package Arch Version Repository Size
    =============================================================================
    Installing:
    python-setuptools noarch 0.6c5-2.el5 base 479 k
    
    Transaction Summary
    =============================================================================
    Install 1 Package(s)
    Update 0 Package(s)
    Remove 0 Package(s)
    
    Total download size: 479 k
    Is this ok [y/N]: y
    Downloading Packages:
    (1/1): python-setuptools- 100% |=========================| 479 kB 00:00
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing: python-setuptools ######################### [1/1]
    
    Installed: python-setuptools.noarch 0:0.6c5-2.el5
    Complete!
    
    21Jul/090

    How to Install dig on a CentOS Linux Server?

    Installing dig on a CentOS Linux server is easy with yum. Dig is actually a bind tool so you will be required to install some bind libraries along with the bind utility package.

     [root@server ~]# yum install bind-utils  

    Now you can run something like the below using dig to find MX records.

     [root@server ~]# dig @NAMESERVER EXAMPLE.COM MX  

    Your install will look something like the below showing how yum looks for dependencies and installs them automatically.

    
    [root@server ~]# yum install bind-utils
    Loading "installonlyn" plugin
    Setting up Install Process
    Setting up repositories
    Reading repository metadata in from local files
    Parsing package install arguments
    Resolving Dependencies
    --> Populating transaction set with selected packages. Please wait.
    ---> Downloading header for bind-utils to pack into transaction set.
    bind-utils-9.3.4-6.0.2.P1 100% |=========================| 40 kB 00:00
    ---> Package bind-utils.x86_64 30:9.3.4-6.0.2.P1.el5_2 set to be updated
    --> Running transaction check
    --> Processing Dependency: libisccc.so.0()(64bit) for package: bind-utils
    --> Processing Dependency: bind-libs = 30:9.3.4-6.0.2.P1.el5_2 for package: bind-utils
    --> Processing Dependency: libbind9.so.0()(64bit) for package: bind-utils
    --> Processing Dependency: libdns.so.22()(64bit) for package: bind-utils
    --> Processing Dependency: libisccfg.so.1()(64bit) for package: bind-utils
    --> Processing Dependency: liblwres.so.9()(64bit) for package: bind-utils
    --> Processing Dependency: libisc.so.11()(64bit) for package: bind-utils
    --> Restarting Dependency Resolution with new changes.
    --> Populating transaction set with selected packages. Please wait.
    ---> Downloading header for bind-libs to pack into transaction set.
    bind-libs-9.3.4-6.0.2.P1. 100% |=========================| 41 kB 00:01
    ---> Package bind-libs.x86_64 30:9.3.4-6.0.2.P1.el5_2 set to be updated
    --> Running transaction check
    
    Dependencies Resolved
    
    =============================================================================
    Package Arch Version Repository Size
    =============================================================================
    Installing:
    bind-utils x86_64 30:9.3.4-6.0.2.P1.el5_2 updates 171 k
    Installing for dependencies:
    bind-libs x86_64 30:9.3.4-6.0.2.P1.el5_2 updates 874 k
    
    Transaction Summary
    =============================================================================
    Install 2 Package(s)
    Update 0 Package(s)
    Remove 0 Package(s)
    
    Total download size: 1.0 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/2): bind-libs-9.3.4-6. 100% |=========================| 874 kB 00:35
    (2/2): bind-utils-9.3.4-6 100% |=========================| 171 kB 00:04
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Installing: bind-libs ######################### [1/2]
    Installing: bind-utils ######################### [2/2]
    
    Installed: bind-utils.x86_64 30:9.3.4-6.0.2.P1.el5_2
    Dependency Installed: bind-libs.x86_64 30:9.3.4-6.0.2.P1.el5_2
    Complete!