How to Monitor Server Logs in Real-Time with Log.io Tool on RHEL 7 /CentOS 7

1.Introduction

Log.io is a small simple but effective application build on top of Node.js and Socket.io, which allows to monitor Linux servers log files in real time through web interface screen widgets. This guide will help you to monitor server log with log.io on CentOS 7 / RHEL 7.

2.Operating System

This article is based on RHEL 7 / CentOS 7 .

3.Installation

3.1 Add Epel Repositories

Install Epel repositories by running the following command.

# yum install http://fedora.mirrors.telekom.ro/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

After you added Epel Repos, do a system upgrade by running the following command.

# yum update

Install Node.js and NPM Packages

Node.js is a Java-script server-side programming platform which allows you to create an applications with back-end functionality. NPM (Node Package Manager) is package manager for Node.js, So the next step is to install Node.js and NPM binaries on your system through the following command.

# yum install npm nodejs 

3.3 Install and Configure Log.io Application

Log.io application must be installed on your system through NPM by specifying a valid system user, through which the installation must take place. So here we can install the application as root user. For installing run the below command.

# npm install -g log.io --user “root”

After installation has been completed change the working directory to Log.io folder, which is hidden under the “/root” directory.

[root@sapin-centos7 ~]# pwd
/root
[root@sapin-centos7 ~]# cd .log.io/
[root@sapin-centos7 .log.io]# ll
total 12
-rw-r--r-- 1 root root 225 Jan 18 17:21 harvester.conf
-rw-r--r-- 1 root root  56 Jan 18 16:24 log_server.conf
-rw-r--r-- 1 root root 516 Jan 18 17:22 web_server.conf
[root@sapin-centos7 .log.io]#

Now it’s time to configure Log.io to monitor local log files in real time.
There are mainly three configuration files and are listed below.

> harvester.conf
> log_server.conf
> web_server.conf

harvester.conf

This the configuration file for harvester, it is nothing but a log forwarder which keeps on watching log files for changes, send new log to the server. We can configure nodeName, what are all logs to watched and where to send a log. By default it only monitors Apache log files such us “access_logs and error_logs”, Here we have to replace the nodeName statement to match your hostname and also you have to add the logStreams statements with what internal log files that you want to monitor.

exports.config = {
  nodeName: "sapin-centos7.syslint.com",
  logStreams: {
    apache: [
      "/var/log/httpd/access_log",
      "/var/log/httpd/error_log"
    ]
  },
  server: {
    host: '0.0.0.0',
    port: 28777
  }
}

Also if you don’t need harvester output to be sent to a remote Log.io server change the line host on server statement to only send its output locally by modifying 0.0.0.0 address with loopback address (127.0.0.1).

log_server.conf

For security reasons, if you are not expecting remote harvesters output to your local Log.io server, Open log_server.conf file and replace 0.0.0.0 address with loopback address (127.0.0.1).

exports.config = {
  host: '127.0.0.1',
  port: 28777
}

web_server.conf

This the configuration file of web interface, this alters the functionality of the web portal. By-default, web portal is accessible on port no 28778 and on all interface. This file offers a way to increase the security by putting HTTP authentication,securing the web interface with SSL, disallowing logs from specific ip address and restricting the web interface access to the specific ip.

exports.config = {
  host: '0.0.0.0',
  port: 28778,

  /* 
  // Enable HTTP Basic Authentication
  auth: {
    user: "admin",
    pass: "adminlogin"
  },
  */

  /* 
  // Enable HTTPS/SSL
  ssl: {
    key: '/path/to/privatekey.pem',
    cert: '/path/to/certificate.pem'
  },
  */

  /*
  // Restrict access to websocket (socket.io)
  // Uses socket.io 'origins' syntax
  restrictSocket: '*:*',
  */

  /*
  // Restrict access to http server (express)
  restrictHTTP: [
    "192.168.29.39",
    "10.0.*"
  ]
  */

}

3.4 Add Firewall Rule and Start Log.io Application

For web access to Log.io server add a rule on RHEL/CentOS 7 Firewall to open TCP 28778 port by issuing the following command.

firewall-cmd --add-port=28778/tcp --permanent
firewall-cmd --reload

3.5 Start Log.io Application

For start Log.io log monitoring application assure that your current working directory is “/root” and use the following commands in the following order to start application.

> First start server, put it in background and press Enter key


log.io-server & 

> Start log harvester in background


log.io-harvester & 
[root@sapin-centos7 .log.io]# log.io-server &
[1] 16427
[root@sapin-centos7 .log.io]#    info  - socket.io started

[root@sapin-centos7 .log.io]# log.io-harvester &
[2] 16431
[root@sapin-centos7 .log.io]# 

4. Access Web Interface

Then open your web browser and visit http://your-ip-address:28778. You will get the following page with logs.

log.io

5. Conclusion

We have successfully installed and configured a real-time log monitoring tool “Log.io” on CentOS 7 / RHEL 7. Log.io is an excellent and effective web application to monitor local or remote servers log files is real time and get an outlook on what is going internally in the systems and especially to debug server problems when systems tend to become unresponsive or crashes, without the need to use a console.

6.Reference

http://logio.org/

How to Install Seafile cloud storage in Ubuntu 14.04 server

