Zabbix: LLD Monitoring FlexLM Services (UPDATED)

This article is a more detailed study of the previous one . Now the template is unified for use in both Windows (PowerShell) and Linux (Bash). If you used the previous template, then everything should stand up.
What it can do: find servers / licenses, read server statuses, read the total and used number of licenses, in case of errors, transmit status codes (description line) and report about them.
The scheme is still the same:
- Template
- Scripts (PowerShell / Bash)
- Proper agent setup

Template
Everything is simple here: imported and forgot. The template was designed in Zabbix version 3.2, keep this in mind.
As last time, for readability, the macros of the construction {$ {# ID}} in the names of elements and triggers are used. The template already contains a number of macros, you just add your transforms based on the elements found.
Also inside there are already several basic triggers for monitoring the status of servers and individual licenses.
Template
Script for windows
The script for Windows was written under Windows 7 SP1 on PSv4, it does not work on XP . Of course, the server should be allowed to run PowerShell scripts ( Set-ExecutionPolicy Unrestricted ).
flex.ps1
The performance of the licensing server is taken from the lmutil.exe utility , which is included in the distributions of different vendors. For the script to work properly, it is necessary to register the path to it in the system environment variables in the Path variable without quotes. For example, the default folder for CSoft v11.5 is “ C: \ Program Files (x86) \ CSoft \ CS License Server ”, and for Autodesk v11.13.1 it is “ C: \ Autodesk \ Network License Manager ”. Use the ";" sign as a separator.
If you are using an Autodesk license server, then look at the feature under the spoiler.
Spoiler
С этим разработчиком оказалось не все так просто. «Из коробки» lmutil отдает ошибку -1,359. Хотя если указать порт@хост, то все нормально.

Связано такое поведение скорее всего с тем, что в старших версиях FLEXlm lmutil сопоставляет пути переменных LM_LICENSE_FILE и VENDOR_LICENSE_FILE. Пути эти стандартные и по умолчанию не существуют.
Для решения достаточно взять lmutil.exe версии 11.5 из произвольного пакета (CSoft/Nanosoft). Или выполнить на хосте команду вида
lmutil lmpath -override all «путь_к_файлу_вашей_лицензии»

Аналогичным образом можно использовать команду
lmutil lmpath -add «произвольное_имя_вендора» «путь_к_файлу_вашей_лицензии»
Команды эти нужно выполнить от имени системной учетной записи, иначе Zabbix-агент так и не сможет работать с утилитой. Сделать это можно с помощью утилиты PsExec с ключом -s: psexec -s cmd и в открывшее окно командной строки внести нужные команды.
Подробнее об этих и других командах вы можете узнать из инструкции по лицензированию, рекомендую к прочтению при дебаге.

Связано такое поведение скорее всего с тем, что в старших версиях FLEXlm lmutil сопоставляет пути переменных LM_LICENSE_FILE и VENDOR_LICENSE_FILE. Пути эти стандартные и по умолчанию не существуют.
Для решения достаточно взять lmutil.exe версии 11.5 из произвольного пакета (CSoft/Nanosoft). Или выполнить на хосте команду вида
lmutil lmpath -override all «путь_к_файлу_вашей_лицензии»

Аналогичным образом можно использовать команду
lmutil lmpath -add «произвольное_имя_вендора» «путь_к_файлу_вашей_лицензии»
Команды эти нужно выполнить от имени системной учетной записи, иначе Zabbix-агент так и не сможет работать с утилитой. Сделать это можно с помощью утилиты PsExec с ключом -s: psexec -s cmd и в открывшее окно командной строки внести нужные команды.
Подробнее об этих и других командах вы можете узнать из инструкции по лицензированию, рекомендую к прочтению при дебаге.
Script for linux
And this script was written under Ubuntu. To learn how to install Autodesk licensing server on Ubuntu step by step, see below (Ubuntu is not officially supported).
Copy the script to an arbitrary folder on the server (specify the path in the agent’s config, more on that below), do not forget to give the appropriate rights to execute it.
It is also necessary to specify the directory of the lmutil utility in the "User Variables" section in the script .
flex.sh (updated 2017/10/26)
Исправлены регулярки для обнаружения количества лицензий
Исправлено обнаружение серверов, когда их >=2
Исправлено обнаружение серверов, когда их >=2
Zabbix Agent Configuration
The simultaneous operation of different systems from one template allows the correct configuration of the agent, or rather part of it UserParameter. This method is also allowed to forget once and for all about restarting the agent in case of adding new functionality in the form of scripts. This is important for heavily loaded servers, where when you restart the agent, you may lose some of the metrics.
So, in this case, the line is used:
for Windows - UserParameter = ZScript [*], powershell C: \ Zabbix \ Scripts \ $ 1.ps1 $ 2 $ 3 $ 4
for Linux - UserParameter = ZScript [*], bash / etc / zabbix / scripts / $ 1.sh $ 2 $ 3 $ 4
Paths and the number of variables indicate yours. Variables can be specified with a margin, it will not be superfluous. And you can access the necessary scripts using the ZScript key [$ 1, $ 2, $ 3, $ 4].
Thanks for attention!
Acknowledgments
Хочется поблагодарить моего работодателя за мотивацию к написанию статьи. Если бы не вы, то мне бы не пришлось оптимизировать нагрузку на наших слабых серверах, переводя сервисы на Ubuntu Server!
Update! 2017/12/26
In connection with the latest trends, I decided to rewrite everything under the server version of work without user parameters and scripts on clients. You will need a template and a script in the external verification directory (for Ubuntu - / usr / lib / zabbix / externalscripts ). Do not forget to give the appropriate rights to execute this file. Template exported from version 3.4.4. From innovations: now Zabbix receives the list of active users of this or that license.
Software - FlexLM.xml