Skip to content

Commit 4763353

Browse files
author
alexander popov
committed
fix: send 'ok' to zabbix if no error, change trigger
1 parent fdc0e4f commit 4763353

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mamonsu/plugins/system/linux/pg_probackup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run(self, zbx):
7878
except Exception as e:
7979
self.log.error('Error in convert data: {stdout} \n {e}'.format(stdout=stdout, e=e))
8080
continue
81-
81+
no_error= True
8282
for instance in result:
8383
for backup in instance.get('backups', []):
8484
status = backup['status']
@@ -88,7 +88,10 @@ def run(self, zbx):
8888
instance_name=instance['instance'],
8989
status=status, backup_catalog=_dir)
9090
self.log.info(error)
91+
no_error = False
9192
zbx.send(self.key_dir_error.format('[' + _dir + ']'), error)
93+
if no_error:
94+
zbx.send(self.key_dir_error.format('[' + _dir + ']'), 'ok')
9295

9396
zbx.send(self.key_main.format('[]'), zbx.json({'data': dirs}))
9497
del dirs
@@ -135,6 +138,6 @@ def discovery_rules(self, template):
135138
triggers = [{
136139
'name': 'Error in backup dir '
137140
'{#BACKUPDIR} (hostname={HOSTNAME} value={ITEM.LASTVALUE})',
138-
'expression': '{#TEMPLATE:pg_probackup.dir.error[{#BACKUPDIR}].strlen()}>1'}
141+
'expression': '{#TEMPLATE:pg_probackup.dir.error[{#BACKUPDIR}].str(ok)}<>1'}
139142
]
140143
return template.discovery_rule(rule=rule, conditions=conditions, items=items, graphs=graphs, triggers=triggers)

0 commit comments

Comments
 (0)