slothfk / 1c_zabbix_template_ce

Шаблон Zabbix для мониторинга кластера серверов 1С Предприятия 8.3
MIT License
155 stars 54 forks source link

Не работает определение количества лицензий и прочих сопутствующих параметров #49

Closed andy-1983 closed 3 years ago

andy-1983 commented 3 years ago

Добрый день!

Мы как раз обслуживаем несколько десятков организаций по конфигурации Камин 5.5. И я очень рад что сотрудники компании Камин развивают ПО с открытым кодом. Спасибо Вам!

Я второй день пытаюсь понять что не так с тем что я настроил. Zabbix 5.0 LTS принял шаблоны и получает некоторые данные. Агент установлен на сервере 1С с тремя компонентами в одном. То есть и центральный ,и рабочий, и сервер лицензирования расположены на одной машине.

Последнее что я попробовал, это установить "Утилита Лицензирования 1С:Предприятия (0.15.0+2)" то есть последней версии. Но это не дало результат. Сама платформа 8.3.16.1224 x86_64. ОС Debian 9.

И так, проблема в том что на сервер Zabbix приходят нули о параметрах количества/количества выданных лицензий.

Какие параметры мне стоит еще проверить? Посоветуйте что ни будь, пожалуйста.

Еще раз спасибо Вам за проделанную работу.

slothfk commented 3 years ago

Если я правильно понимаю, то речь про метрики по утилизации имеющихся лицензий? Сервис RAS запущен? На стандартном порту? Администраторы кластера есть? Информация по общему количеству сеансов есть или тоже 0?

andy-1983 commented 3 years ago

Добрый день.

RAS запущен, есть соответствующая строка в выводе ps -ax | grep ras

885 ? Ss 0:00 /opt/1C/v8.3/x86_64/ras cluster --daemon -p 1545

Но вот ручной запуск /opt/1C/v8.3/x86_64/rac session list дает в итоге бесконечное ожидание, что в Вашем скрипте обрабатывается таймаутом.

Тут пишут что виновата платформа, или создание учетных записей администратора кластера принципиально?

Сейчас, например через windows, мы в mmc кластера входим без пароля.

вс, 20 дек. 2020 г. в 21:57, Alexey Y. Fedotov notifications@github.com:

Если я правильно понимаю, то речь про метрики по утилизации имеющихся лицензий? Сервис RAS запущен? На стандартном порту? Администраторы кластера есть? Информация по общему количеству сеансов есть или тоже 0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748646590, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3NBYY2MK4AB2PEDKILSVZCJZANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

885 ? Ss 0:00 /opt/1C/v8.3/x86_64/ras cluster --daemon -p 1545

Уберите из строки запуска ключ --daemon Запускаете RAS с помощью systemd? Внесите необходимые коррективы в файл сервиса или можете взять его здесь https://github.com/slothfk/1c_systemd/blob/master/srv1cv8-ras.service

andy-1983 commented 3 years ago

Да, за запуск отвечает systemd

/opt/1C/v8.3/x86_64/rac session list

Ошибка разбора параметра: cluster

ps -ax | grep ras

11337 ? Ssl 0:00 /opt/1C/v8.3/x86_64/ras cluster --port=1545

пн, 21 дек. 2020 г. в 09:50, Alexey Y. Fedotov notifications@github.com:

885 ? Ss 0:00 /opt/1C/v8.3/x86_64/ras cluster --daemon -p 1545

Уберите из строки запуска ключ --daemon Запускаете RAS с помощью systemd? Внесите необходимые коррективы в файл сервиса или можете взять его здесь https://github.com/slothfk/1c_systemd/blob/master/srv1cv8-ras.service

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748797904, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3LZF7EPF3C6HJZJBODSV3V4HANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

/opt/1C/v8.3/x86_64/rac session list Ошибка разбора параметра: cluster

Попробуйте так /opt/1C/v8.3/x86_64/rac session list --cluster $(/opt/1C/v8.3/x86_64/rac cluster list | awk '/cluster/ { print $3 }')

andy-1983 commented 3 years ago

Извините за беспокойство, раз я теперь знаю что rac работает, то можно вернуться к вашим скриптам.

/etc/zabbix/scripts/1c_license_server.sh info

0:0

В общем вывод по прежнему не изменился, в Zabbix приходят нули.

пн, 21 дек. 2020 г. в 12:10, Alexey Y. Fedotov notifications@github.com:

/opt/1C/v8.3/x86_64/rac session list Ошибка разбора параметра: cluster

Попробуйте так /opt/1C/v8.3/x86_64/rac session list --cluster $(/opt/1C/v8.3/x86_64/rac cluster list | awk '/cluster/ { print $3 }')

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748862235, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3NNKKDK74PJFHBJBEDSV4GHDANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info 0:0

Покажите тогда уж вывод $ ring license list

andy-1983 commented 3 years ago

