Collecting Data From Counters. Sending a Monthly Billing Report Using Zabbix

  • Published In: Tutorial
  • Created Date: 2018-10-10
  • Hits: 2484

Modern human aims to automate as many as possible spheres of his/her personal and professional life. Earlier in our blog, we had already examined a possibility of Using NetPing Devices to Solve the Issue of Registering Data from Water Flow Meters. In this article, we will examine one more automation variant – sending a monthly report about the water consumption data using the integration of a monitoring device produced by NetPing company with a Zabbix monitoring system.

In the report, there is a need to represent the next information:

  • date of sending a report;
  • information on the meter;
  • final water/electricity consumption for the last month;
  • readings at the beginning of the period;
  • readings at the end of the period;
  • a total sum of the payment in currency according to the tariff

Required Hardware and Software

To implement sending monthly reports, we will need to have the next set of equipment:

  • A device for remote monitoring NetPing IO v2 or UniPing v3 – 1 pc.;
  • Water consumption meters with a pulse output – 2 pcs.;
  • PC or a server for collecting and storing information with the installed Zabbix monitoring system – 1 pc.;
  • Local/global network for data transfer – 1 pc.

Let's consider that a NetPing IO v2 monitoring device is configured for the operation in your local network. More detailed information about NetPing IO v2 configurations is given in the documentation. Water consumption meters with a pulse output are connected to corresponding input-output lines of a NetPing IO v2 device and configured according to the recommendations from this article. Let's also consider that a Zabbix monitoring system is configured for the operation with a NetPing IO v2 monitoring device and water meters with a pulse output (more detailed information is provided here). In this example, we use Zabbix of the version 3.4.8.

Configuring a Monitoring Device NetPing IO v2

To increase the information, provided by reports, there is a need to indicate memos for IO lines of a NetPing IO v2 device, to which water meters with a pulse output are connected. To do this, go to the page "Discrete I/O Lines" using a navigational menu under the heading of a web interface of a monitoring device NetPing IO v2. and fill in a parameter «Memo» for an IO line 1 and IO line 2. Unfortunately, Zabbix does not recognize Cyrillic, sent through an SNMP protocol, therefore memos must be specified n Latin letters. Configurations for all parameters of IO lines are examined in details here.

NetPing IO v2 configuring a memo of an IO line

Configuring a Zabbix Monitoring System for Sending E-mail Reports.

Then, go to a web interface of a Zabbix monitoring system. According to this article, we added two new data elements for each meter for receiving current readings of water consumption from a meter and calculated data elements that determine a monthly water consumption:

Zabbix variables

Create two more calculated data elements: one for a cold water meter, another one for a hot water meter that will count the cost of a monthly water consumption. Go to the page «Configuration → Hosts →Items»:

Zabbix Configuration - Hosts - Items

Click the button «Create Item»:

Zabbix creating a data element

Fill in the fields in the form that opens, the same as in our example:

Zabbix creating parameters of a data element

Name – is an element name in Zabbix. In our example, «Price_cold» is a name for a cold water meter and «Price_hot» is a name for a hot water meter;
Type – is a parameter that determines the data element query method;
Key – is a unique key name of a data element in a range of one node. In our example, «1price» for a cold water meter and «2price» for a hot water meter;
Formula – is an arithmetic expression for calculating necessary readings on the basis of other data elements.

In our example, we multiply a monthly water consumption on the cost of one cubic meter according to provider's tariffs. For a cold water meter, the last value of a data element «1month» is multiplied by 33,03 rubles. For a hot water meter, the last value of a data element «2month» multiply by 116,86 rubles (tariffs are conventional). Click the button «Add», and repeat a data element creation for the second meter.

Then, we need to configure monthly sending of a report to an e-mail. Go to the page «Administration → Media Types». Check the notification method to be set to «Email» and enabled. Enable it, if necessary and configure it according to the documentation.

Zabbix Administration - Media Types

Then, go to the user settings of Admin «Administration → Users» and add a new notification method at the tab «Media». Click the link «Add», and specify parameters, as shown in our example, in a pop-up window «Media» that appears:

Zabbix configuration of a user Admin

Zabbix configuration of a new notification type

