]> arthur.barton.de Git - netdata.git/blob - plugins.d/alarm-notify.sh
jump to alarm chart and open alarms modal when clicking on an alarm URL
[netdata.git] / plugins.d / alarm-notify.sh
1 #!/usr/bin/env bash
2
3 # (C) Costa Tsaousis
4 # pushover support by Jan Arnold
5
6 me="${0}"
7
8 # -----------------------------------------------------------------------------
9 # parse command line parameters
10
11 recipient="${1}"   # the recepient of the email
12 hostname="${2}"    # the hostname this event refers to
13 unique_id="${3}"   # the unique id of this event
14 alarm_id="${4}"    # the unique id of the alarm that generated this event
15 event_id="${5}"    # the incremental id of the event, for this alarm
16 when="${6}"        # the timestamp this event occured
17 name="${7}"        # the name of the alarm, as given in netdata health.d entries
18 chart="${8}"       # the name of the chart (type.id)
19 family="${9}"      # the family of the chart
20 status="${10}"     # the current status : UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
21 old_status="${11}" # the previous status: UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
22 value="${12}"      # the current value
23 old_value="${13}"  # the previous value
24 src="${14}"        # the line number and file the alarm has been configured
25 duration="${15}"   # the duration in seconds the previous state took
26 non_clear_duration="${16}" # the total duration in seconds this is non-clear
27 units="${17}"      # the units of the value
28 info="${18}"       # a short description of the alarm
29
30 # -----------------------------------------------------------------------------
31 # screen statuses we don't need to send a notification
32
33 # don't do anything if this is not WARNING, CRITICAL or CLEAR
34 if [ "${status}" != "WARNING" -a "${status}" != "CRITICAL" -a "${status}" != "CLEAR" ]
35 then
36     echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}'"
37     exit 1
38 fi
39
40 # don't do anything if this is CLEAR, but it was not WARNING or CRITICAL
41 if [ "${old_status}" != "WARNING" -a "${old_status}" != "CRITICAL" -a "${status}" = "CLEAR" ]
42 then
43     echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}' (last status was ${old_status})"
44     exit 1
45 fi
46
47 # -----------------------------------------------------------------------------
48 # load configuration
49
50 # needed commands
51 # if empty they will be searched in the system path
52 curl=
53 sendmail=
54
55 # enable / disable features
56 SEND_SLACK="YES"
57 SEND_PUSHOVER="YES"
58 SEND_EMAIL="YES"
59
60 # slack configs
61 SLACK_WEBHOOK_URL=
62 DEFAULT_RECIPIENT_SLACK=
63 declare -A role_recipients_slack=()
64
65 # pushover configs
66 PUSHOVER_APP_TOKEN=
67 DEFAULT_RECIPIENT_PUSHOVER=
68 declare -A role_recipients_pushover=()
69
70 # email configs
71 DEFAULT_RECIPIENT_EMAIL="root"
72 declare -A role_recipients_email=()
73
74 # load the user configuration
75 # this will overwrite the variables above
76 if [ -f "${NETDATA_CONFIG_DIR}/health_alarm_notify.conf" ]
77     then
78     source "${NETDATA_CONFIG_DIR}/health_alarm_notify.conf"
79 fi
80
81 # -----------------------------------------------------------------------------
82 # find the exact recipient per method
83
84 declare -A arr_slack=()
85 declare -A arr_pushover=()
86 declare -A arr_email=()
87
88 # netdata may call us with multiple recipients
89 # so, here we find the unique ones
90 for x in ${recipient}
91 do
92     # email
93     a="${role_recipients_email[${recipient}]}"
94     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_EMAIL}"
95     for r in ${a//,/ }; do arr_email[${r}]="1"; done
96
97     # pushover
98     a="${role_recipients_pushover[${recipient}]}"
99     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_PUSHOVER}"
100     for r in ${a//,/ }; do arr_pushover[${r}]="1"; done
101
102     # slack
103     a="${role_recipients_slack[${recipient}]}"
104     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_SLACK}"
105     for r in ${a//,/ }; do arr_slack[${r}]="1"; done
106 done
107
108 # build the list of slack recipients (channels)
109 to_slack="${!arr_slack[*]}"
110 [ -z "${to_slack}" ] && SEND_SLACK="NO"
111
112 # build the list of pushover recipients (user tokens)
113 to_pushover="${!arr_pushover[*]}"
114 [ -z "${to_pushover}" ] && SEND_PUSHOVER="NO"
115
116 # build the list of email recipients (email addresses)
117 to_email=
118 for x in "${!arr_email[*]}"
119 do
120     [ ! -z "${to_email}" ] && to_email="${to_email}, "
121     to_email="${to_email}${x}"
122 done
123 [ -z "${to_email}" ] && to_email="root"
124
125
126 # -----------------------------------------------------------------------------
127 # verify the delivery methods supported
128
129 # check slack
130 [ -z "${SLACK_WEBHOOK_URL}" ] && SEND_SLACK="NO"
131
132 # check pushover
133 [ -z "${PUSHOVER_APP_TOKEN}" ] && SEND_PUSHOVER="NO"
134
135 if [ \( "${SEND_PUSHOVER}" = "YES" -o "${SEND_SLACK}" = "YES" \) -a -z "${curl}" ]
136     then
137     curl="$(which curl 2>/dev/null || command -v curl 2>/dev/null)"
138     if [ -z "${curl}" ]
139         then
140         SEND_PUSHOVER="NO"
141         SEND_SLACK="NO"
142     fi
143 fi
144
145 if [ "${SEND_EMAIL}" = "YES" -a -z "${sendmail}" ]
146     then
147     sendmail="$(which sendmail 2>/dev/null || command -v sendmail 2>/dev/null)"
148     [ -z "${sendmail}" ] && SEND_EMAIL="NO"
149 fi
150
151 # check that we have at least a method enabled
152 if [ "${SEND_EMAIL}" != "YES" -a "${SEND_PUSHOVER}" != "YES" -a "${SEND_SLACK}" != "YES" ]
153     then
154     echo >&2 "I don't have a means to send a notification. Sorry!"
155     exit 1
156 fi
157
158 # -----------------------------------------------------------------------------
159 # get the system hostname
160
161 [ -z "${hostname}" ] && hostname="${NETDATA_HOSTNAME}"
162 [ -z "${hostname}" ] && hostname="${NETDATA_REGISTRY_HOSTNAME}"
163 [ -z "${hostname}" ] && hostname="$(hostname 2>/dev/null)"
164
165 # -----------------------------------------------------------------------------
166 # get the date the alarm happened
167
168 date="$(date --date=@${when} 2>/dev/null)"
169 [ -z "${date}" ] && date="$(date 2>/dev/null)"
170
171 # -----------------------------------------------------------------------------
172 # URL encode a string
173
174 urlencode() {
175     local string="${1}" strlen encoded pos c o
176
177     strlen=${#string}
178     for (( pos=0 ; pos<strlen ; pos++ ))
179     do
180         c=${string:$pos:1}
181         case "$c" in
182             [-_.~a-zA-Z0-9])
183                 o="${c}"
184                 ;;
185
186             *)
187                 printf -v o '%%%02x' "'$c"
188                 ;;
189         esac
190         encoded+="${o}"
191     done
192     echo "${encoded}"
193 }
194
195 # -----------------------------------------------------------------------------
196 # convert a duration in seconds, to a human readable duration
197 # using DAYS, MINUTES, SECONDS
198
199 duration4human() {
200     local s="${1}" d=0 h=0 m=0 ds="day" hs="hour" ms="minute" ss="second"
201     d=$(( s / 86400 ))
202     s=$(( s - (d * 86400) ))
203     h=$(( s / 3600 ))
204     s=$(( s - (h * 3600) ))
205     m=$(( s / 60 ))
206     s=$(( s - (m * 60) ))
207
208     if [ ${d} -gt 0 ]
209     then
210         [ ${m} -ge 30 ] && h=$(( h + 1 ))
211         [ ${d} -gt 1 ] && ds="days"
212         [ ${h} -gt 1 ] && hs="hours"
213         if [ ${h} -gt 0 ]
214         then
215             echo "${d} ${ds} and ${h} ${hs}"
216         else
217             echo "${d} ${ds}"
218         fi
219     elif [ ${h} -gt 0 ]
220     then
221         [ ${s} -ge 30 ] && m=$(( m + 1 ))
222         [ ${h} -gt 1 ] && hs="hours"
223         [ ${m} -gt 1 ] && ms="minutes"
224         if [ ${m} -gt 0 ]
225         then
226             echo "${h} ${hs} and ${m} ${ms}"
227         else
228             echo "${h} ${hs}"
229         fi
230     elif [ ${m} -gt 0 ]
231     then
232         [ ${m} -gt 1 ] && ms="minutes"
233         [ ${s} -gt 1 ] && ss="seconds"
234         if [ ${s} -gt 0 ]
235         then
236             echo "${m} ${ms} and ${s} ${ss}"
237         else
238             echo "${m} ${ms}"
239         fi
240     else
241         [ ${s} -gt 1 ] && ss="seconds"
242         echo "${s} ${ss}"
243     fi
244 }
245
246 # -----------------------------------------------------------------------------
247 # email sender
248
249 send_email() {
250     if [ "${SEND_EMAIL}" = "YES" ]
251         then
252
253         "${sendmail}" -t
254
255         if [ $? -eq 0 ]
256         then
257             echo >&2 "${me}: Sent notification email for ${status} on '${chart}.${name}' to '${to_email}'"
258             return 0
259         else
260             echo >&2 "${me}: FAILED to send notification email for ${status} on '${chart}.${name}' to '${to_email}'"
261             return 1
262         fi
263     fi
264
265     return 1
266 }
267
268 # -----------------------------------------------------------------------------
269 # pushover sender
270
271 send_pushover() {
272     local apptoken="${1}" usertokens="${2}" when="${3}" url="${4}" status="${5}" title="${6}" message="${7}" httpcode sent=0 user priority
273
274     if [ "${SEND_PUSHOVER}" = "YES" -a ! -z "${apptoken}" -a ! -z "${usertokens}" -a ! -z "${title}" -a ! -z "${message}" ]
275         then
276
277         priority=0
278         [ "${status}" = "CRITICAL" ] && priority=1
279
280         for user in ${usertokens}
281         do
282             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
283                 --form-string "token=${apptoken}" \
284                 --form-string "user=${user}" \
285                 --form-string "html=1" \
286                 --form-string "title=${title}" \
287                 --form-string "message=${message}" \
288                 --form-string "timestamp=${when}" \
289                 --form-string "url=${url}" \
290                 --form-string "url_title=Open netdata dashboard to view the alarm" \
291                 --form-string "priority=${priority}" \
292                 https://api.pushover.net/1/messages.json)
293
294             if [ "${httpcode}" == "200" ]
295             then
296                 echo >&2 "${me}: Sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
297                 sent=$((sent + 1))
298             else
299                 echo >&2 "${me}: Failed to send pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP error code ${httpcode}."
300             fi
301         done
302
303         [ ${sent} -gt 0 ] && return 0
304     fi
305
306     return 1
307 }
308
309 # -----------------------------------------------------------------------------
310 # slack sender
311
312 send_slack() {
313     local webhook="${1}" channels="${2}" when="${3}" username="${4}" image="${5}" author="${6}" httpcode sent=0 channel color
314
315     if [ "${SEND_SLACK}" = "YES" -a ! -z "${webhook}" -a ! -z "${channels}" -a ! -z "${username}" -a ! -z "${image}" -a ! -z "${author}" ]
316         then
317
318         case "${status}" in
319             WARNING) color="warning" ;;
320             CRITICAL) color="danger" ;;
321             CLEAR) color="good" ;;
322             *) color="#777777" ;;
323         esac
324
325         for channel in ${channels}
326         do
327             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode \
328                 "payload={\"channel\": \"#${channel}\", \"username\": \"${username}\", \"text\": \"${hostname} ${status_message} - ${author} ${raised_for} - click <${goto_url}|here> to view the netdata dashboard.\", \"icon_url\": \"${image}\", \"attachments\": [{\"fallback\": \"${alarm} - ${info}\", \"color\": \"${color}\", \"title\": \"${alarm}\", \"title_link\": \"${goto_url}\", \"text\": \"${info}\", \"footer\": \"netdata\", \"footer_icon\": \"${NETDATA_REGISTRY_URL}/images/seo-performance-128.png\", \"ts\": ${when}}]}" \
329                 "${webhook}")
330
331             if [ "${httpcode}" == "200" ]
332             then
333                 echo >&2 "${me}: Sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
334                 sent=$((sent + 1))
335             else
336                 echo >&2 "${me}: Failed to send slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
337             fi
338         done
339
340         [ ${sent} -gt 0 ] && return 0
341     fi
342
343     return 1
344 }
345
346
347 # -----------------------------------------------------------------------------
348 # prepare the content of the notification
349
350 # the url to send the user on click
351 goto_url="${NETDATA_REGISTRY_URL}/goto-host-from-alarm.html?host=$(urlencode "${NETDATA_REGISTRY_HOSTNAME}")&chart=${chart}&family=${family}"
352
353 # the severity of the alarm
354 severity="${status}"
355
356 # the time the alarm was raised
357 raised_for="(was ${old_status,,} for $(duration4human ${duration}))"
358
359 # the key status message
360 status_message="status unknown"
361
362 # the color of the alarm
363 color="grey"
364
365 # the alarm value
366 alarm="${name//_/ } = ${value} ${units}"
367
368 # the image of the alarm
369 image="${NETDATA_REGISTRY_URL}/images/seo-performance-128.png"
370
371 # prepare the title based on status
372 case "${status}" in
373         CRITICAL)
374         image="${NETDATA_REGISTRY_URL}/images/alert-128-red.png"
375         status_message="is critical"
376         color="#ca414b"
377         ;;
378
379     WARNING)
380         image="${NETDATA_REGISTRY_URL}/images/alert-128-orange.png"
381         status_message="needs attention"
382         color="#caca4b"
383                 ;;
384
385         CLEAR)
386         image="${NETDATA_REGISTRY_URL}/images/check-mark-2-128-green.png"
387         status_message="recovered"
388                 color="#77ca6d"
389
390                 # don't show the value when the status is CLEAR
391                 # for certain alarms, this value might not have any meaning
392                 alarm="${name//_/ }"
393                 ;;
394 esac
395
396 if [ "${status}" = "CLEAR" ]
397 then
398     severity="Recovered from ${old_status}"
399     if [ $non_clear_duration -gt $duration ]
400     then
401         raised_for="(had issues for $(duration4human ${non_clear_duration}))"
402     fi
403
404 elif [ "${old_status}" = "WARNING" -a "${status}" = "CRITICAL" ]
405 then
406     severity="Escalated to ${status}"
407     if [ $non_clear_duration -gt $duration ]
408     then
409         raised_for="(has issues for $(duration4human ${non_clear_duration}))"
410     fi
411
412 elif [ "${old_status}" = "CRITICAL" -a "${status}" = "WARNING" ]
413 then
414     severity="Demoted to ${status}"
415     if [ $non_clear_duration -gt $duration ]
416     then
417         raised_for="(has issues for $(duration4human ${non_clear_duration}))"
418     fi
419
420 else
421     raised_for=
422 fi
423
424 # prepare HTML versions of elements
425 info_html=
426 [ ! -z "${info}" ] && info_html=" <small><br/>${info}</small>"
427
428 raised_for_html=
429 [ ! -z "${raised_for}" ] && raised_for_html="<br/><small>${raised_for}</small>"
430
431 # -----------------------------------------------------------------------------
432 # send the slack notification
433
434 # slack aggregates posts from the same username
435 # so we use "${hostname} ${status}" as the bot username, to make them diff
436
437 send_slack "${SLACK_WEBHOOK_URL}" "${to_slack}" "${when}" "${hostname} ${status}" "${image}" "${chart} (${family})"
438 SENT_SLACK=$?
439
440 # -----------------------------------------------------------------------------
441 # send the pushover notification
442
443 send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${hostname} ${status_message} - ${name//_/ } - ${chart}" "
444 <font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>&nbsp;
445 <small><b>${chart}</b><br/>Chart<br/>&nbsp;</small>
446 <small><b>${family}</b><br/>Family<br/>&nbsp;</small>
447 <small><b>${severity}</b><br/>Severity<br/>&nbsp;</small>
448 <small><b>${date}${raised_for_html}</b><br/>Time<br/>&nbsp;</small>
449 <a href=\"${goto_url}\">View Netdata</a><br/>&nbsp;
450 <small><small>The source of this alarm is line ${src}</small></small>
451 "
452
453 SENT_PUSHOVER=$?
454
455 # -----------------------------------------------------------------------------
456 # send the email
457
458 send_email <<EOF
459 To: ${to_email}
460 Subject: ${hostname} ${status_message} - ${name//_/ } - ${chart}
461 Content-Type: text/html
462
463 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
464 <html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0; padding: 0;">
465 <body style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; width: 100% !important; min-height: 100%; line-height: 1.6; background: #f6f6f6; margin:0; padding: 0;">
466 <table>
467     <tbody>
468     <tr>
469         <td style="vertical-align: top;" valign="top"></td>
470         <td width="700" style="vertical-align: top; display: block !important; max-width: 700px !important; clear: both !important; margin: 0 auto; padding: 0;" valign="top">
471             <div style="max-width: 700px; display: block; margin: 0 auto; padding: 20px;">
472                 <table width="100%" cellpadding="0" cellspacing="0" style="background: #fff; border: 1px solid #e9e9e9;">
473                     <tbody>
474                     <tr>
475                         <td bgcolor="#eee" style="padding: 5px 20px 5px 20px; background-color: #eee;">
476                             <div style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 20px; color: #777; font-weight: bold;">netdata notification</div>
477                         </td>
478                     </tr>
479                     <tr>
480                         <td bgcolor="${color}" style="font-size: 16px; vertical-align: top; font-weight: 400; text-align: center; margin: 0; padding: 10px; color: #ffffff; background: ${color} !important; border: 1px solid ${color}; border-top-color: ${color};" align="center" valign="top">
481                             <h1 style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: 400; margin: 0;">${hostname} ${status_message}</h1>
482                         </td>
483                     </tr>
484                     <tr>
485                         <td style="vertical-align: top;" valign="top">
486                             <div style="margin: 0; padding: 20px; max-width: 700px;">
487                                 <table width="100%" cellpadding="0" cellspacing="0" style="max-width:700px">
488                                     <tbody>
489                                     <tr>
490                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding:0 0 20px;" align="left" valign="top">
491                                             <span>${chart}</span>
492                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Chart</span>
493                                         </td>
494                                     </tr>
495                                     <tr style="margin: 0; padding: 0;">
496                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
497                                             <span><b>${alarm}</b>${info_html}</span>
498                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Alarm</span>
499                                         </td>
500                                     </tr>
501                                     <tr>
502                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
503                                             <span>${family}</span>
504                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Family</span>
505                                         </td>
506                                     </tr>
507                                     <tr style="margin: 0; padding: 0;">
508                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
509                                             <span>${severity}</span>
510                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Severity</span>
511                                         </td>
512                                     </tr>
513                                     <tr style="margin: 0; padding: 0;">
514                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top"><span>${date}</span>
515                                             <span>${raised_for_html}</span> <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Time</span>
516                                         </td>
517                                     </tr>
518                                     <tr style="margin: 0; padding: 0;">
519                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;">
520                                             <a href="${goto_url}" style="font-size: 14px; color: #ffffff; text-decoration: none; line-height: 1.5; font-weight: bold; text-align: center; display: inline-block; text-transform: capitalize; background: #35568d; border-width: 1px; border-style: solid; border-color: #2b4c86; margin: 0; padding: 10px 15px;" target="_blank">View Netdata</a>
521                                         </td>
522                                     </tr>
523                                     <tr style="text-align: center; margin: 0; padding: 0;">
524                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 11px; vertical-align: top; margin: 0; padding: 10px 0 0 0; color: #666666;" align="center" valign="bottom">The source of this alarm is line <code>${src}</code>
525                                         </td>
526                                     </tr>
527                                     <tr style="text-align: center; margin: 0; padding: 0;">
528                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 12px; vertical-align: top; margin:0; padding: 20px 0 0 0; color: #666666; border-top: 1px solid #f0f0f0;" align="center" valign="bottom">Sent by
529                                             <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance monitoring.
530                                         </td>
531                                     </tr>
532                                     </tbody>
533                                 </table>
534                             </div>
535                         </td>
536                     </tr>
537                     </tbody>
538                 </table>
539             </div>
540         </td>
541     </tr>
542     </tbody>
543 </table>
544 </body>
545 </html>
546 EOF
547
548 SENT_EMAIL=$?
549
550 # -----------------------------------------------------------------------------
551 # let netdata know
552
553 # we did send somehting
554 [ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_SLACK} -eq 0 ] && exit 0
555
556 # we did not send anything
557 exit 1