root@WebKamin2:/home/maintainer# /opt/1C/1CE/components/1c-enterprise-ring-0.19.5+12-x86_64/ring license list 519xxxxxxxxxxxx-8100xxxxx (имя файла: "20201214104705.lic") 365xxxxxxxxxxxx-8100xxxxxx (имя файла: "20201211152731.lic") root@WebKamin2:/home/maintainer# /opt/1C/1CE/components/1c-enterprise-ring-0.19.5+12-x86_64/ring license info --name 519xxxxxxxxx-8100xxxxxx Имя файла лицензии: "20201214104705.lic" Информация о пользователе: Имя: Отчество: Фамилия: e-mail: Компания: Страна: Россия Индекс: 628609 Регион/область: ХМАО-Югра Город: Нижневартовск Улица: Мира Дом: Корпус: Информация о продукте: Описание: 1С Предприятие 8. Лицензия на сервер (х86-64) (программная защита) Дата комплектации: 10:32:52 01.11.2012 Регистрационный номер: 8100xxxxxxG0 Код продукта: 0000000060000 Тип лицензии: Серверная лицензия на 64-разрядный сервер Тип привязки лицензии: Компьютер TechnicalInfo: LicenseType: ServerLicenseFor64BitServer LicenseAssociationType: Computer LicenseGenerationDate: 2012-11-01T10:32:52 ProductCode: 0000000060000 DistributionKitRegistrationNumber: 8100xxxxxxG0 root@WebKamin2:/home/maintainer# /opt/1C/1CE/components/1c-enterprise-ring-0.19.5+12-x86_64/ring license info --name 365xxxxxxxxxxxx-8100xxxxxx Имя файла лицензии: "20201211152731.lic" Информация о пользователе: Имя: Отчество: Фамилия: e-mail: Компания: Страна: Россия Индекс: 628609 Регион/область: ХМАО-Югра Город: Нижневартовск Улица: Мира Дом: Корпус: Информация о продукте: Описание: 1С Предприятие 8. Лицензия на 100 рабочих мест (программная защита) Дата комплектации: 00:00:00 05.08.2013 Регистрационный номер: 8100xxxxxxG0 Код продукта: 0000000000100 Тип лицензии: Клиентская лицензия Тип привязки лицензии: Компьютер TechnicalInfo: LicenseType: ClientLicense LicenseAssociationType: Computer LicenseGenerationDate: 2013-08-05T00:00:00 ProductCode: 0000000000100 DistributionKitRegistrationNumber: 8100xxxxxxG0

Может быть загвоздка в том что именно короткая команда ring не работает, так как его таталоги не входят в path?

пн, 21 дек. 2020 г. в 13:59, Alexey Y. Fedotov notifications@github.com:

/etc/zabbix/scripts/1c_license_server.sh info 0:0

Покажите тогда уж вывод $ ring license list

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748912191, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3PVLWQHPS46H5P7DDTSV4TATANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

Может быть загвоздка в том что именно короткая команда ring не работает, так как его таталоги не входят в path?

В таком случае скрипт должен был бы ругнуться на неустановленную утилиту ring ;)

slothfk commented 3 years ago

И еще, Вы регистрационные данные то в публичный доступ не "сливайте" так, не хорошо это! ;)

slothfk commented 3 years ago

Код продукта: 0000000000100

Проблема в этом! Т.к. подсчет лицензий происходит на основе кода продукта, а такого кода у меня не занесено в список. Для 100 пользователей другой код был ...

andy-1983 commented 3 years ago

чет я забыл что это все на git попадет, не разу кстати с разработчиком github не общался, спасибо за совет

пн, 21 дек. 2020 г. в 14:15, Alexey Y. Fedotov notifications@github.com:

И еще, Вы регистрационные данные то в публичный доступ не "сливайте" так, не хорошо это! ;)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748919843, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3PGBCKL7MOEXXLYMLTSV4U4XANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

andy-1983 commented 3 years ago

там у вас что то типа 0000001000100

пн, 21 дек. 2020 г. в 14:18, Alexey Y. Fedotov notifications@github.com:

Код продукта: 0000000000100

Проблема в этом! Т.к. подсчет лицензий происходит на основе кода продукта, а такого кода у меня не занесено в список. Для 100 пользователей другой код был ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748920951, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3NIZXZ3EVXWVBCIWKDSV4VHJANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

там у вас что то типа 0000001000100

Да, все верно! Эта информация собрана на основе тех лицензий, что у нас используются ... Попробую запросить у 1С возможные коды, но ответят ли - как знать ....

andy-1983 commented 3 years ago

cat /etc/zabbix/scripts/1c_license_server.sh

!/bin/bash

#

Мониторинг 1С Предприятия 8.3 (сервер лицензирования)

#

(c) 2019-2020, Алексей Ю. Федотов

#

Email: fedotov@kaminsoft.ru

#