Seafile cloud storage

1. Introduction

Seafile is a free and open source cloud storage software system. It acts as a central server for storing files and synchronize the data with multiple computers and mobile devices using the seafile client. It allows users to assemble files into libraries and these libraries can be shared among the users as well as groups. Also it provides advanced support for privacy protection and teamwork. This article will help you to install Seafile on Ubuntu server.

2. Prerequisites

Operating System must be Ubuntu 14.04 LTS
Linux server with a valid hostname, 2GB RAM
LAMP must be installed

3. Install all Dependency Softwares for Seafile

First, you need to update the system to make sure that all softwares are updated.

# apt-get update
# apt-get upgrade

Then install the following required dependencies:

Java Runtime Environment (JRE)

# apt-get install openjdk-7-jre

Install poppler-utils

# apt-get install poppler-utils

Install Python and its libraries

# apt-get install libpython2.7  python-simplejson python-setuptools python-imaging python-mysqldb
# easy_install pip
# pip install boto

4. Install Seafile

You need to download the latest stable version of Seafile and extract it using the below commands. It is important to choose the package as per your system architecture. The downloaded seafile package here is that of 32 bit system.

# cd /usr/local/src
# wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.0.4_i386.tar.gz
# tar -xzf seafile-server_5.0.4_i386.tar.gz
# cd seafile-server-5.0.4/

5. Configure Seafile

Here you have to run the following script to check whether your server meets all requirements.

# ./setup-seafile-mysql.sh

Since we have already installed all system requirements, you just press the Enter key to continue. Next you will be prompted to enter several information like server name, IP address, default port, create MySQL database etc for configuring seafile in the server. You should enter the server name and IP address that you have set up for your server. When you answer the questions which are related to default values, it is always good to press the “enter” key to accept the values.

Some examples are shown below :

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ]

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ]

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/usr/local/src/seafile-data" ]

Which port do you want to use for the seafile fileserver?
[ default "8082" ]

After all the required information are entered you will get the summary of your configuration. Finally press enter for saving the configuration.

You will get the following message after saving the configuration.

Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start  | stop | restart  }

6. Start Seafile and seahub services

First you need to start the seafile service, which controls the file transfer and data sharing function.

# ./seafile.sh start

Next you need to start the seahub servcie. It provides the web interface to interact with seafile.

# ./seahub.sh start

Since the Seahub server is started for the first time, you will need to create the admin account.

What is the email for the admin account?
[ admin email ] ance@gmail.com

What is the password for the admin account?
[ admin password ]

Enter the password again:
[ admin password again ]

----------------------------------------
Successfully created seafile admin

7. Seafile Web Interface

Seahub is Seafile server package which contains Python HTTP server. Once the Seahub server is started, you can access Seafile via http://your domain or IP:8000 and then login with the admin account and password that was created on the configuration time. After login to the page, you can create and manage your files, contacts, groups, libraries, etc.

How to install and configure SpamAssassin with Postfix in Debian 8

SpamAssassin

1. Introduction

Spamassassin is a spam detection and prevention software intentionally made for incoming email spamming. We can prevent incoming spam mails by using various methods such as making content-matching rules. It flags an email as spam according to the resulting score of the mail which gets during the test.

In this article, We can see how to install and configure Spamassassin 3.4 in Debian 8.

2. Requirement

All the system softwares should be uptodate before starting the installation. Please follow the below commands to update your Debian system.

# apt-get update
# apt-get upgrade

3. Installation

After completing the software update, please install SpamAssassin using the following command :

# apt-get install spamc spamassassin

Thus the installation is completed. You can see the version by executing the commands below :

# spamassassin -V
SpamAssassin version 3.4.0
  running on Perl version 5.20.2

4. Setting Privileges

By default, The SpamAssasin will run under the root. We need to assign it to a low privileged user as a security measure. Executing the below commands one by one :

# groupadd -g 5555 spamd
# useradd -u 5555 -g spamd -s /sbin/nologin -d /usr/local/spamassassin spamd
# mkdir -p /usr/local/spamassassin/log
# chown spamd:spamd -R /usr/local/spamassassin

5. Enable SpamAssasin

To enable SpamAssassin daemon, Open the file /etc/default/spamassassin and edit the option ‘ENABLED=0’ to ‘ENABLED=1’.

6. Configure Spamassassin

Open the file given below :

# vi /etc/spamassassin/local.cf

Add or Change the following parameters and save the file.

rewrite_header Subject *****SPAM*****
required_score 3.0
report_safe 0
use_bayes 1
bayes_auto_learn 1

We have completed the Spamassassin configuration. Let see the postfix configuration.

7. Configure Postfix

Open the postfix master.cf file :

# vi /etc/postfix/master.cf

Search for the line given below :

smtp      inet  n       -       -       -       -       smtpd

Change the line as below :

smtp 	inet  n 	-	-	-	- 	smtpd -o content_filter=spamassassin

Then, add the following line at the end of the file :

spamassassin unix - n n - - pipe
  user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Atlast, Save the file and restart the services :

# service spamassassin restart
# service postfix restart

Now you can see the SpamAssassin starts running :

# netstat -tnulp | grep spam
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN 15972/spamassassin.

8. Conclusion

Thus we have completed the installation and configuration of SpamAssassin.