Projet

Général

Profil

Révision 15e41f87

ID15e41f87f6d68711b0a4577415f5981822134b51
Parent 4b836355
Enfant dac093c3

Ajouté par Josh Robb il y a environ 13 ans

Add a plugin for monitoring senderscore repuation.

Voir les différences:

plugins/senderscore/senderscore
1
#!/usr/bin/python
2
 
3
import socket
4
import sys
5
import os
6

  
7
def get_senderscores(ip):
8
    tmp = ip.split(".")
9
    backwards = "%s.%s.%s.%s" % (tmp[3], tmp[2], tmp[1], tmp[0])
10
    # replists = ['cmplt.rating.senderscore.com', 'score.senderscore.com', 'uus.rating.senderscore.com', 'vol.rating.senderscore.com', 'filtered.rating.senderscore.com']
11
    replists = ['score.senderscore.com']
12
    lookup_results = {}
13
    for rl in replists:
14
            try:
15
                    host = '%s.%s' % (backwards, rl)
16
                    ret = socket.gethostbyname(host)
17
                    if ret:
18
                            lookup_results[rl] = ret
19
            except Exception, e:
20
                    print >> sys.stderr,e
21
                    # sys.exit(1)
22
    scores = {}
23
    for k in lookup_results.keys():
24
        v = lookup_results[k].split('.')[3]
25
        k = k.split(".")[0]
26
        scores[k] = v
27
    return scores
28

  
29
def print_stats(ip):
30
    scores = get_senderscores(ip)
31
    for key in scores.keys():
32
        print key+".value "  +scores[key]
33

  
34
def print_config():
35
    print """
36
graph_title senderscore reputation
37
graph_info This graph shows senderscore.org reputation metrics
38
graphs_args --upper-limit 100 -u 100 -l 0
39
graph_category senderscore
40
graph_vlabel score
41
graph_scale no
42

  
43
score.label sender score
44
score.info score represents the overall health of your email programs as they appear to receiving systems.
45
score.warning 95:
46
score.critical 90:
47
"""
48

  
49
unused = """cmplt.label complaints
50
cmplt.infocomplaint scores are a rank based on your complaint rates.
51
cmplt.warning 95
52
cmplt.critical 90
53

  
54
uus.label unknown users
55
uus.info ratio of unknown users, or invalid email addresses, compared to the amount of email seen by our receiving sources
56

  
57
vol.label volume
58
vol.info rank of ip address by volume of email monitored
59

  
60
filtered.label filtered
61
filtered.info how often messages are rejected (bounced due to some policy reason, usually spam filtering or blacklisting) compared to other IP addresses seen in the Sender Score Reputation Network
62
filtered.warning 95
63
filtered.critical 90
64
"""
65

  
66
if __name__ == "__main__":
67
    if os.environ['senderscore_check_ip'] == '':
68
        print "env.senderscore_check_ip not defined in munin config"
69
        sys.exit(1)
70
     
71
    ip = os.environ['senderscore_check_ip']
72

  
73
    if len(sys.argv) > 1 and sys.argv[1] != '':
74
        if sys.argv[1] == 'config':
75
            print_config()
76
        else:
77
            print "Command %s not recognized" % sys.argv[1]
78
            sys.exit(1)
79
    else:
80
        print_stats(ip)

Formats disponibles : Unified diff