Install Monit on CentOS/Redhat

Monit is a free open source tool to monitor and manage linux system and services.

To install Monit on Redhat or CentOS, you need to enable EPEL (Extra Packages for Enterprise Linux). You need to login as root to enable EPEL and install monit.

$ ls /etc/yum.repos.d/

You will see some repo and conf at this path. Eg: redhat-rhui-client-config.repo,  rhel-source.repo, rhui-load-balancers.conf, etc

$ vi /etc/yum.repos.d/epel.repo

Add the following lines:

[epel]
 name=Extra Packages for Enterprise Linux 5 – $basearch
 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
 failovermethod=priority
 enabled=1
 gpgcheck=0

Save and close file

$ yum clean all

Loaded plugins: amazon-id, rhui-lb, security

Cleaning repos: epel rhui-REGION-client-config-server-6 rhui-REGION-rhel-server-releases

              : rhui-REGION-rhel-server-rh-common

Cleaning up Everything

$ yum install monit

Loaded plugins: amazon-id, rhui-lb, security
Setting up Install Process
epel                                          | 3.7 kB     00:00     
epel/primary_db                               | 3.3 MB     00:01 
:
:
Installed:
  monit.x86_64 0:4.10.1-9.el5                                                                                         
Dependency Installed:
  openssl098e.x86_64 0:0.9.8e-18.el6_5.2                                                                              
Complete!
Advertisements

Adding SLF4J Logs to Akka

You might want to consider adding SLF4J plugin to your default Akka logs. This can help you standardize the logs and would help you in the better analysis of your logs.

Akka provides help on how you can plugin SLF4J into your akka application: http://doc.akka.io/docs/akka/snapshot/java/logging.html#SLF4J 

I implemented the suggested approach and am listing down the simplified steps for quick reference.

Add dependency

Add akka-slf4j plugin and logback-classic dependency to your build.

Eg: Add the following to your pom.xml

<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j</artifactId>
<version>2.3.9</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>

If you are using SBT, then your build.sbt would look like:

libraryDependencies += “com.typesafe.akka” % “akka-slf4j” % “2.3.9”,
libraryDependencies += “ch.qos.logback” % “logback-classic” % “1.1.2”

Enable SLF4JLogger for Akka

Update your application.conf (src/main/resources) with the following:

akka {
event-handlers = [“akka.event.slf4j.Slf4jEventHandler”]
loglevel = “INFO”
}

Add logback.xml

Add logback.xml to your classpath. That is, create a logback.xml at src/main/resources. The following is an example of logback.xml. You can find more info about how you can configure your logs with the various patterns at: http://logback.qos.ch/manual/layouts.html

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<appender name=”CONSOLE” class=”ch.qos.logback.core.ConsoleAppender”>
<target>System.out</target>
<encoder>
<pattern>%d %X{akkaTimestamp} %-4r %-5level [%thread] %logger{0} %class{0} – %-5msg%n</pattern>
</encoder>
</appender>
<appender name=”FILE” class=”ch.qos.logback.core.FileAppender”>
<file>./log/akka.log</file>
<append>false</append>
<encoder>
<pattern>%d %X{akkaTimestamp} %-4r %-5level [%thread] %logger{0} %class{0} – %-5msg%n</pattern>
</encoder>
</appender>
<logger name=”akka” level=”DEBUG” />
<root level=”INFO”>
<appender-ref ref=”CONSOLE”/>
<appender-ref ref=”FILE”/>
</root>
</configuration>

Add Logs

Now you can add logs to your code, add the following to your scala code:

import akka.event.Logging

val log = Logging(context.system, this.getClass.getName)

log.info(“Info message”)

log.warning(“Warning message”)

log.debug(“Debug message”)

log.error(“Error message”)