WORK_DIR=$(dirname "${0}" | sed -r 's/\/\//g; s/^(.{1}):/\/\1/') source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=( # Коды пользовательских лицензий [0000000100005]=5 # 5 пользователей [0000000100015]=10 # 10 пользователей [0000000100050]=50 # 50 пользователей [0000000000100]=100 # 100 пользователей [0000000100500]=500 ) # 500 пользователей

поправил один код лицензии для теста, но результат тот же

/etc/zabbix/scripts/1c_license_server.sh info

0:0

пн, 21 дек. 2020 г. в 14:24, Alexey Y. Fedotov notifications@github.com:

там у вас что то типа 0000001000100

Да, все верно! Эта информация собрана на основе тех лицензий, что у нас используются ... Попробую запросить у 1С возможные коды, но ответят ли - как знать ....

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748923468, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3PJ33OZJ6MZXKPHBSLSV4V6ZANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

поправил один код лицензии для теста, но результат тот же

Ну это логично, потому что еще здесь надо править регэксп в команде awk тогда

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | \ awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

andy-1983 commented 3 years ago

Так

declare -A LICENSE_CODE=( # Коды пользовательских лицензий [0000000000005]=5 # 5 пользователей [0000000000015]=10 # 10 пользователей [0000000000050]=50 # 50 пользователей [0000000000100]=100 # 100 пользователей [0000000000500]=500 ) # 500 пользователей

и так

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | \ awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

Результат

/etc/zabbix/scripts/1c_license_server.sh info

0:0

пн, 21 дек. 2020 г. в 15:04, Alexey Y. Fedotov notifications@github.com:

поправил один код лицензии для теста, но результат тот же

Ну это логично, потому что еще здесь надо править регэксп в команде awk тогда

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748939671, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3PIIUF7TP3HCFTKJM3SV42VPANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

Вот это

awk '/0{7}10{2}[0-9]+/'

надо заменить на awk '/0{7}[01]0{2}[0-9]+/'

andy-1983 commented 3 years ago

Теперь получилось...

Сейчас пишет что количество веб-клиентов = 1. Но у нас все клиенты на тонком клиенте, разве они не должны отображаться как веб?

Вообще большое Вам спасибо, я в принципе могу продолжить, но предлагаю на сегодня закончить.

пн, 21 дек. 2020 г. в 15:27, Alexey Y. Fedotov notifications@github.com:

Вот это

awk '/0{7}10{2}[0-9]+/'

надо заменить на awk '/0{7}[01]0{2}[0-9]+/'

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748948927, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3MNVHLHJYM4CAQHCWTSV45MJANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

Но у нас все клиенты на тонком клиенте, разве они не должны отображаться как веб?

Нет, тонкий - это тонкий, веб - это веб (через браузер)!

andy-1983 commented 3 years ago

image

Сейчас вот такое вижу, но судя по всему количество лицензий пока не правильно прилетает.

пн, 21 дек. 2020 г. в 16:29, Alexey Y. Fedotov notifications@github.com:

Но у нас все клиенты на тонком клиенте, разве они не должны отображаться как веб?

Нет, тонкий - это тонкий, веб - это веб (через браузер)!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748973680, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3IR3QILES7MS24P7OLSV5EVDANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

К сожалению картинка из письма не "приклеилась" к issue, посмотреть ее нет возможности :( Можно прикрепить картинку непосредственно в веб-интерфейсе гитхаба ...

andy-1983 commented 3 years ago

починил картинку.

/etc/zabbix/scripts/1c_license_server.sh info

1:0

я полагал должно отобразится общее число/выданных лицензий

еще ошибка приближения к лимиту лицензий не снялась... вот я и делаю вывод.

пн, 21 дек. 2020 г. в 17:21, Alexey Y. Fedotov notifications@github.com:

К сожалению картинка из письма не "приклеилась" к issue, посмотреть ее нет возможности :( Можно прикрепить картинку непосредственно в веб-интерфейсе гитхаба ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-748997559, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3KJVJ7MENH7UPAXEQDSV5KUZANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

я полагал должно отобразится общее число/выданных лицензий

подобный вывод говорит о том, что найден 1 файл лицензии, на 0 пользователей, т.е. что-то пошло не так!

еще ошибка приближения к лимиту лицензий не снялась..

"ошибка" лимита лицензий связана с предыдущим пунктом, т.к. заббикс "не видит" доступных лицензий ....

slothfk commented 3 years ago

а покажите ка вывод $ ls -al /var/1C/licenses

andy-1983 commented 3 years ago

ls -al /var/1C/licenses итого 24 drwxrwxr-x 2 usr1cv8 grp1cv8 4096 дек 14 12:19 . drwxrwxr-x 3 usr1cv8 grp1cv8 4096 май 29 2020 .. -rw-r--r-- 1 usr1cv8 grp1cv8 4959 дек 14 12:19 20201211152731.lic -rw-r--r-- 1 usr1cv8 grp1cv8 4956 дек 14 12:15 20201214104705.lic

пн, 21 дек. 2020 г. в 17:57, Alexey Y. Fedotov notifications@github.com:

а покажите ка вывод $ ls -al /var/1C/licenses

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749015449, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3LTM7DL5S5Z5D2US6TSV5O63ANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

Замените этот код

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | \ awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

на следующий CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

andy-1983 commented 3 years ago

На всякий случай привожу полный тест скрипта

cat /etc/zabbix/scripts/1c_license_server.sh

!/bin/bash

#

Мониторинг 1С Предприятия 8.3 (сервер лицензирования)

#

(c) 2019-2020, Алексей Ю. Федотов

#

Email: fedotov@kaminsoft.ru

#

WORK_DIR=$(dirname "${0}" | sed -r 's/\/\//g; s/^(.{1}):/\/\1/') source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=( # Коды пользовательских лицензий [0000000000005]=5 # 5 пользователей [0000000000015]=10 # 10 пользователей [0000000000050]=50 # 50 пользователей [0000000000100]=100 # 100 пользователей [0000000000500]=500 ) # 500 пользователей

function licenses_summary {

RING_TOOL=$(check_ring_license) || exit 1

( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \
    awk 'BEGIN { files=0; users=0 }
        { files+=1; users+=$1 }
        END { print files":"users }'

}

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | \

awk '/0{7}[01]0{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//'

)

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

function get_license_counts {

CLSTR_LIST=${1##*:}

for CURR_CLSTR in ${CLSTR_LIST//;/ }; do
    timeout -s HUP ${RAS_PARAMS[timeout]} rac session list --licenses

--cluster=${CURR_CLSTR%%,} \ ${RAS_PARAMS[auth]} ${1%%:}:${RAS_PARAMS[port]} 2>/dev/null | \ awk '/(user-name|rmngr-address|app-id)/' | \ perl -pe 's/ //g; s/\n/|/; s/rmngr-address:(\"(.)\"|)||/\2/; s/app-id://; s/user-name:/\n/;' | \ awk -F"|" -v hostname=${HOSTNAME,,} -v cluster=${CURR_CLSTR%%,} 'BEGIN { sc=0; hc=0; cc=0; wc=0 } \ { if ($1 != "") { sc+=1; uc[$1]; if ( index(tolower($3), hostname) > 0 ) { hc+=1 } \ if ($2 == "WebClient") { wc+=1 } if ($3 == "") { cc+=1 } } } \ END {print "CL#"cluster":"hc":"length(uc)":"sc":"cc":"wc }' done

}

function used_license {

( execute_tasks get_license_counts $( pop_clusters_list ) ) | \
    awk -F: 'BEGIN {ul=0; as=0; cl=0; uu=0; wc=0} \
        { print $0; ul+=$2; uu+=$3; as+=$4; cl+=$5; wc+=$6; } \
        END { print "summary:"ul":"uu":"as":"cl":"wc }' | sed 's/<sp>/

/g'

}

function get_clusters_list {

pop_clusters_list | cut -f2 -d: | perl -pe 's/;[^\n]/\n/; s/;//' | \
    awk 'BEGIN {FS=","; print "{\"data\":[" } \
        {print

"{\"{#CLSTR_UUID}\":\""$1"\",\"{#CLSTR_NAME}\":\""$3"\"}," } \ END { print "]}" }' | \ perl -pe 's/\n//;' | perl -pe 's/(.*),]}/\1]}\n/; s// /g'

}

function check_clusters_disconnection {

LOST_CLSTR=$( check_clusters_cache lost | sed 's/ /<sp>/g; s/"//g' )

if [[ -n ${LOST_CLSTR} ]]; then
    echo "Произошло отключение от кластера (сервер, имя):"
    for CURR_RMNGR in ${LOST_CLSTR}; do
        for CURR_CLSTR in ${CURR_RMNGR//;/ }; do
            echo "${CURR_RMNGR%:*} - ${CURR_CLSTR##*,}" | sed 's/<sp>/

/g' done done else echo "OK" fi

}

case ${1} in info) licenses_summary ;; used) shift; make_ras_params ${@}; used_license ;; clusters) get_clusters_list ;; check) check_clusters_disconnection ;; *) error "${ERROR_UNKNOWN_MODE}" ;; esac

Вывод не изменился

/etc/zabbix/scripts/1c_license_server.sh info

1:0

пн, 21 дек. 2020 г. в 18:17, Alexey Y. Fedotov notifications@github.com:

Замените этот код

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | \ awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

на следующий CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749025666, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3PSHG4ZJQUO6TS6YNDSV5RIRANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

вставьте перед этой строкой следующую строку echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]} и пришлите вывод $ /etc/zabbix/scripts/1c_license_server.sh info

