Skip to content

Commit

Permalink
CE: Ограничения для информационных баз (fix #63)
Browse files Browse the repository at this point in the history
- Отслеживание блокировки начала сеансов
- Отслеживание блокировки регламентных заданий
  • Loading branch information
slothfk committed May 20, 2021
1 parent 6097cea commit 1f7e464
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 2 deletions.
76 changes: 75 additions & 1 deletion 1c_central_server.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>4.4</version>
<date>2021-05-14T12:43:35Z</date>
<date>2021-05-20T10:09:10Z</date>
<groups>
<group>
<name>Templates (Kaminsoft)</name>
Expand Down Expand Up @@ -31,6 +31,20 @@
</application>
</applications>
<items>
<item>
<name>[1С/Инфобаза] Ограничения</name>
<type>ZABBIX_ACTIVE</type>
<key>1c.cs.ib.restrictions</key>
<delay>5m</delay>
<history>0</history>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>[1С] Информация</name>
</application>
</applications>
</item>
<item>
<name>[1С/Сеансы] Количество активных</name>
<type>DEPENDENT</type>
Expand Down Expand Up @@ -713,6 +727,66 @@
</application>
</applications>
</item_prototype>
<item_prototype>
<name>[1С/Инфобаза/{#IB_NAME}] Блокировка регламентных заданий</name>
<type>DEPENDENT</type>
<key>1c.cs.ib.sched_deny[{#IB_UUID}]</key>
<delay>0</delay>
<history>30d</history>
<trends>90d</trends>
<applications>
<application>
<name>[1С] Информация</name>
</application>
</applications>
<preprocessing>
<step>
<type>REGEX</type>
<params>IB#{#IB_UUID},\d+,(\d+)
\1</params>
</step>
</preprocessing>
<master_item>
<key>1c.cs.ib.restrictions</key>
</master_item>
<trigger_prototypes>
<trigger_prototype>
<expression>{last()}=1</expression>
<name>[1С/Ифобаза/{#IB_NAME}] Включена блокировка регламентных заданий</name>
<priority>AVERAGE</priority>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
<item_prototype>
<name>[1С/Инфобаза/{#IB_NAME}] Блокировка начала сеансов</name>
<type>DEPENDENT</type>
<key>1c.cs.ib.sess_deny[{#IB_UUID}]</key>
<delay>0</delay>
<history>30d</history>
<trends>90d</trends>
<applications>
<application>
<name>[1С] Информация</name>
</application>
</applications>
<preprocessing>
<step>
<type>REGEX</type>
<params>IB#{#IB_UUID},(\d+),\d+
\1</params>
</step>
</preprocessing>
<master_item>
<key>1c.cs.ib.restrictions</key>
</master_item>
<trigger_prototypes>
<trigger_prototype>
<expression>{last()}=1</expression>
<name>[1С/Ифобаза/{#IB_NAME}] Включена блокировка начала сеансов</name>
<priority>AVERAGE</priority>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
<item_prototype>
<name>[1С/Инфобаза/{#IB_NAME}] Сеанс длительного пользовательского вызова</name>
<type>DEPENDENT</type>
Expand Down
3 changes: 2 additions & 1 deletion configs/userparameter_1c-cs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
# Email: [email protected]
#

UserParameter=1c.cs.infobase.availability[*],/etc/zabbix/scripts/1c_central_server.sh ib_status $1
UserParameter=1c.cs.ib.availability[*],/etc/zabbix/scripts/1c_central_server.sh ib_status $1
UserParameter=1c.cs.sessions[*],/etc/zabbix/scripts/1c_central_server.sh sessions $1 $2 $3 $4
UserParameter=1c.cs.ib.restrictions[*],/etc/zabbix/scripts/1c_central_server.sh ib_restrict

UserParameter=1c.cs.clusters.discovery[*],/etc/zabbix/scripts/1c_central_server.sh clusters
UserParameter=1c.cs.infobases.discovery[*],/etc/zabbix/scripts/1c_central_server.sh infobases $1 $2 $3 $4 $5
3 changes: 3 additions & 0 deletions configs/zabbix.sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Defaults: zabbix !requiretty

zabbix ALL = (usr1cv8) NOPASSWD: /usr/bin/find * -name 1CV8Clst.lst -exec grep DBMS -A1 {} +
1 change: 1 addition & 0 deletions playbooks/roles/1c_cs/files/zabbix.sudoers
8 changes: 8 additions & 0 deletions playbooks/roles/1c_cs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
# tasks file for 1c_cs

- name: Copy sudoers file for zabbix user
copy:
src: zabbix.sudoers
dest: /etc/sudoers.d/zabbix
owner: root
group: root
mode: 0440

- name: Copy userparameter for central server
copy:
src: userparameter_1c-cs.conf
Expand Down
7 changes: 7 additions & 0 deletions scripts/1c_central_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ function get_session_amounts {

}

function get_infobases_restrictions {
[[ -z ${IS_WINDOWS} ]] && COMMAND_PREFIX="sudo -u ${USR1CV8}" || COMMAND_PREFIX=""
get_server_directory | xargs -I{{}} ${COMMAND_PREFIX} find {{}} -maxdepth 2 -name 1CV8Clst.lst -exec grep DBMS -A1 {} + |
perl -pe 's/([^}],)\r?\n/\1/' |
perl -pe 's/.*{(\w{8}-\w{4}-\w{4}-\w{4}-\w{12}),.+{([01]).+},([01]),.*/IB#\1,\2,\3/'
}

case ${1} in
ib_status) shift; get_infobase_status ${@} ;;
sessions) shift; make_ras_params ${@}; get_session_amounts ;;
infobases) shift 2; make_ras_params ${@}; get_infobases_list ;;
clusters) get_clusters_list ;;
ib_restrict) get_infobases_restrictions ;;
*) error "${ERROR_UNKNOWN_MODE}" ;;
esac

3 changes: 3 additions & 0 deletions scripts/1c_common_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function error {
echo "ОШИБКА: ${1}" >&2 ; exit 1
}

# Системный пользователь для запуска сервера 1С Предприятия
export USR1CV8="usr1cv8"

# Тип операционной системы GNU/Linux или MS Windows
[[ "$(uname -s)" != "Linux" ]] && IS_WINDOWS=1

Expand Down

0 comments on commit 1f7e464

Please sign in to comment.