<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send_event( name, runbook, status, output, team, page=False, tip=None, notification_email=None, check_every='30s', realert_every=-1, alert_after='0s', dependencies=[], irc_channels=None, slack_channels=None, ticket=False, project=None, priority=None, source=None, tags=[], ttl=None, sensu_host='169.254.255.254', sensu_port=3030, component=None, description=None, ):
 """Send a new event with the given information. Requires a name, runbook, status code, event output, and team but the other keys are kwargs and have defaults. :type name: str :param name: Name of the check :type runbook: str :param runbook: The runbook associated with the check :type status: int :param status: Exit status code, 0,1,2,3. Must comply with the Nagios conventions. See `the Sensu docs <https://sensuapp.org/docs/latest/checks#sensu-check-specification>`_ for the exact specification. :type output: str :param output: The output of the check itself. May include CRIT/WARN/OK to make it easy to evaluate how things went. Should be newline separated, but try to put the most relevant data in the first line. Example: OK: Everything is fine or CRIT: Accounts are locked. Users can't buy widgets. :type team: str :param team: Team responsible for this check. This team must already be defined server-side in the Sensu handler configuration. :type page: bool :param page: Boolean on whether this alert is page-worthy. Activates handlers that send pages. :type tip: str :param tip: A short 1-line version of the runbook. Example: "Set clip-jawed monodish to 6" :type notification_email: str :param notification_email: A comma-separated string of email destinations. Unset will default to the "team" default. :type check_every: str :param check_every: Human readable time unit to let Sensu know how of then this event is fired. Defaults to "30s". If this parameter is not set correctly, the math for `alert_after` will be incorrect. :type realert_every: int :param realert_every: Integer value for filtering repeat occurrences. A value of 2 would send every other alert. Defaults to -1, which is a special value representing exponential backoff. (alerts on event number 1,2,4,8, etc) :type alert_after: str :param alert_after: A human readable time unit to suspend handler action until enough occurrences have taken place. Only valid when check_every is accurate. :type dependencies: list :param dependencies: An list of strings representing checks that *this* check is dependent on. :type irc_channels: list :param irc_channels: An list of IRC channels to send the event notification to. Defaults to the team setting. Set an empty list to specify no IRC notifications. :type slack_channels: list :param slack_channels: An list of Slack channels to send the event notification to. Defaults to the team setting. Set an empty list to specify no Slack notifications. :type ticket: bool :param ticket: A Boolean value to enable ticket creation. Defaults to false. :type project: str :param project: A string representing the JIRA project that the ticket should go under. Defaults to the team value. :type priority: str :param priority: A JIRA priority to use when creating a ticket. This only makes sense to use when in combination with the ticket parameter set to true. :type source: str :param source: Allows "masquerading" the source value of the event, otherwise comes from the fqdn of the host it runs on. This is especially important to set on events that could potentially be created from multiple hosts. For example if ``send_event`` is called from three different hosts in a cluster, you wouldn't want three different events, you would only want one event that looked like it came from ``the_cluster``, so you would set ``source='the_cluster'``. :type tags: list :param tags: An list of arbitrary tags that can be used in handlers for different metadata needs such as labels in JIRA handlers. :type ttl: str :param ttl: A human readable time unit to set the check TTL. If Sensu does not hear from the check after this time unit, Sensu will spawn a new failing event! (aka check staleness) Defaults to None, meaning Sensu will only spawn events when send_event is called. :type sensu_host: str :param sensu_host: The IP or Name to connect to for sending the event. Defaults to the yocalhost IP. :type component: list :param component: Component(s) affected by the event. Good example here would would be to include the service that is being affected or a module of that service such as healthcheck. :type description: str :param description: Human readable text giving more context on the event. This could include information on what the check means or why was it created. Note on TTL events and alert_after: ``alert_after`` and ``check_every`` only really make sense on events that are created periodically. Setting ``alert_after`` on checks that are not periodic is not advised because the math will be incorrect. For example, if check was written that called ``send_event`` on minute values that were prime, what should the ``check_every`` setting be? No matter what it was, it would be wrong, and therefore ``alert_after`` would be incorrectly calculated (as it is a function of the number of failing events seen multiplied by the ``check_every`` setting). If in doubt, set ``alert_after`` to ``0`` to ensure you never miss an alert due to incorrect ``alert_after`` math on non-periodic events. (See also this `Pull request <https://github.com/sensu/sensu/pull/1200>`_) """

    if not (name and team):
        raise ValueError("Name and team must be present")
    if not re.match(r'^[\w\.-]+$', name):
        raise ValueError("Name cannot contain special characters")
    if not runbook:
        runbook = 'Please set a runbook!'
    result_dict = {
        'name': name,
        'status': status,
        'output': output,
        'handler': 'default',
        'team': team,
        'runbook': runbook,
        'tip': tip,
        'notification_email': notification_email,
        'interval': human_to_seconds(check_every),
        'page': page,
        'realert_every': int(realert_every),
        'dependencies': dependencies,
        'alert_after': human_to_seconds(alert_after),
        'ticket': ticket,
        'project': project,
        'priority': priority,
        'source': source,
        'tags': tags,
        'ttl': human_to_seconds(ttl),
    }
    if irc_channels is not None:
        result_dict['irc_channels'] = irc_channels

    if slack_channels is not None:
        result_dict['slack_channels'] = slack_channels

    if component is not None:
        result_dict['component'] = component

    if description is not None:
        result_dict['description'] = description

    json_hash = json.dumps(result_dict)

    sock = socket.socket()
    try:
        sock.connect((sensu_host, sensu_port))
        sock.sendall(six.b(json_hash) + b'\n')
    finally:
        sock.close()