andy-1983 commented 3 years ago

cat /etc/zabbix/scripts/1c_license_server.sh

!/bin/bash

#

Мониторинг 1С Предприятия 8.3 (сервер лицензирования)

#

(c) 2019-2020, Алексей Ю. Федотов

#

Email: fedotov@kaminsoft.ru

#

WORK_DIR=$(dirname "${0}" | sed -r 's/\/\//g; s/^(.{1}):/\/\1/') source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=( # Коды пользовательских лицензий [0000000000005]=5 # 5 пользователей [0000000000015]=10 # 10 пользователей [0000000000050]=50 # 50 пользователей [0000000000100]=100 # 100 пользователей [0000000000500]=500 ) # 500 пользователей

function licenses_summary {

RING_TOOL=$(check_ring_license) || exit 1

( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \
    awk 'BEGIN { files=0; users=0 }
        { files+=1; users+=$1 }
        END { print files":"users }'

}

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | \

awk '/0{7}[01]0{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//'

)

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]}

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

function get_license_counts {

CLSTR_LIST=${1##*:}

for CURR_CLSTR in ${CLSTR_LIST//;/ }; do
    timeout -s HUP ${RAS_PARAMS[timeout]} rac session list --licenses

--cluster=${CURR_CLSTR%%,} \ ${RAS_PARAMS[auth]} ${1%%:}:${RAS_PARAMS[port]} 2>/dev/null | \ awk '/(user-name|rmngr-address|app-id)/' | \ perl -pe 's/ //g; s/\n/|/; s/rmngr-address:(\"(.)\"|)||/\2/; s/app-id://; s/user-name:/\n/;' | \ awk -F"|" -v hostname=${HOSTNAME,,} -v cluster=${CURR_CLSTR%%,} 'BEGIN { sc=0; hc=0; cc=0; wc=0 } \ { if ($1 != "") { sc+=1; uc[$1]; if ( index(tolower($3), hostname) > 0 ) { hc+=1 } \ if ($2 == "WebClient") { wc+=1 } if ($3 == "") { cc+=1 } } } \ END {print "CL#"cluster":"hc":"length(uc)":"sc":"cc":"wc }' done

}

function used_license {

( execute_tasks get_license_counts $( pop_clusters_list ) ) | \
    awk -F: 'BEGIN {ul=0; as=0; cl=0; uu=0; wc=0} \
        { print $0; ul+=$2; uu+=$3; as+=$4; cl+=$5; wc+=$6; } \
        END { print "summary:"ul":"uu":"as":"cl":"wc }' | sed 's/<sp>/

/g'

}

function get_clusters_list {

pop_clusters_list | cut -f2 -d: | perl -pe 's/;[^\n]/\n/; s/;//' | \
    awk 'BEGIN {FS=","; print "{\"data\":[" } \
        {print

"{\"{#CLSTR_UUID}\":\""$1"\",\"{#CLSTR_NAME}\":\""$3"\"}," } \ END { print "]}" }' | \ perl -pe 's/\n//;' | perl -pe 's/(.*),]}/\1]}\n/; s// /g'

}

function check_clusters_disconnection {

LOST_CLSTR=$( check_clusters_cache lost | sed 's/ /<sp>/g; s/"//g' )

if [[ -n ${LOST_CLSTR} ]]; then
    echo "Произошло отключение от кластера (сервер, имя):"
    for CURR_RMNGR in ${LOST_CLSTR}; do
        for CURR_CLSTR in ${CURR_RMNGR//;/ }; do
            echo "${CURR_RMNGR%:*} - ${CURR_CLSTR##*,}" | sed 's/<sp>/

/g' done done else echo "OK" fi

}

case ${1} in info) licenses_summary ;; used) shift; make_ras_params ${@}; used_license ;; clusters) get_clusters_list ;; check) check_clusters_disconnection ;; *) error "${ERROR_UNKNOWN_MODE}" ;; esac

