Monit is a  a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.  

    How to enable Monit?

    Recent versions of BitNami stacks ship Monit configuration files for all servers. If you are using a Virtual Machine or Cloud Image, Monit is already configured and enabled by default. Note the following is only valid for Linux platforms.

    Check the Monit files in the installdir/config/monit folder. If you are using a Virtual Machine or a Cloud Image, installdir is the /opt/bitnami folder.

    You can enable Monit in your machine creating a symbolic link. It is necessary to have already installed Monit from the repositories. For example, in Ubuntu:

    $ sudo apt-get install monit
    $ sudo ln -s installdir/config/monit/bitnami.conf /etc/monit/conf.d/bitnami.conf
    

    For RedHat, CentOS or AWS Linux:

    $ sudo yum install monit
    $ sudo ln -s installdir/config/monit/bitnami.conf /etc/monit.d/bitnami.conf

    Note: If you do not find Monit package in your repositories, add the EPEL repository in your repository list.

    How to check Monit configuration?

    You can simply check the servers status with the following command:

    $ sudo monit status

    At this point you should see the servers that Monit is monitoring and the machine stats:

    The Monit daemon 5.5.1 uptime: 1d 19h 35m 
    Process 'mysql'
      status                            Running
      monitoring status                 Monitored
      pid                               27154
      parent pid                        26893
      uptime                            1m 
      children                          0
      memory kilobytes                  38428
      memory kilobytes total            38428
      memory percent                    0.2%
      memory percent total              0.2%
      cpu percent                       0.0%
      cpu percent total                 0.0%
      data collected                    Thu, 15 Aug 2013 13:39:06
    Process 'apache'
      status                            Running
      monitoring status                 Monitored
      pid                               27205
      parent pid                        1
      uptime                            1m 
      children                          8
      memory kilobytes                  13500
      memory kilobytes total            86504
      memory percent                    0.0%
      memory percent total              0.5%
      cpu percent                       0.0%
      cpu percent total                 0.0%
      data collected                    Thu, 15 Aug 2013 13:39:06
    System 'desktop'
      status                            Running
      monitoring status                 Monitored
      load average                      [0.14] [0.21] [0.22]
      cpu                               0.9%us 0.7%sy 0.0%wa
      memory usage                      7113496 kB [43.5%]
      swap usage                        182008 kB [1.1%]
      data collected                    Thu, 15 Aug 2013 13:39:06
     

    Monit is also includes a small httpd application where you can manage the servers. It only works from localhost by default but you can add your IP address in the "/installdir/config/monit/bitnami.conf" configuration file:

    # BitNami configuration file for Monit.
    set httpd port 2812 and
        use address localhost
        allow localhost
    include installdir/config/monit/conf.d/*.conf 

    If you have installed the stack in your own machine, you can access to the Monit Server Manager at http://localhost:2812

    monit.png

    How to configure my server with Monit?

    You can find all Monit configuration files for the Bitnami servers in the "installdir/config/monit/conf.d" folder. For example, the Apache Monit config file:

    check process apache
     with pidfile "/installdir/apache2/logs/httpd.pid"
     start program = "/installdir/apache2/scripts/ctl.sh start" with timeout 90 seconds
     stop program = "/installdir/apache2/scripts/ctl.sh stop"
     
    As you can see in the above example, it is ponly necessary to specify the PID file location and the commands to start/stop the server. You can find more configuration options at the Monit documentation.
     
    Once you created your own config file for your server, add it to the same folder. To reinitialize monit you can run the following command:
    $ sudo monit reload

    How to disable Monit?

    If you want to disable one server, you can run the following comand to disable it. For example, Apache server:

    $ sudo monit unmonitor apache

    You can also stop the monit process with the following command:

    $ sudo monit quit

    How to access to the Monit WebGUI?

    Amazon cloud / BitNami Hosting

    By default Monit WebGUI is not accessible from the outside for security reasons. In order to access it, you can create an SSH tunnel to the default Monit Port (2812) , sending your requests to your Monit WebGUI from 127.0.0.1 (localhost).

    You should follow these steps to create the tunnel:

    1. Get your SSH private key if you don't have it already. More info

    2. Create the tunnel.

    - If you are in Linux or Mac you can run the following in a Terminal in your local machine (using your Public DNS instead of xyz.bitnamiapp.com):

    $ ssh -N -L 2812:127.0.0.1:2812 -i bitnami-hosting.pem bitnami@xyz.bitnamiapp.com
    

    - If you are using Windows, you can use Putty:

    • Follow the steps described here
    • Before opening the connection. Go to Connection -> SSH -> Tunnels, enter the values below and click "Add" button:
      • Source port: "2812"
      • Destination: "localhost:2812" 
    • Click Open

    3. While the tunnel is active you can connect to the Monit WebGUI at http://127.0.0.1:2812  in your browser.

    Virtual Machine

    If you are running the Virtual Appliance in a secure environment, you can enable it by editing the "installdir/config/monit/bitnami.conf" file and replace "use address localhost" with "use address SERVER_IP" and "allow localhost" with "allow 0.0.0.0/0":

    # Bitnami configuration file for Monit.
    set httpd port 2812 and
        use address SERVER_IP
        allow 0.0.0.0/0
    include /opt/bitnami/config/monit/conf.d/*.conf
    

    Then you should restart Monit to load the changes:

    $ /etc/init.d/monit restart
    

    Then you can access at the same URL with http://SERVER_IP:2812/monit

    Azure cloud

    By default Monit WebGUI is not accessible from the outside for security reasons. In order to access it, you can create an SSH tunnel to the default Monit Port (2812) , sending your requests to your Monit WebGUI from 127.0.0.1 (localhost).

    You should follow these steps to create the tunnel:

    1. Create the tunnel.

    - If you are in Linux or Mac you can run the following in a Terminal in your local machine (using your Public DNS instead of xyz.bitnamiapp.com):

    $ ssh -N -L 2812:127.0.0.1:2812 -i bitnami-hosting.pem bitnami@xyz.bitnamiapp.com
    

    - If you are using Windows, you can use Putty:

    • Follow the steps described here
    • Before opening the connection. Go to Connection -> SSH -> Tunnels, enter the values below and click "Add" button:
      • Source port: "2812"
      • Destination: "localhost:2812" 
    • Click Open

    2. While the tunnel is active you can connect to the Monit WebGUI at http://127.0.0.1:2812  in your browser.

    Tabs end

    Tag page (Edit tags)
    • No tags
    Page statistics
    10174 view(s), 11 edit(s) and 9971 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     monit.png
    Monit sample
    55.24 kB11:52, 15 Aug 2013AdminActions