Usm observer EN: различия между версиями

Материал из WiKi - UserSide
Нет описания правки
Нет описания правки
 
(не показаны 2 промежуточные версии этого же участника)
Строка 3: Строка 3:
{{ActivEN}}
{{ActivEN}}


'''usm_observer''' - is a module for constant control by SNMP means of configurable indicators of [[Equipment|devices]] and notification of [[Employees|employees]] and [[Departments|departments]] about the fact of these indicators' values exceeding the set values.
'''usm_observer''' - is a module for constant control by SNMP means of configurable indicators of [[Equipment|devices]] and notification of [[Staff|staff]] and [[Subdivisions|subdivisions]] about the fact of these indicators' values exceeding the set values.




Строка 19: Строка 19:
''The module requires Python3 of any currently supported version. The status of versions can be viewed here:"[https://devguide.python.org/versions/ Status of Python versions]". It is recommended to use a version with "security" or "bugfix" status. Versions marked as "end-of-life" are not supported. Versions marked as "feature" are not recommended.''
''The module requires Python3 of any currently supported version. The status of versions can be viewed here:"[https://devguide.python.org/versions/ Status of Python versions]". It is recommended to use a version with "security" or "bugfix" status. Versions marked as "end-of-life" are not supported. Versions marked as "feature" are not recommended.''


Python3 Required Modules:
=== Installation ===
PySNMP


All dependencies are installed automatically. To do this, while in the module directory, execute:
Copy the archive to the modules directory, e.g. /opt/userside and unzip it.
<pre>
cd /opt/userside
sudo unzip usm_observer_2.0.0.zip
</pre>


pip3 install -r requirements.txt
Navigate to the usm_observer directory, create a virtual environment
<pre>
cd usm_observer
sudo python3 -m venv venv
sudo venv/bin/pip install --upgrade pip
sudo venv/bin/pip install --upgrade -r requirements.txt
</pre>


== Installing the module ==
=== Setting ===


Upload the module to the server in the modules directory and run (X.X.X is the current version number)
If this is the first setting of version 2.x, copy the example configuration file
<pre>
sudo cp settings.yaml-example settings.yaml
</pre>


unzip usm_observer-vX.X.X.zip
Edit the settings.yaml file. In the '''api''' section, specify <code>url</code> of your USERSIDE and [[UserSide API Key EN|API-key]] in the field <code>key</code>. In the '''log''' section you can change the path to the logs in the field <code>path</code> and the logging level (DEBUG, INFO, WARNING, ERROR) in the field <code>level</code>. If you want the log to be output to standard output instead of a file, then for <code>path</code> specify the value <code>STDOUT</code> — this may be useful when initially setting up the module.
rm usm_observer-vX.X.X.zip
cd usm_observer
 
Upgrade the package manager
 
pip3 install --upgrade pip
 
Now install the dependencies. You can use [[Python_venv_EN|virtual python environment]] with the appropriate patches to the commands below, or install everything according to these instructions globally.
 
pip3 install --upgrade -r requirements.txt
 
If this is an initial installation - copy the example configuration file
 
cp settings.ini-example settings.ini
 
== Configuring the module ==
 
The '''settings.ini''' configuration file contains two sections with parameters
 
The '''api''' section contains parameters of connection to the USERSIDE API:
 
* '''url''' - specify here the URL USERSIDE
* '''key''' - specify here the [[UserSide API Key_EN|API Key]]
* '''ssl_verify''' - if you want to disable SSL certificate verification, set the value to '''no'''
 
The '''log''' section contains parameters for logging the module operation:
 
* '''path''' - path to the directory where the log file will be created
* '''level''' - level of detail: 1 - debugging, 2 - informational, 3 - warnings, 4 - errors, 5 - fatal errors
* '''to_console''' - yes - output log messages to the console but not to a file; no - output log messages to a file


== Test launch ==
== Test launch ==


To verify that the configuration is correct, perform a manual test launch. To do this, set level = 1 and to_console = yes in the log section of settings.ini and then launch the module manually by executing the following command:
To make it easier to control the first test launch, set the path to the log in settings.yaml to <code>STDOUT</code> and launch the module:
 
<pre>
python3 usm_observer.py
venv/bin/python main.py
</pre>


If the module worked correctly and terminated correctly, set level = 2 and to_console = no and configure the module to start automatically.
If the module worked correctly and terminated correctly, set the correct path to the log so that it is recorded to a file.


If errors were detected during the manual test launch, eliminate them or contact our support service for help using the ticket system in your personal client cabinet.
If errors were detected during the manual test launch, eliminate them or contact our support team using the ticket system in your personal account.


== Automatic startup ==
== Automatic start ==
 
Configure the startup in crontab as follows. Pay attention to output redirection - preferably the files to which the output is redirected should be located in the same directory as the module's log file.