/etc/zabbix/scripts/1c_license_server.sh info

/etc/zabbix/scripts/1c_license_server.sh: строка 85: синтаксическая ошибка рядом с неожиданным маркером «(» /etc/zabbix/scripts/1c_license_server.sh: строка 85: ` echo "Произошло отключение от кластера (сервер, имя):"'

пн, 21 дек. 2020 г. в 18:31, Alexey Y. Fedotov notifications@github.com:

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

вставьте перед этой строкой следующую строку echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]} и пришлите вывод $ /etc/zabbix/scripts/1c_license_server.sh info

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749033778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3N7RRZJZDGUPXXBUDLSV5S5PANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

andy-1983 commented 3 years ago

echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]}"

/etc/zabbix/scripts/1c_license_server.sh info 5:300

пн, 21 дек. 2020 г. в 18:36, Андрей Нурулин a.s.nurulin@gmail.com:

cat /etc/zabbix/scripts/1c_license_server.sh

!/bin/bash

#

Мониторинг 1С Предприятия 8.3 (сервер лицензирования)

#

(c) 2019-2020, Алексей Ю. Федотов

#

Email: fedotov@kaminsoft.ru

#

WORK_DIR=$(dirname "${0}" | sed -r 's/\/\//g; s/^(.{1}):/\/\1/') source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=( # Коды пользовательских лицензий [0000000000005]=5 # 5 пользователей [0000000000015]=10 # 10 пользователей [0000000000050]=50 # 50 пользователей [0000000000100]=100 # 100 пользователей [0000000000500]=500 ) # 500 пользователей

function licenses_summary {

RING_TOOL=$(check_ring_license) || exit 1

( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \
    awk 'BEGIN { files=0; users=0 }
        { files+=1; users+=$1 }
        END { print files":"users }'

}

function license_info {

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | \

awk '/0{7}[01]0{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/;

s/^$//' )

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false

--name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]}

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

function get_license_counts {

CLSTR_LIST=${1##*:}

for CURR_CLSTR in ${CLSTR_LIST//;/ }; do
    timeout -s HUP ${RAS_PARAMS[timeout]} rac session list --licenses

--cluster=${CURR_CLSTR%%,} \ ${RAS_PARAMS[auth]} ${1%%:}:${RAS_PARAMS[port]} 2>/dev/null | \ awk '/(user-name|rmngr-address|app-id)/' | \ perl -pe 's/ //g; s/\n/|/; s/rmngr-address:(\"(.)\"|)||/\2/; s/app-id://; s/user-name:/\n/;' | \ awk -F"|" -v hostname=${HOSTNAME,,} -v cluster=${CURR_CLSTR%%,} 'BEGIN { sc=0; hc=0; cc=0; wc=0 } \ { if ($1 != "") { sc+=1; uc[$1]; if ( index(tolower($3), hostname) > 0 ) { hc+=1 } \ if ($2 == "WebClient") { wc+=1 } if ($3 == "") { cc+=1 } } } \ END {print "CL#"cluster":"hc":"length(uc)":"sc":"cc":"wc }' done

}

function used_license {

( execute_tasks get_license_counts $( pop_clusters_list ) ) | \
    awk -F: 'BEGIN {ul=0; as=0; cl=0; uu=0; wc=0} \
        { print $0; ul+=$2; uu+=$3; as+=$4; cl+=$5; wc+=$6; } \
        END { print "summary:"ul":"uu":"as":"cl":"wc }' | sed 's/<sp>/

/g'

}

function get_clusters_list {

pop_clusters_list | cut -f2 -d: | perl -pe 's/;[^\n]/\n/; s/;//' | \
    awk 'BEGIN {FS=","; print "{\"data\":[" } \
        {print

"{\"{#CLSTR_UUID}\":\""$1"\",\"{#CLSTR_NAME}\":\""$3"\"}," } \ END { print "]}" }' | \ perl -pe 's/\n//;' | perl -pe 's/(.*),]}/\1]}\n/; s// /g'

}

function check_clusters_disconnection {

LOST_CLSTR=$( check_clusters_cache lost | sed 's/ /<sp>/g; s/"//g' )

if [[ -n ${LOST_CLSTR} ]]; then
    echo "Произошло отключение от кластера (сервер, имя):"
    for CURR_RMNGR in ${LOST_CLSTR}; do
        for CURR_CLSTR in ${CURR_RMNGR//;/ }; do
            echo "${CURR_RMNGR%:*} - ${CURR_CLSTR##*,}" | sed 's/<sp>/

/g' done done else echo "OK" fi

}

case ${1} in info) licenses_summary ;; used) shift; make_ras_params ${@}; used_license ;; clusters) get_clusters_list ;; check) check_clusters_disconnection ;; *) error "${ERROR_UNKNOWN_MODE}" ;; esac

/etc/zabbix/scripts/1c_license_server.sh info

/etc/zabbix/scripts/1c_license_server.sh: строка 85: синтаксическая ошибка рядом с неожиданным маркером «(» /etc/zabbix/scripts/1c_license_server.sh: строка 85: ` echo "Произошло отключение от кластера (сервер, имя):"'

пн, 21 дек. 2020 г. в 18:31, Alexey Y. Fedotov notifications@github.com:

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

вставьте перед этой строкой следующую строку echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]} и пришлите вывод $ /etc/zabbix/scripts/1c_license_server.sh info

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749033778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3N7RRZJZDGUPXXBUDLSV5S5PANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info 5:300

