[% USE date %]

[% SET message = n.message.substr(13) %]
[% options = message.split(';') %]
[% state_color = 'grey' %]
[% IF n.type == 'SERVICE NOTIFICATION' %]
    [% SET level = options.3 %]
    [%    IF level == 'OK'              %][% level = 'OK'        statusclass = 'notificationsOK' state_color = 'green' %]
    [% ELSIF level == 'RECOVERY'        %][% level = 'OK'        statusclass = 'notificationsOK' state_color = 'green' %]
    [% ELSIF level == 'WARNING'         %][% level = 'WARNING'   statusclass = 'notificationsWARNING' state_color = 'yellow' %]
    [% ELSIF level == 'CRITICAL'        %][% level = 'CRITICAL'  statusclass = 'notificationsCRITICAL' state_color = 'red' %]
    [% ELSIF level.match('CUSTOM\ \(') %][%                      statusclass = 'notificationsCUSTOM' %]
    [% ELSIF level.match('ACKNOWLEDGEMENT\ \(') %][%             statusclass = 'notificationsACKNOWLEDGEMENT' %]
    [% ELSIF level.match('FLAPPINGSTART\ \(')   %][% level = 'FLAPPING START' statusclass = 'notificationsUNKNOWN' %]
    [% ELSIF level.match('FLAPPINGSTOP\ \(')    %][% level = 'FLAPPING STOP'  statusclass = 'notificationsUNKNOWN' %]
    [% ELSE                                      %][%   statusclass = 'notificationsUNKNOWN' %]
    [% END %]
[% ELSE %]
    [% SET level = options.2 %]
    [%    IF level == 'UP'          %][% level = 'HOST UP'          statusclass = 'notificationsHOSTUP' state_color = 'green' %]
    [% ELSIF level == 'RECOVERY'    %][% level = 'HOST UP'          statusclass = 'notificationsHOSTUP' state_color = 'green' %]
    [% ELSIF level == 'DOWN'        %][% level = 'HOST DOWN'        statusclass = 'notificationsHOSTDOWN' state_color = 'red' %]
    [% ELSIF level == 'UNREACHABLE' %][% level = 'HOST UNREACHABLE' statusclass = 'notificationsHOSTUNREACHABLE' state_color = 'red' %]
    [% ELSIF level.match('CUSTOM\ \(') %][%                        statusclass = 'notificationsHOSTCUSTOM' %]
    [% ELSIF level.match('ACKNOWLEDGEMENT\ \(') %][%               statusclass = 'notificationsHOSTACKNOWLEDGEMENT' %]
    [% ELSIF level.match('FLAPPINGSTART\ \(')   %][% level = 'FLAPPING START' statusclass = 'notificationsUNKNOWN' %]
    [% ELSIF level.match('FLAPPINGSTOP\ \(')    %][% level = 'FLAPPING STOP'  statusclass = 'notificationsUNKNOWN' %]
    [% ELSE                                      %][%    statusclass = 'notificationsUNKNOWN' %]
    [% END %]
[% END %]
