Blog

How to install Nagios local server on Ubuntu 16.04

How to install Nagios local server on Ubuntu OS?

To have reached this question, you should need a software for remote monitoring of electrical or non-electrical quantities, networks, services, etc.

According to Wikipedia – “Nagios, now known as Nagios Core, is a free and open source computer software application that monitors systems, networks, and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications, and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.”

In this article will be described how to install Nagios local server – step by step. In the document, following packages are used – Nagios 4.2.1, Nagios Plugins2.1.2, and Ubuntu 16.04.
It is assumed, that the user is familiar with Linux and already has a workstation with Ubuntu 16.04.

1. How to install Nagios local server – initial settings

1.1. Run terminal as root to install Nagios local server necessary packages

Installation and configuration of the required packages require administrator rights, so before downloading and installing the following packages put the following command in the console:

sudo su

how-to-install-nagios-local-server-initial-settings
You will be asked for a password, then the console goes into the root mode.

1.2. Packages installation

The following packages should be installed:

sudo apt-get install apache2
sudo apt-get install php7.0-gd
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev

1.3. Creating a new user

It is necessary to create a new user and group to which it belongs. Use the following commands:

useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -a -G nagcmd www-data

1.4. Creating a directory for downloading Nagios packages

mkdir ~/downloads
cd ~/downloads
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.1.tar.gz
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

2. Compiling and installing Nagios

cd ~/downloads
tar zxvf nagios-4.2.1.tar.gz
cd nagios-4.2.1/
./configure –with-nagios-group=nagios –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Depending on system configuration, it is possible to be displayed following error:

how-to-install-nagios-local-server-compiling-error

This error is caused by Nagios process. It tries to create a configuration file in the directory /etc/httpd.conf/.
But in Ubuntu, this configuration file should be placed in the directory /etc/apache2/sites-enabled/.
The following command should be used:

sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
sudo ls -l /etc/apache2/sites-enabled/

The result will be as follows:
how-to-install-nagios-local-server-command

3. Changing the e-mail address

nano /usr/local/nagios/etc/objects/contacts.cfg

The address nagios@localhost should be replaced with the desired email address. To save changes, use a keyboard shortcut Ctrl+X. After this choose Y and press Enter. The document remains with the same my name.

how-to-install-nagios-local-server-changing-mail

4. Configuring the Web interface, creating a user

After the execution of the following commands, a password for user nagiosadmin will be required.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
a2enmod cgi
sudo service apache2 restart

5. Compiling and installing of Nagios plugins

cd ~/downloads
tar zxvf nagios-plugins-2.1.2.tar.gz
cd nagios-plugins-2.1.2
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install

6. Start Nagios

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start

Depending on the configuration of the system, it is possible Nagios process, not to start. In this case, perform the following steps in the terminal:

6.1. nagios.service file creation

cd /etc/systemd/system/
sudo nano nagios.service

In this file, following rows should be inserted:

[Unit]
Description=Nagios
BindTo=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

To save changes, use a keyboard shortcut Ctrl+X. After this choose Y and press Enter.

6.2. Copy the following configuration file

cp /etc/init.d/skeleton /etc/init.d/nagios

6.3. Edit the configuration file

sudo nano /etc/init.d/nagios

In the end of the file, following rows should be inserted:

DESC=”Nagios”
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS=”-d/usr/local/nagios/etc/nagios.cfg”
PIDFILE=/usr/local/nagios/var/$NAME.lock

how-to-install-nagios-local-server-6-3

6.4. Saving the file, changing the conditions of access to it

sudo chmod +x /etc/init.d/nagios

6.5. Edit apache2 configuration file

sudo nano /etc/apache2/sites-enabled/nagios.conf

Delete the # character from the row “Allow from 127.0.0.1”. This will allow Nagios process to be accessed at 127.0.0.1/nagios or localhost/nagios.

how-to-install-nagios-local-server-apache2

6.6. Start Nagios service

sudo service nagios start

7. Login into the Nagios via a WEB browser

The user interface is available at:

http://localhost/nagios/

127.0.0.1/nagios

The username: nagiosadmin

The password: as set in step 4

