better email message
[monitor.git] / monitor / database / zabbixapi / emailZabbix.py
1 class mailtxt:
2         @classmethod
3         def reformat(cls, arguments={'hostname' : "your.host.name", 
4                                                                  'support_email' : 'support@your.host.name'}):
5                 fields = dir(cls)
6                 for f in fields:
7                         #print "looking at %s" % f
8                         if "__" not in f and 'reformat' not in f:
9                                 attr = getattr(cls,f)
10                                 #print attr
11                                 setattr(cls, f, attr % arguments)
12                                 #print getattr(cls,f)
13                 return
14
15         # NOTE: using the literal --> ' <-- character in messages will cause the db or zabbix_server to fail.
16
17         nodedown_one_subject="Server {HOSTNAME} is unreachable: First Notice"
18         nodedown_one = """
19 Hello,
20
21 We hope that you are having a good day.  As part of PlanetLab node monitoring, we noticed the following node is down at your site:
22
23     {HOSTNAME} : Since {EVENT.AGE}
24
25 We are writing because we need your help returning them to their regular operation.
26
27 To help, please confirm that a verison 3.0 or greater BootCD is installed in the machine.  Then, after checking that the node is properly networked, power cycle the machine.  Note that rebooting the machine may not fully resolve the problems we are seeing.  Once the machine has come back up, please visit the monitor status page to verify that your node is accessible.  
28
29 If the machine has booted successfully, you may check directly by logging in with your site_admin account, and running:
30
31     sudo /usr/sbin/vps ax
32
33 If you have a BootCD older than 3.0, you will need to create a new BootImage on CD or USB.  You can find instructions for this at the Technical Contacts Guide:
34
35     https://www.planet-lab.org/doc/guides/bootcdsetup
36
37 There is no need to respond to this message unless there are console messages relating to the node failure.  In this case, please report them to PlanetLab support (%(support_email)s) so we can help resolve the issue.   Including this message in your reply will help us coordinate our records with the actions you have taken.
38
39 If after following these directions, you are still experiencing problems, then you can acknowledge this notice by visiting the links below and describing the problem:
40
41     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
42     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
43
44 Thank you for your help,
45   -- PlanetLab Central (%(support_email)s)
46 """
47
48         nodedown_two_subject="Server {HOSTNAME} is unreachable: Second Notice"
49         nodedown_two = """
50 Hello, 
51
52 We hope that you are having a good day.  As part of PlanetLab node monitoring, we noticed the following node is down at your site:
53
54     {HOSTNAME} : Since {EVENT.AGE}
55
56 We are writing again because our previous correspondence, sent only to the registered Technical Contact, has gone unacknowledged for at least a week, and we need your help returning these machines to their regular operation.  We understand that machine maintenance can take time.  So, while we wait for the machines to return to their regular operation slice creation has been suspended at your site.  No new slices may be created, but the existing slices and services running within them will be unaffected.
57
58 To help, please confirm that a verison 3.0 or greater BootCD is installed in the machine.  Then, after checking that the node is properly networked, power cycle the machine.  Note that rebooting the machine may not fully resolve the problems we are seeing.  Once the machine has come back up, please visit the monitor status page to verify that your node is accessible.  
59
60 If the machine has booted successfully, you may check directly by logging in with your site_admin account, and running:
61
62     sudo /usr/sbin/vps ax                                                                                  
63 If you have a BootCD older than 3.0, you will need to create a new BootImage on CD or USB.  You can find instructions for this at the Technical Contacts Guide:
64
65     https://www.planet-lab.org/doc/guides/bootcdsetup
66
67 If after following these directions, you are still experiencing problems, then you can acknowledge this notice by visiting the links below and describing the problem:
68
69     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
70     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
71
72 After another week, we will disable all slices currently running on PlanetLab.  Because this action will directly affect all users of these slices, these users will also be notified at that time.
73
74 Thank you for your help,
75   -- PlanetLab Central (%(support_email)s)
76
77
78 """
79
80         nodedown_three_subject="Server {HOSTNAME} is unreachable: Third Notice"
81         nodedown_three ="""
82 Hello,
83
84 We hope that you are having a good day.  As part of PlanetLab node monitoring, we noticed the following node is down at your site:
85
86     {HOSTNAME} : Since {EVENT.AGE}
87
88 We understand that machine maintenance can take time.  We are writing again because our previous correspondences, sent first to the registered Technical Contact then the the Site PI, have gone unacknowledged for at least two weeks, and we need your help returning these machines to their regular operation.  This is the third time attempting to contact someone in regard to these machines at your site.  So, while we wait for the machines to return to their regular operation all current slice activity will be suspended.  Current experiments will be stopped and will not be be able to start again until there is evidence that you have begun to help with the maintenance of these machines.  
89
90 To help, please confirm that a verison 3.0 or greater BootCD is installed in the machine.  Then, after checking that the node is properly networked, power cycle the machine.  Note that rebooting the machine may not fully resolve the problems we are seeing.  Once the machine has come back up, please visit the monitor status page to verify that your node is accessible.
91
92 If the machine has booted successfully, you may check directly by logging in with your site_admin account, and running:
93
94     sudo /usr/sbin/vps ax
95
96 If you have a BootCD older than 3.0, you will need to create a new BootImage on CD or USB.  You can find instructions for this at the Technical Contacts Guide:
97
98     https://www.planet-lab.org/doc/guides/bootcdsetup
99
100 If after following these directions, you are still experiencing problems, then you can acknowledge this notice by visiting the links below and describing the problem:
101
102     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
103     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
104
105 Thank you for your help,
106     -- PlanetLab Central (%(support_email)s)
107 """
108         nodedown_four_subject="Server {HOSTNAME} is unreachable: Waiting Forever"
109         nodedown_four=""" 
110 Hello,
111
112 We hope that you are having a good day.  As part of PlanetLab node monitoring, we noticed the following node is down at your site:
113
114     {HOSTNAME} : Since {EVENT.AGE}
115
116 We have not heard a response from you regarding this machine.  We will continue sending message until we receive an acknowledgment and description of the issue prevening the node from remaining online.
117
118 You can acknowledge this notice by visiting the link below or by letting us know what the problem is by replying to this message.
119
120     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
121     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
122
123 Thank you for your help,
124     -- PlanetLab Central (%(support_email)s)
125 """
126         node_discovered_subject = """Discovered a new host!"""
127         node_discovered = """
128 Thank you for registering and installing this machine:
129
130     hostname {HOSTNAME} : ip {IPADDRESS}
131
132 Our monitoring infrastructure has detected it, and in the future it will alert you in the event of unexpected downtime.
133
134         Discovered : Online
135         {TRIGGER.URL}
136
137 Thank you for your help,
138     -- PlanetLab Central (%(support_email)s)
139 """
140         thankyou_nodeup = """
141 While monitoring your site, we noticed that the following nodes *improved* their states:
142
143     {HOSTNAME} : Available
144
145 Often, system administration is a thankless job, but not today. :-)
146
147 Thank you!
148   -- PlanetLab Central (%(support_email)s)
149 """