2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def inventory_plesk_backups(info
):
31 inventory
.append((line
[0], {}))
35 def check_plesk_backups(item
, params
, info
):
40 if len(line
) != 5 or line
[1] != '0':
42 return (3, 'Error in agent (%s)' % ' '.join(line
[1:]))
45 state
= params
.get('no_backup_configured_state', 1)
46 return (state
, 'No backup configured')
49 state
= params
.get('no_backup_found_state', 1)
50 return (state
, 'No backup found')
52 return (3, 'Unexpected line %r' % line
)
54 _domain
, _rc
, timestamp
, size
, total_size
= line
56 total_size
= saveint(total_size
)
57 timestamp
= saveint(timestamp
)
63 # 1. check last backup size not 0 bytes
68 output
.append('Last Backup - Size: %s%s' % (get_bytes_human_readable(size
), status_txt
))
69 perfdata
.append(('last_backup_size', size
))
71 age_seconds
= int(time
.time()) - timestamp
72 seconds
= age_seconds
% 60
73 rem
= age_seconds
/ 60
75 hours
= (rem
% 1440) / 60
78 # 2. check age of last backup < 24h
80 warn
, crit
= None, None
81 if 'backup_age' in params
:
82 warn
, crit
= params
['backup_age']
83 if age_seconds
> params
['backup_age'][1]:
84 status
= max(status
, 2)
86 elif age_seconds
> params
['backup_age'][0]:
87 status
= max(status
, 1)
90 backup_time
= time
.strftime("%c", time
.localtime(timestamp
))
91 output
.append('Age: %s (%dd %02d:%02d:%02d)%s' % (backup_time
, days
, hours
, minutes
,
93 perfdata
.append(('last_backup_age', age_seconds
, warn
, crit
))
95 # 3. check total size of directory above configured threshold
97 warn
, crit
= None, None
98 if 'total_size' in params
:
99 warn
, crit
= params
['total_size']
100 if total_size
> params
['total_size'][1]:
101 status
= max(status
, 2)
103 elif total_size
> params
['total_size'][0]:
104 status
= max(status
, 1)
106 output
.append('Total Size: %s%s' % (get_bytes_human_readable(total_size
), status_txt
))
107 perfdata
.append(('total_size', total_size
))
109 return (status
, ', '.join(output
), perfdata
)
111 return (3, 'Domain not found')
114 check_info
['plesk_backups'] = {
115 'check_function': check_plesk_backups
,
116 'inventory_function': inventory_plesk_backups
,
117 'service_description': "Plesk Backup %s",
118 'has_perfdata': True,
119 'group': 'plesk_backups',