how-to-install-nagios-local-server-web`

8. Adding host to Nagios

To be added a host to the system, several configuration files should be changed . Changes are made through an editor in the console. It is recommended to stop Nagios during the changes:

sudo service nagios stop

It is recommended after any change in a file of the system to verify configuration using the following command:

– /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

So if there is a configuration error, only the last changed file should be checked.

8.1. Change of the main configuration file

The base installation of the system allows monitoring only of the local host (computer). It is necessary to allow to Nagios process access to other hosts – switches, routers or other servers.

sudo nano /usr/local/nagios/etc/nagios.cfg

After this command, an editor will be open.
From the last line #cfg_file=/usr/local/nagios/etc/objects/switch.cfg the character # should be removed.
This will allow Nagios process to access configuration file, where the host data are written.

how-to-install-nagios-local-server-web

8.2. Adding an information for the new host in the following configuration file

sudo nano /usr/local/nagios/etc/objects/switch.cfg

In the end of the file, details of the new host (TCW220) should be added

define host{

use generic-switch
host_name TCW220
alias Teracom Ethernet Controller TCW220
address 192.168.1.2
hostgroups switches
}

how-to-install-nagios-local-server-web

After saving changes in the configuration file, you need to restart Nagios process.

sudo service nagios restart

The new host is now available through a WEB interface.

how-to-install-nagios-local-server-web-interface

The basic installation of Nagios includes service for monitoring the host only. To add additional services should be available a plugin, which performs the service and posts the results in the user interface.

We hope that this article was helpful enough to learn how to install Nagios local server and use it with different hosts.

May 14th, 2017|Blog|

Rain detector usage with TCW220

In this article will be shown how to use Ethernet data logger TCW220 with a rain detector.

Two different rain detectors are used – RG-11 and CON-REGME. RG-11 is manufactured by Hydreon Corporation, while CON-REGME is manufactured by B+B Thermo-Technik.

1. Test setting

An example test setting is shown on Fig. 1. Both rain detectors are powered by the controller TCW220.

In the event of rain or snow, they send a signal to the digital inputs of Ethernet data logger TCW220 (the rain detector RG-11 to digital input 1, the rain detector CON-REGME to digital input 2). The controller TCW220 is equipped with a logger which enables the storage and comparison of the information received by the two rain detectors.

rain detector test schematic
Fig. 1

The corresponding connections between the controller and the rain detectors are shown in Table 1.

rain detector test table of wiring

Table 1

To get accurate measurements from the rain detectors, they have to be mounted on a spot where there is free access to rain.

rain detector test mounting

A mandatory requirement when assembling the rain detectors is all components to be dry because any moisture in them creates condensation which may damage the rain detector.

2. Principle of operation of rain detector CON-REGME

This type of rain detector uses a sensor that detects the conductivity changes on the sensor surface. That change leads to the activation of a relay which then sends a signal to the digital input of the controller TCW220.

This rain detector operates at different sensitivity levels which can be changed so that the presence of fog can also be detected. The sensor surface can be heated which will enable operation at low temperatures and will speed up the drying process of the sensor.

CON REGME rain detector

 

3. Principle of operation of rain detector RG-11

This type of rain detector uses infrared rays that are reflected by a lens. When there is water on the lens, some of the rays get deflected.

The sensor detects the difference in the intensity of the rays, and then activates a relay which sends a signal to the digital input of the controller TCW220.

These rain detectors can operate at different sensitivity levels and in various modes that are changed by using DIP switches.

RG11 rain detector test

 

4. Test results

Figure 2 shows the feature of the controller TCW220 to display the saved data from the rain detectors and to compare them.

In the case below, the rain detector CON-REGME, using a sensor for changes in the conductivity, is the first to detect the presence of rain in both measurements. The detector using infrared rays has registered it later because depending on its operating mode, it will send a signal for the presence of rain at specific intensity of the rain.

A signal that it is not raining is first sent by the rain detector RG-11, and later by CON-REGME whose surface dries up a little more slowly.

rain detector test graph

Graph 1

5. Conclusion

Each of the tested sensors in combination with Ethernet data logger TCW220 can be used for condensation sensing, irrigation control, automation of greenhouses, balcony sun shades, and so on.

August 22nd, 2016|Blog|

Internet of things (IoT)

If you have never heard about Internet of things (IoT), probably now is the perfect time to learn about this application. This relatively new concept can be seen nowadays integrated in various manufacturing installations, as well as in the service sector and our daily lives. The main goals of this application is to bring a maximum level of automation to some processes, to optimize your costs and to save you a lot of time.

What exactly is the Internet of things (IoT)

In Internet of things (IoT), various physical objects are connected to the internet and can be identified by different devices. The technologies used for this purpose can be manifold – from sensors measuring temperature and humidity to QR codes and solutions based on RFID technology.

How the Internet of things (IoT) can be used in practice

It is the first topic to discuss after such a general explanation of the concept. In the following lines we’ll try to illustrate the practical use of this application.

When you are having fun

The different technologies used for the realization of the Internet of things (IoT) concept, provide an infinite number of opportunities to improve the service in the field of entertainment and education. Various museum and art exhibitions may be presented in a more attractive and interesting way. Also, you may create a special atmosphere in your backyard during your garden party with color and lighting, which you control through your smartphone.

In business and healthcare

The Internet of things (IoT) and more precisely the RFID technology can be used to facilitate the inventory of an enterprise, a library or a bank. All that is needed are RFID tags and a mobile reader and the time for inventory can be shortened up to 20 times. It also significantly reduces the chance of making a mistake during the inventory.

Technologies based on RFID can be used to detect the location of objects, people and animals within couple of seconds. You can also gather some information about the behavior and the expectations of the participants in various events, in order to offer them a better entertaining program next time.

The internet of things (IoT) might be of primary importance for the medicine and healthcare. The options for identification (also possible in real time) and the fast processing of large amounts of data and information, allow for better patient’s care and more rapid intervention in emergency situations. The integration of applications based on the RFID technology in emergency centers and nursing homes has already given some excellent results.

At home

All appliances in your home can be connected to the internet and can be run through a computer, tablet or phone, no matter how far from home you are at a given moment. You can control the heating or put automatic settings on it, you may solve once and for all the problem with the lights, which someone always forgets to turn them off. You may control the cook or the boiler. You may protect your home through a security system that includes video surveillance or use sensors for mechanical control of doors and windows or even install a fire alarm connected straight to the fire station.

Your “Smart” home will allow you to optimize your energy costs without losing your comfort and it also brings security and protection of your place to a higher level.

Are you intrigued by what you have just read? Internet of the things (IoT) can help you to save time, money, troubles, it will develop faster and better your business or will make you feel more comfortable at home. You’ll be fully surprised by the opportunities this new concept may offer.

May 25th, 2016|Blog|

HTTP file upload setup for TCW220

In this article will be described how to arrange log file upload of Ethernet data logger TCW220.

The Ethernet data logger TCW220 can upload periodically its log file via HTTP protocol to dedicated HTTP server. The log file is upload with HTTP Post.
There are many variants to organize HTTP server. Maybe, the most popular is Apache server. It has installations for WIN, Linux and OsX. In this article another variant for WIN will be shown.

TC Monitor is software for remote monitoring and control. For its normal operation it needs HTTP server. For customer convenience, HTTP server is included in installation package of software. This HTTP server can be used also for log file receiving.

To arrange log file upload of Ethernet data logger TCW220 follow the steps below:

1. Install TC Monitor software

TC Monitor installation package can be downloaded from www.teracom.cc.
The installation is quite simple – double click on the installation package, choose folder and press Install.

TCMonitor-install-1
TCMonitor-install-2
TCMonitor-install-3

Note: The install path must not contain any spaces or Windows specific file system characters.

2. Start TC Monitor

TC Monitor can be activated from the start menu. The following window will appear:

TCMonitor-start

Note: For proper operation TC Monitor should run.

3. Create destination folder for log files

The folder should be located in …\TCMonitor-1.4\web\www

In this article “http_post_log” will be used like a folder name.

Create-folder-post-log

4. PHP file

For proper operation dedicated PHP file should be available in created directory (step 3).
Our proposal for PHP file is HTTP_Post.php.

Download file, unzip and copy it in created directory (step 3).

This PHP add time stamp for every new file. In this case the new information doesn’t overwrite old one and all uploaded files are kept in the directory.
After a few uploads the directory will look like:

Folder-http-post-log

5. TCW220 settings

Following settings on page Services->Logger should be made:

  • Logger – Enable;
  • Logger mode – Time mode. Actually all variants are possible;
  • Log interval – 30 seconds. All valid values are also possible;
  • HTTP upload – Enable;
  • Server – IP address of PC + :8181 + name of created folder + name of PHP file

TC Monitor listen on port 8181. It is mandatory in record.
In standard application a router with public static IP and port forwarding should be used.

TCW220-post-log-settings

6. Import log file to Excel

An uploaded file can be import in Excel and data can be viewed like a graph.

6.1. Use Open, using .csv for file type

Excel-open-log-file

6.2. Select column with data – in our example these are data for sensor S11

Excel-select-data

6.3. Select type of chart

Excel-select-line-chart

6.4. Create charts

Excel-make-charts

May 10th, 2016|Blog|

How to install local ThingSpeak server

ThingSpeak server is an open data platform and API for the Internet of Things that enables you to collect, store, analyze, visualize, and act on data from sensors. More about ThingSpeak can be read here.

This article discribe how to make standalone Thingspeak server installation on Ubuntu 14.04.

1. Make an initial update of the system

sudo apt-get update

2. Installation of all necessary packages

sudo apt-get -y install build-essential git mysql-server mysql-client libmysqlclient-dev libxml2-dev libxslt-dev libssl-dev libsqlite3-dev

For Ubuntu 14.04 above command will install all necessary packages. For some older versions of Ubuntu, extra command should be executed for git package instalation.

sudo apt-get git-core

3. MySQL pass

If you haven’t had MySQL installed in advance, you will be required to enter a new password for administrative rights on the MySQL database.

ThingSpeak-server-i1-SQL-pass

4. Ruby installation

Download and installation time for those packages vary, depend of system hardware. Installation is made by following commands:

wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.4.tar.gz
tar xvzf ruby-2.1.4.tar.gz
cd ruby-2.1.4
./configure
make
sudo make install
cd ..

ThingSpeak-server-i2_Ruby_isntall

ThingSpeak-server-i3_Ruby_install

5. Rails installation

echo “gem: –no-rdoc –no-ri” >> ${HOME}/.gemrc
sudo gem install rails

6. ThingSpeak installation

It is recommend that the installation of the following packages is done using normal user rights (no root privileges).

ThingSpeak-server-i4

Installation is made by following commands:

git clone https://github.com/iobridge/thingspeak.git
cp thingspeak/config/database.yml.example thingspeak/config/database.yml
cd thingspeak
bundle install
bundle exec rake db:create

Here the MySQL database access password will be required.

bundle exec rake db:schema:load

If the package installation was successful, the following message will be displayed:

ThingSpeak-server-i5

7. Launching the ThingSpeak server

ThingSpeak server can be launched by following command:

rails server

ThingSpeak_i6

After execution of above command, ThingSpeak server will be accessible at 0.0.0.0:3000 in the web browser:

ThingSpeak_i7_server

Every activity of user will be displayed on the console.

To stop the server, use Ctrl+C in console.

To launch the server, use:

rails server

ThingSpeak_i8

8. Launching ThingSpeak server at start up

8.1. Creating a launching script

In order to launch ThingSpeak at start up, a short script must be created and added to the processes, which is launched at system start-up. This can be done with the following commands in the console terminal.

cd /home/USER/thingspeak
nano run.sh

In this case the script is added to the folder, where ThingSpeak packages was downloaded. The string USER should be replaced with real user name of user installed the ThingSpeak server. Like example if the user name is tele the command should be

cd /home/telem/thingspeak
nano run.sh

After the last command, an empty document run.sh will be created. In this document the following command should be saved:

#!/bin/bash
cd /home/USER/thingspeak && pwd && rails server webrick

ThingSpeak_i9

Ctrl+X saves the document. If the ThingSpeak is isntalled in a different directory, it should be specified here. The command, written in this way, means that the process is located in directory /home/USER/thingspeak, and this process will launch at system start-up.

8.2. Compiling the script

The already created script is compiled with following command:

chmod +x /home/USER/thingspeak/run.sh

8.3. Adding the script to the start-up processes

Then he script should be added to the process launched at the operating system start up. This happens by adding a record in one of the configuration files, which has to be opened, changed and saved with administrative (sudo) rights

cd /etc
sudo nano rc.local

After executing these commands, the configuration file will be opened. Just before the last line (exit 0) following record should be added:

sudo –u USER sh /home/USER/thingspeak/run.sh &

ThingSpeak_i10

Ctrl+X saves the document.

This document describes the steps of installing a ThingSpeak server. The commands used were applied with the operating systems Ubuntu 14.04.
The installation is done in directory /home/thingspeak of user telem.

April 7th, 2016|Blog|