Type – is a parameter for selecting a notification method created earlier in a Zabbix monitoring system («Administration → Media Types»). In our case, select a notification type «Email» from the list;
Send to – is an email address, where e-mail reports will be sent;
When active – is the time of triggering of this notification. A setting can be left on default;
Use if severity – is an importance of the trigger. Checkboxes determine at which severity of the trigger the notification will work. In the example, all checkboxes are checked for better visuality of this parameter.
Enabled – is a parameter that is necessary for switching this notification on and off.

Save changes by clicking buttons «Add» and «Update».

Then, go to creating the action at performing which our e-mail reports will be sent. In this article, we will regard sending an e-mail report with readings of meters once a month, on the 20th day of every month. At first, let's create a trigger that will need to operate for a monthly report to be sent. Go to the page «Configuration → Hosts →Triggers» and click the button «Create trigger»:

Zabbix Configuration - Hosts - Triggers

Zabbix creating a trigger

Fill in the fields in the form that opens, as shown in the screenshot:

Zabbix creating a trigger filling parameters in

Name – is a name of a trigger. In our example, «Monthly report cold water» for a cold water meter and «Monthly report hot water» for a hot water meter;
Severity – is a selection of required severity of the trigger. Let's choose a level of severity «Information»;
Expression – is a logic expression, when it is true, a trigger operates.

To configure a logic expression, click the button «Add» (1) and fill in the fields in the form that opens:

Zabbix creating a trigger configuration of a logic expression

Item – select data element that corresponds to a required meter. In our example, «NetPing IO v2: Water meter 1 Cold Water Supply» for a cold water meter and «NetPing IO v2: Water meter 2 Hot Water Supply» for a hot water counter;
Function – choose «Day of month is = N» from a drop-down list;
N – specify a necessary day of a month. It is 20 in our example.

Then, click the button «Insert». The rest parameters can be left on default. Save changes by clicking the button «Add» (2). Repeat a process of creating a trigger for the second water consumption meter.

Then, go to the section «Configuration → Actions», and click the button «Create Action»:

Zabbix creating an action

In a window that opens at the tab «Action», fill in the fields as shown in our example. Here, we need to sort the triggers in operation of which e-mail reports will be sent:

Zabbix picking triggers for the action

Name – is a unique name of the action. In our example, it is «Monthly report cold water» for a cold water meter and «Monthly report hot water» for a hot water meter;
Conditions – are conditions, at which the action will trigger. In our example, the names of the triggers, which operating causes sending e-mail reports, are «NetPing IO v2: Monthly report cold water» for a cold water meter and «NetPing IO v2: Monthly report hot water» for a hot water meter;
New condition – is a field for creating a new condition. Adding rules is confirmed by clicking the link «Add» in the field «New condition»;
Enabled – is a parameter for switching on and switching off this action.

Then, go to the tab «Operations» and specify the text of an e-mail report that will be sent when a trigger described at the tab «Action» operates:

Zabbix creating the action of adding a notification recipient

Default operation step duration – is a duration of a single step of the operation. For example, a step duration of one hour means that if the first operation is performed in this action, then the next operation will start in one hour. In our example, the operation of sending a notification is only one, therefore it is possible to leave a default value;
Default subject – is a default notification subject. A subject can contain macros. Cyrillic is supported. In our example, it is a «Monthly report on cold water consumption» for a cold water meter and «Monthly report for hot water consumption» for a hot water meter;
Default message – is a default message. A message can contain macros. Cyrillic is supported. In this field, we write a text of an e-mail report that will be sent to a system administrator on the 20th day of each month. In the test of an e-mail report, links to previously created data elements are used.

In the field «Operations», click the link «New», and click a description form that unfolds as shown in our example. Add a user «Admin» to the field «Send to Users». In the field «Send only to», select from the list a notification type «Email». Confirm changes by clicking the link «Add» (1):

Zabbix creating the action adding a message recipient

Confirm creating a new action by clicking the button «Add» (2). Repeat creating of a trigger for the second water consumption meter.

Now, every 20th day of a month, a system administrator will receive e-mail reports about a monthly water consumption and its cost:

A final monthly billing report on a water consumption using Zabbix

Therefore, we automatized not only accounting data on water consumption, but also sending a billing report.

comments powered by Disqus