6
6
7
7
8
8
class Health (Plugin ):
9
- AgentPluginType = 'sys'
10
9
11
- DEFAULT_CONFIG = {'max_memory_usage' : str (40 * 1024 * 1024 )}
10
+ AgentPluginType = "sys"
11
+
12
+ DEFAULT_CONFIG = {
13
+ "max_memory_usage" : str (40 * 1024 * 1024 )
14
+ }
12
15
13
16
counter = 0
14
17
15
18
def run (self , zbx ):
16
- zbx .send (' mamonsu.plugin.keepalive[]' , 0 )
19
+ zbx .send (" mamonsu.plugin.keepalive[]" , 0 )
17
20
if platform .LINUX :
18
21
usage = resource .getrusage (resource .RUSAGE_SELF ).ru_maxrss * 1024
19
- zbx .send (' mamonsu.memory.rss[max]' , usage )
22
+ zbx .send (" mamonsu.memory.rss[max]" , usage )
20
23
self .counter += 1
21
24
if self .counter > 9 :
22
- self .log .info (' === Keep alive ===' )
25
+ self .log .info (" === Keep alive ===" )
23
26
self .counter = 0
24
27
25
28
def items (self , template , dashboard = False ):
26
29
# see supervisor.py:
27
30
if self .Type == "mamonsu" :
28
31
result = template .item ({
29
- ' name' : ' Mamonsu: plugin errors' ,
30
- ' key' : ' mamonsu.plugin.errors[]' ,
31
- ' value_type' : Plugin .VALUE_TYPE .text # text
32
+ " name" : " Mamonsu: Plugin Errors" ,
33
+ " key" : " mamonsu.plugin.errors[]" ,
34
+ " value_type" : Plugin .VALUE_TYPE .text # text
32
35
}) + template .item ({
33
- ' name' : ' Mamonsu: plugin keep alive' ,
34
- ' key' : self .right_type ("mamonsu.plugin.keepalive{0}" )
36
+ " name" : " Mamonsu: Plugin Keep Alive" ,
37
+ " key" : self .right_type ("mamonsu.plugin.keepalive{0}" )
35
38
})
36
39
if platform .LINUX :
37
40
result += template .item ({
38
- ' name' : ' Mamonsu: rss memory max usage' ,
39
- ' key' : ' mamonsu.memory.rss[max]' ,
40
- ' units' : Plugin .UNITS .bytes
41
+ " name" : " Mamonsu: RSS Memory Max Usage" ,
42
+ " key" : " mamonsu.memory.rss[max]" ,
43
+ " units" : Plugin .UNITS .bytes
41
44
})
42
45
else :
43
46
result = template .item ({
44
- ' name' : ' Mamonsu: plugin keep alive' ,
45
- ' key' : self .right_type ("mamonsu.plugin.keepalive{0}" )
47
+ " name" : " Mamonsu: Plugin Keep Alive" ,
48
+ " key" : self .right_type ("mamonsu.plugin.keepalive{0}" )
46
49
})
47
50
if not dashboard :
48
51
return result
@@ -52,31 +55,25 @@ def items(self, template, dashboard=False):
52
55
def triggers (self , template , dashboard = False ):
53
56
if self .Type == "mamonsu" :
54
57
result = template .trigger ({
55
- 'name' : 'Mamonsu plugin errors '
56
- 'on {HOSTNAME}. {ITEM.LASTVALUE}' ,
57
- 'expression' : '{#TEMPLATE:mamonsu.plugin.errors[].strlen()'
58
- '}>1'
58
+ "name" : "Mamonsu plugin errors on {HOSTNAME}. {ITEM.LASTVALUE}" ,
59
+ "expression" : "{#TEMPLATE:mamonsu.plugin.errors[].strlen()}>1"
59
60
}) + template .trigger ({
60
- 'name' : 'Mamonsu nodata from {HOSTNAME}' ,
61
- 'expression' : '{#TEMPLATE:' + self .right_type ("mamonsu.plugin.keepalive{0}" ) +
62
- '.nodata(180)}=1'
61
+ "name" : "Mamonsu nodata from {HOSTNAME}" ,
62
+ "expression" : "{#TEMPLATE:" + self .right_type ("mamonsu.plugin.keepalive{0}" ) + ".nodata(180)}=1"
63
63
})
64
64
if platform .LINUX :
65
65
result += template .trigger ({
66
- 'name' : 'Mamonsu agent memory usage alert '
67
- 'on {HOSTNAME}: {ITEM.LASTVALUE} bytes' ,
68
- 'expression' : '{#TEMPLATE:mamonsu.memory.rss[max].last()}'
69
- '>' + self .plugin_config ('max_memory_usage' )
66
+ "name" : "Mamonsu agent memory usage alert on {HOSTNAME}: {ITEM.LASTVALUE} bytes" ,
67
+ "expression" : "{#TEMPLATE:mamonsu.memory.rss[max].last()}>" + self .plugin_config (
68
+ "max_memory_usage" )
70
69
})
71
70
else :
72
71
result = template .trigger ({
73
- 'name' : 'Mamonsu nodata from {HOSTNAME}' ,
74
- 'expression' : '{#TEMPLATE:' + self .right_type ("mamonsu.plugin.keepalive{0}" ) +
75
- '.nodata(180)}=1'
72
+ "name" : "Mamonsu nodata from {HOSTNAME}" ,
73
+ "expression" : "{#TEMPLATE:" + self .right_type ("mamonsu.plugin.keepalive{0}" ) + ".nodata(180)}=1"
76
74
})
77
75
return result
78
76
79
77
def keys_and_queries (self , template_zabbix ):
80
- result = [' {0},{1}' .format ("mamonsu.plugin.keepalive" , "echo 0" )]
78
+ result = [" {0},{1}" .format ("mamonsu.plugin.keepalive" , "echo 0" )]
81
79
return template_zabbix.key_and_query (result )
82
-
0 commit comments