Очень интересно ...

Замените функцию

function licenses_summary {

    RING_TOOL=$(check_ring_license) || exit 1

    ( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \
        awk 'BEGIN { files=0; users=0 }
            { files+=1; users+=$1; print $1 }
            END { print files":"users }'

}

и пришлите аналогичный вывод скрипта ...

andy-1983 commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info

:[]} 0000000000100 0000000000100:[ 0000000000100]}

5:300

вт, 22 дек. 2020 г. в 09:16, Alexey Y. Fedotov notifications@github.com:

/etc/zabbix/scripts/1c_license_server.sh info 5:300

Очень интересно ...

Замените функцию

function licenses_summary {

RING_TOOL=$(check_ring_license) || exit 1

( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \

    awk 'BEGIN { files=0; users=0 }

        { files+=1; users+=$1; print $1 }

        END { print files":"users }'

}

и пришлите аналогичный вывод скрипта ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749364048, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3NVP4U4YP3I7RYFPY3SWA2UPANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]}"

В этой строке Вы ошибку не скорректировали? Должно выглядеть вот так echo "${CURRENT_CODE}:${LICENSE_CODE[${CURRENT_CODE}]}"

andy-1983 commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info

/etc/zabbix/scripts/1c_license_server.sh: строка 41: LICENSE_CODE: неправильный индекс массива : 0000000000100 0000000000100:

4:200

Привожу полный текст сценария:

# cat /etc/zabbix/scripts/1c_license_server.sh
#!/bin/bash
#
# Мониторинг 1С Предприятия 8.3 (сервер лицензирования)
#
# (c) 2019-2020, Алексей Ю. Федотов
#
# Email: fedotov@kaminsoft.ru
#

WORK_DIR=$(dirname "${0}" | sed -r 's/\\/\//g; s/^(.{1}):/\/\1/')
source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не
найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=(    # Коды пользовательских лицензий
    [0000000000005]=5        # 5 пользователей
    [0000000000015]=10       # 10 пользователей
    [0000000000050]=50       # 50 пользователей
    [0000000000100]=100      # 100 пользователей
    [0000000000500]=500 )    # 500 пользователей

function licenses_summary {

    RING_TOOL=$(check_ring_license) || exit 1

    ( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \

        awk 'BEGIN { files=0; users=0 }

            { files+=1; users+=$1; print $1 }

            END { print files":"users }'

}

function license_info {

#    CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false
--name ${1} | \
#        awk '/0{7}[01]0{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//'
)

    CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false
--name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

    echo "${CURRENT_CODE}:${LICENSE_CODE[${CURRENT_CODE}]}"

    [[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

function get_license_counts {

    CLSTR_LIST=${1##*:}

    for CURR_CLSTR in ${CLSTR_LIST//;/ }; do
        timeout -s HUP ${RAS_PARAMS[timeout]} rac session list --licenses
--cluster=${CURR_CLSTR%%,*} \
            ${RAS_PARAMS[auth]} ${1%%:*}:${RAS_PARAMS[port]} 2>/dev/null | \
            awk '/(user-name|rmngr-address|app-id)/' | \
            perl -pe 's/ //g; s/\n/|/; s/rmngr-address:(\"(.*)\"|)\||/\2/;
s/app-id://; s/user-name:/\n/;' | \
            awk -F"|" -v hostname=${HOSTNAME,,} -v
cluster=${CURR_CLSTR%%,*} 'BEGIN { sc=0; hc=0; cc=0; wc=0 } \
                { if ($1 != "") { sc+=1; uc[$1]; if ( index(tolower($3),
hostname) > 0 ) { hc+=1 } \
                if ($2 == "WebClient") { wc+=1 } if ($3 == "") { cc+=1 } }
} \
                END {print "CL#"cluster":"hc":"length(uc)":"sc":"cc":"wc }'
    done

}

function used_license {

    ( execute_tasks get_license_counts $( pop_clusters_list ) ) | \
        awk -F: 'BEGIN {ul=0; as=0; cl=0; uu=0; wc=0} \
            { print $0; ul+=$2; uu+=$3; as+=$4; cl+=$5; wc+=$6; } \
            END { print "summary:"ul":"uu":"as":"cl":"wc }' | sed 's/<sp>/
/g'

}

function get_clusters_list {

    pop_clusters_list | cut -f2 -d: | perl -pe 's/;[^\n]/\n/; s/;//' | \
        awk 'BEGIN {FS=","; print "{\"data\":[" } \
            {print
"{\"{#CLSTR_UUID}\":\""$1"\",\"{#CLSTR_NAME}\":\""$3"\"}," } \
            END { print "]}" }' | \
        perl -pe 's/\n//;' | perl -pe 's/(.*),]}/\1]}\n/; s/<sp>/ /g'

}

