740ac1eb7b3362ad04b1c1d30cf7de69e39fe6ff
[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 any 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 Finally, you can track the current status of your machines using this Google Gadget:
40
41     http://fusion.google.com/add?source=atgs&moduleurl=http://%(hostname)s/monitor/sitemonitor.xml
42
43 Thank you for your help,
44   -- PlanetLab Central (%(support_email)s)
45 """
46
47         nodedown_two_subject="Server {HOSTNAME} is unreachable: Second Notice"
48         nodedown_two = """
49 Hello, 
50
51 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:
52
53     {HOSTNAME} : Since {EVENT.AGE}
54
55 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.
56
57 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.  
58
59 If the machine has booted successfully, you may check directly by logging in with your site_admin account, and running:
60
61     sudo /usr/sbin/vps ax                                                                                  
62 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:
63
64     https://www.planet-lab.org/doc/guides/bootcdsetup
65
66 If after following these directions, you are still experiencing problems, then you can acknowledge this notice by visiting, and letting us know what the problem is at mailto:%(support_email)s 
67
68     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
69     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
70
71 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.
72
73 Thank you for your help,
74   -- PlanetLab Central (%(support_email)s)
75
76
77 """
78
79         nodedown_three_subject="Server {HOSTNAME} is unreachable: Third Notice"
80         nodedown_three ="""
81 Hello,
82
83 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:
84
85     {HOSTNAME} : Since {EVENT.AGE}
86
87 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.  
88
89 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.
90
91 If the machine has booted successfully, you may check directly by logging in with your site_admin account, and running:
92
93     sudo /usr/sbin/vps ax
94
95 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:
96
97     https://www.planet-lab.org/doc/guides/bootcdsetup
98
99 If after following these directions, you are still experiencing problems, then you can acknowledge this notice by visiting, and letting us know what the problem is at mailto:%(support_email)s
100
101     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
102     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
103
104 Thank you for your help,
105     -- PlanetLab Central (%(support_email)s)
106 """
107         nodedown_four_subject="Server {HOSTNAME} is unreachable: Waiting Forever"
108         nodedown_four=""" 
109 Hello,
110
111 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:
112
113     {HOSTNAME} : Since {EVENT.AGE}
114
115 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.
116
117 You can acknowledge this notice by visiting the link below or by letting us know what the problem is by replying to this message.
118
119     http://%(hostname)s/zabbix/acknow.php?eventid={EVENT.ID}
120     http://%(hostname)s/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}
121
122 Thank you for your help,
123     -- PlanetLab Central (%(support_email)s)
124 """
125         node_discovered_subject = """Discovered {HOSTNAME} and online"""
126         node_discovered = """
127 Thank you for registering and installing this machine:
128
129     {HOSTNAME}
130
131 Our monitoring infrastructure has detected it, and in the future it will alert you in the event of unexpected downtime.
132
133         {TRIGGER.NAME}: {STATUS}
134 Thank you for your help,
135     -- PlanetLab Central (%(support_email)s)
136 """
137         thankyou_nodeup = """
138 While monitoring your site, we noticed that the following nodes *improved* their states:
139
140     {HOSTNAME} : Available
141
142 Often, system administration is a thankless job, but not today. :-)
143
144 Thank you!
145   -- PlanetLab Central (%(support_email)s)
146 """