Add a line to crontab, having previously changed the path to the module:
Add a line to crontab, having previously changed the path to the module:
<pre>
2/* * * * *  root    /opt/userside/usm_observer/venv/bin/python /opt/userside/usm_observer/main.py
</pre>


* *  * * *  root    python3 /path/to/module/usm_observer.py >> /var/log/userside/usm_observer_cron.log 2>>/var/log/userside/usm_observer_cron_error.log
Make sure that the module starts. To do this, observe the log file after a few minutes:
 
<pre>
Make sure that the module starts. To do this, observe the log file after one minute:
tail -f /var/log/usm_observer/usm_observer.log
 
</pre>
tail -f /var/log/userside/usm_observer.log
 
If the module does not start automatically, the problem may be that there are no paths to python3 in crontab. Add the path to the PATH variable of the crontab file or specify the full path to python3 in the job line.
 
You can find the full path to python3 by running the command:
 
which python3
 
== Log file rotation ==
 
The log files created by the module need to be rotated. To do this, the standard log rotation tools in the operating system should be used.
 
The following configuration will rotate all *.log files every day and store 7 archive copies (for 7 days)
 
=== Rotation on FreeBSD ===
 
On FreeBSD, the newsyslog daemon is responsible for rotation. Create the file /usr/local/etc/newsyslog.conf.d/userside, in which place the following line (don't forget the path if you changed it):


/var/log/userside/*.log            644  7      *    @T00  GJC
== Rotation of log files ==


=== Rotation on Linux ===
The log files created by the module need to be rotated. For this purpose, the standard log rotation tools in the operating system should be used.


On Linux, the logrotate daemon is responsible for rotation. Create a file /etc/logrotate.d/userside, in which put the following text (don't forget the path if you change it):
The following configuration will rotate all *.log files on a daily basis and store 7 archive copies (for 7 days)


/var/log/userside/*.log {
Create the following file /etc/logrotate.d/usm_observer:
    rotate 7
<pre>
    daily
/var/log/usm_observer/usm_observer.log {
    compress
    rotate 7
    delaycompress
    daily
    missingok
    compress
    notifempty
    delaycompress
}
    missingok
    notifempty
}
</pre>


== Operation Logic ==
== Operation Logic ==

Текущая версия от 09:00, 3 февраля 2025

en | ru

This function is one of the possibilities
to update the activity date of an object

usm_observer - is a module for constant control by SNMP means of configurable indicators of devices and notification of staff and subdivisions about the fact of these indicators' values exceeding the set values.


This module is a replacement for the obsolete us_control_EN module


Overview

Module Language: Python

Current version: see page: Modules_EN

Module Status: Paid

The module requires Python3 of any currently supported version. The status of versions can be viewed here:"Status of Python versions". It is recommended to use a version with "security" or "bugfix" status. Versions marked as "end-of-life" are not supported. Versions marked as "feature" are not recommended.

Installation

Copy the archive to the modules directory, e.g. /opt/userside and unzip it.

cd /opt/userside
sudo unzip usm_observer_2.0.0.zip

Navigate to the usm_observer directory, create a virtual environment

cd usm_observer
sudo python3 -m venv venv
sudo venv/bin/pip install --upgrade pip
sudo venv/bin/pip install --upgrade -r requirements.txt

Setting

If this is the first setting of version 2.x, copy the example configuration file

sudo cp settings.yaml-example settings.yaml

Edit the settings.yaml file. In the api section, specify url of your USERSIDE and API-key in the field key. In the log section you can change the path to the logs in the field path and the logging level (DEBUG, INFO, WARNING, ERROR) in the field level. If you want the log to be output to standard output instead of a file, then for path specify the value STDOUT — this may be useful when initially setting up the module.

Test launch

To make it easier to control the first test launch, set the path to the log in settings.yaml to STDOUT and launch the module:

venv/bin/python main.py

If the module worked correctly and terminated correctly, set the correct path to the log so that it is recorded to a file.

If errors were detected during the manual test launch, eliminate them or contact our support team using the ticket system in your personal account.

Automatic start

Add a line to crontab, having previously changed the path to the module:

2/* * * * *   root    /opt/userside/usm_observer/venv/bin/python /opt/userside/usm_observer/main.py

Make sure that the module starts. To do this, observe the log file after a few minutes:

tail -f /var/log/usm_observer/usm_observer.log

Rotation of log files

The log files created by the module need to be rotated. For this purpose, the standard log rotation tools in the operating system should be used.

The following configuration will rotate all *.log files on a daily basis and store 7 archive copies (for 7 days)

Create the following file /etc/logrotate.d/usm_observer:

/var/log/usm_observer/usm_observer.log {
    rotate 7
    daily
    compress
    delaycompress
    missingok
    notifempty
}

Operation Logic

  • Each launch the module checks the status of SNMP-parameters of the monitored devices. If the value of a parameter is out of limits, an alarm is considered to have occurred. There can be several alarm parameters on a device. For each device, where an alarming parameter was found or vice versa - the parameter came back to normal - an e-mail and/or SMS is generated for the selected (at the level of each device) circle of recipients
  • A separate e-mail/message is generated for each device, which will contain all the parameters whose (alarm/normal) status has changed. The information will be presented in the letter in a detailed manner, and in SMS in a compact manner
  • The next message will be sent only if a parameter has changed again
  • If during the polling process it is found out that the device being polled is inactive (an error occurred while connecting to the device or an error occurred during parameter acquisition), this will be marked by the module and in the next several startup cycles (default: 5) this device will not be polled, so as not to create delays in polling other parameters.
  • For devices from which parameters were retrieved, the date of the last activity will be updated.
  • If an invalid parameter (OID) is specified, when polling a device, polling of this device will be stopped on this parameter.


If the module has stopped starting - a corresponding message will be displayed on the main page for the operators having access to the system configuration

General Setup

First, you need to specify a list of monitored parameters and the events at which to consider the values of these parameters to be out of normal.

Parameters can be compiled into polling profiles

For all parameters that are currently being polled, the current status and alarms can be viewed

There is a log of polled parameters (not all values, only their changes), which is stored in the system database.

The current list of polled devices is also available

Customisation in the device card

When editing the equipment card, a block is available where you can select a polling profile for this device, specify some individual parameters for polling that are not included in the selected profile, and specify the recipients of alarm messages

In the view mode, the module block is also displayed and from it you can view the current state of the parameters and the log of their state changes