function check_clusters_disconnection {

    LOST_CLSTR=$( check_clusters_cache lost | sed 's/ /<sp>/g; s/"//g' )

    if [[ -n ${LOST_CLSTR} ]]; then
        echo "Произошло отключение от кластера (сервер, имя):"
        for CURR_RMNGR in ${LOST_CLSTR}; do
            for CURR_CLSTR in ${CURR_RMNGR//;/ }; do
                echo "${CURR_RMNGR%:*} - ${CURR_CLSTR##*,}" | sed 's/<sp>/
/g'
            done
        done
    else
        echo "OK"
    fi

}

case ${1} in
    info) licenses_summary ;;
    used) shift; make_ras_params ${@}; used_license ;;
    clusters) get_clusters_list ;;
    check) check_clusters_disconnection ;;
    *) error "${ERROR_UNKNOWN_MODE}" ;;
esac

вт, 22 дек. 2020 г. в 14:17, Alexey Y. Fedotov notifications@github.com:

echo "${CURRENT_CODE}:$LICENSE_CODE[${CURRENT_CODE}]}"

В этой строке Вы ошибку не скорректировали? Должно выглядеть вот так echo "${CURRENT_CODE}:${LICENSE_CODE[${CURRENT_CODE}]}"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749489896, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3KJAIQ65QHDDX3RWKLSWB53ZANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

а выполните пожалуйста $ bash --version

andy-1983 commented 3 years ago

root@WebKamin2:/home/maintainer# bash --version GNU bash, версия 4.4.12(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. Лицензия GPLv3+: GNU GPL версии 3 или более поздней < http://gnu.org/licenses/gpl.html>

вт, 22 дек. 2020 г. в 16:10, Alexey Y. Fedotov notifications@github.com:

а выполните пожалуйста $ bash --version

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-749532635, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3OK4VH3IAJ5I5ULT6LSWCLFHANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

А попробуйте перед строкой

function licenses_summary {

вставить код export LICENSE_CODE

и опять прислать вывод

/etc/zabbix/scripts/1c_license_server.sh info

andy-1983 commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info

/etc/zabbix/scripts/1c_license_server.sh: строка 20: export: «{»: это недопустимый идентификатор /etc/zabbix/scripts/1c_common_module.sh: строка 59: license_info: команда не найдена /etc/zabbix/scripts/1c_common_module.sh: строка 59: license_info: команда не найдена 0:0 /etc/zabbix/scripts/1c_license_server.sh: строка 32: синтаксическая ошибка рядом с неожиданным маркером «}» /etc/zabbix/scripts/1c_license_server.sh: строка 32: `}'

# cat /etc/zabbix/scripts/1c_license_server.sh
#!/bin/bash
#
# Мониторинг 1С Предприятия 8.3 (сервер лицензирования)
#
# (c) 2019-2020, Алексей Ю. Федотов
#
# Email: fedotov@kaminsoft.ru
#

WORK_DIR=$(dirname "${0}" | sed -r 's/\\/\//g; s/^(.{1}):/\/\1/')
source "${WORK_DIR}"/1c_common_module.sh 2>/dev/null || { echo "ОШИБКА: Не
найден файл 1c_common_module.sh!" ; exit 1; }

declare -A LICENSE_CODE=(    # Коды пользовательских лицензий
    [0000000000005]=5        # 5 пользователей
    [0000000000015]=10       # 10 пользователей
    [0000000000050]=50       # 50 пользователей
    [0000000000100]=100      # 100 пользователей
    [0000000000500]=500 )    # 500 пользователей

export LICENSE_CODE function licenses_summary {

    RING_TOOL=$(check_ring_license) || exit 1

    ( execute_tasks license_info $(get_license_list "${RING_TOOL}") ) | \

        awk 'BEGIN { files=0; users=0 }

            { files+=1; users+=$1; print $1 }

            END { print files":"users }'

}

function license_info {

#    CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false
--name ${1} | \
#        awk '/0{7}[01]0{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//'
)

    CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false
--name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

    echo "${CURRENT_CODE}:${LICENSE_CODE[${CURRENT_CODE}]}"

    [[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

}

function get_license_counts {

    CLSTR_LIST=${1##*:}

    for CURR_CLSTR in ${CLSTR_LIST//;/ }; do
        timeout -s HUP ${RAS_PARAMS[timeout]} rac session list --licenses
--cluster=${CURR_CLSTR%%,*} \
            ${RAS_PARAMS[auth]} ${1%%:*}:${RAS_PARAMS[port]} 2>/dev/null | \
            awk '/(user-name|rmngr-address|app-id)/' | \
            perl -pe 's/ //g; s/\n/|/; s/rmngr-address:(\"(.*)\"|)\||/\2/;
s/app-id://; s/user-name:/\n/;' | \
            awk -F"|" -v hostname=${HOSTNAME,,} -v
cluster=${CURR_CLSTR%%,*} 'BEGIN { sc=0; hc=0; cc=0; wc=0 } \
                { if ($1 != "") { sc+=1; uc[$1]; if ( index(tolower($3),
hostname) > 0 ) { hc+=1 } \
                if ($2 == "WebClient") { wc+=1 } if ($3 == "") { cc+=1 } }
} \
                END {print "CL#"cluster":"hc":"length(uc)":"sc":"cc":"wc }'
    done

}

function used_license {

    ( execute_tasks get_license_counts $( pop_clusters_list ) ) | \
        awk -F: 'BEGIN {ul=0; as=0; cl=0; uu=0; wc=0} \
            { print $0; ul+=$2; uu+=$3; as+=$4; cl+=$5; wc+=$6; } \
            END { print "summary:"ul":"uu":"as":"cl":"wc }' | sed 's/<sp>/
/g'

}

function get_clusters_list {

    pop_clusters_list | cut -f2 -d: | perl -pe 's/;[^\n]/\n/; s/;//' | \
        awk 'BEGIN {FS=","; print "{\"data\":[" } \
            {print
"{\"{#CLSTR_UUID}\":\""$1"\",\"{#CLSTR_NAME}\":\""$3"\"}," } \
            END { print "]}" }' | \
        perl -pe 's/\n//;' | perl -pe 's/(.*),]}/\1]}\n/; s/<sp>/ /g'

}

function check_clusters_disconnection {

    LOST_CLSTR=$( check_clusters_cache lost | sed 's/ /<sp>/g; s/"//g' )

    if [[ -n ${LOST_CLSTR} ]]; then
        echo "Произошло отключение от кластера (сервер, имя):"
        for CURR_RMNGR in ${LOST_CLSTR}; do
            for CURR_CLSTR in ${CURR_RMNGR//;/ }; do
                echo "${CURR_RMNGR%:*} - ${CURR_CLSTR##*,}" | sed 's/<sp>/
/g'
            done
        done
    else
        echo "OK"
    fi

}

case ${1} in
    info) licenses_summary ;;
    used) shift; make_ras_params ${@}; used_license ;;
    clusters) get_clusters_list ;;
    check) check_clusters_disconnection ;;
    *) error "${ERROR_UNKNOWN_MODE}" ;;
esac

ср, 23 дек. 2020 г. в 17:25, Alexey Y. Fedotov notifications@github.com:

А попробуйте перед строкой

function licenses_summary {

вставить код export LICENSE_CODE

и опять прислать вывод

/etc/zabbix/scripts/1c_license_server.sh info

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-750322765, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3JJFCLT2P4OZRLCBSDSWH4WPANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

export LICENSE_CODE function licenses_summary {

я же написал "перед СТРОКОЙ", т.е. это должно выглядеть как

export LICENSE_CODE

function licenses_summary {
andy-1983 commented 3 years ago

/etc/zabbix/scripts/1c_license_server.sh info

/etc/zabbix/scripts/1c_license_server.sh: строка 43: LICENSE_CODE: неправильный индекс массива : 0000000000100 0000000000100:

4:200

да, извините, сообразил уже, исправленная версия, но тоже пока не работает

ср, 23 дек. 2020 г. в 17:55, Alexey Y. Fedotov notifications@github.com:

export LICENSE_CODE function licenses_summary {

я же написал "ПЕРЕД" строкой, т.е. это должно выглядеть как

export LICENSE_CODE

function licenses_summary {

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-750336018, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3JDNHOSFL2SVC7RVO3SWIAHVANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

Пока "заткнуть дырку" можно так:

  1. Взять исходный скрипт
  2. Заменить строки

    CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk '/0{7}10{2}[0-9]+/' | perl -pe 's/.*: (\d{10})/\1/; s/^$//' )

на следующую CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2; exit }' )

  1. Заменить строку

    [[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

на следующую [[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE## }]}

А я пока подумаю, как это сделать более красиво ;)

andy-1983 commented 3 years ago

то есть нужно взять скрипт из репозитория? А коды лицензий не нужно править, они же константы?

пт, 25 дек. 2020 г. в 12:13, Alexey Y. Fedotov notifications@github.com:

Пока "заткнуть дырку" можно так:

  1. Взять исходный скрипт
  2. Заменить строку

CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2 }' )

на следующую CURRENT_CODE=$( "${RING_TOOL}" license info --send-statistics false --name ${1} | awk -F: '/0{7}[10]0{2}[0-9]+/ { print $2; exit }' )

  1. Заменить строку

[[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE}]}

на следующую [[ -n ${CURRENT_CODE} ]] && echo ${LICENSE_CODE[${CURRENT_CODE## }]}

А я пока подумаю, как это сделать более красиво ;)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-751216379, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3NOHWBGD3WFDWZB3T3SWRJU5ANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940

slothfk commented 3 years ago

А коды лицензий не нужно править, они же константы?

Да их тоже надо поправить! Забыл про них написать :/

andy-1983 commented 3 years ago

Сейчас все отработало, информация корректна.

Спасибо Вам и с наступающим новым годом!

пт, 25 дек. 2020 г. в 16:02, Alexey Y. Fedotov notifications@github.com:

А коды лицензий не нужно править, они же константы?

Да их тоже надо поправить! Забыл про них написать :/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/slothfk/1c_zabbix_template_ce/issues/49#issuecomment-751246246, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXBX3MXFE7ANWJ2E2QMM7DSWSEOPANCNFSM4VCHKKQA .

--

С уважением, Андрей Нурулин. тел. +7-982-570-0940