# propagate, and distribute a work formed by combining OpenSSL with The
# Software, or a work derivative of such a combination, even if such
# copying, modification, propagation, or distribution would otherwise
# violate the terms of the GPL. You must comply with the GPL in all
# respects for all of the code used other than OpenSSL.
# "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
# Project and licensed under the OpenSSL Licenses, or a work based on such
# software and licensed under the OpenSSL Licenses.
# "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
# under which the OpenSSL Project distributes the OpenSSL toolkit software,
# as those licenses appear in the file LICENSE-OPENSSL.

# This script is intended to be used by an external management system to
# synchronize SNMP alarm state. When invoked without any parameters it
# will trigger a clear for all known alarms on this node, followed by a
# re-issue of all currently active alarms. When invoked with the --noclear
# option it will only re-issue all currently active alarms.

import sys
import syslog
import alarms

if len(sys.argv) == 1:
    alarms.sendrequest(["sync-alarms"])
else:
    syslog.syslog(
        syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" %
        (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)
# violate the terms of the GPL. You must comply with the GPL in all
# respects for all of the code used other than OpenSSL.
# "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
# Project and licensed under the OpenSSL Licenses, or a work based on such
# software and licensed under the OpenSSL Licenses.
# "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
# under which the OpenSSL Project distributes the OpenSSL toolkit software,
# as those licenses appear in the file LICENSE-OPENSSL.


# This script is used to issue an SNMP alarm. It takes two parameters, the
# name of the alarm issuer and the alarm identifier. For example:
#
#   issue_alarm.py "monit" "1000.3"
# Note the alarm identifier uses ituAlarmPerceivedSeverity. We can
# translate this to alarmModelState using the function AlarmTableDef::state.
# This mapping is described in RFC 3877 section 5.4
# https://tools.ietf.org/html/rfc3877#section-5.4

import sys
import syslog
import alarms


if len(sys.argv) == 3:
  alarms.sendrequest(["issue-alarm", sys.argv[1], sys.argv[2]])
else:
  syslog.syslog(syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" % (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)
#! /usr/bin/python2.7

# @file sync_alarms.py
#
# Copyright (C) Metaswitch Networks 2016
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.


# This script is intended to be used by an external management system to
# synchronize SNMP alarm state. When invoked without any parameters it
# will trigger a clear for all known alarms on this node, followed by a
# re-issue of all currently active alarms. When invoked with the --noclear
# option it will only re-issue all currently active alarms.


import sys
import syslog
import alarms


if len(sys.argv) == 1:
  alarms.sendrequest(["sync-alarms"])
else:
  syslog.syslog(syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" % (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)
#! /usr/bin/python2.7

# @file clear_alarms.py
#
# Copyright (C) Metaswitch Networks 2014
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.


# This script is used to clear all currently active SNMP alarms issued by a
# specified issuer. It takes a single parameter which identifies the issuer
# whose alarms are to be cleared. For example:
#
#   clear_alarms.py "monit"


import sys
import syslog
import alarms


if len(sys.argv) == 2:
  alarms.sendrequest(["clear-alarms", sys.argv[1]])
else:
  syslog.syslog(syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" % (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)
# "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
# under which the OpenSSL Project distributes the OpenSSL toolkit software,
# as those licenses appear in the file LICENSE-OPENSSL.


# This script is intended to be used by an external management system to
# synchronize SNMP alarm state. When invoked without any parameters it
# will trigger a clear for all known alarms on this node, followed by a
# re-issue of all currently active alarms. When invoked with the --noclear
# option it will only re-issue all currently active alarms.


import sys
import syslog
import alarms


if len(sys.argv) == 1:
  alarms.sendrequest(["sync-alarms"])

elif len(sys.argv) == 2:
  if sys.argv[1] == "--noclear":
    alarms.sendrequest(["sync-alarms-no-clear"])
  else:
    syslog.syslog(syslog.LOG_ERR, "unexpected option: %s", sys.argv[1])

else:
  syslog.syslog(syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" % (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)
# propagate, and distribute a work formed by combining OpenSSL with The
# Software, or a work derivative of such a combination, even if such
# copying, modification, propagation, or distribution would otherwise
# violate the terms of the GPL. You must comply with the GPL in all
# respects for all of the code used other than OpenSSL.
# "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
# Project and licensed under the OpenSSL Licenses, or a work based on such
# software and licensed under the OpenSSL Licenses.
# "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
# under which the OpenSSL Project distributes the OpenSSL toolkit software,
# as those licenses appear in the file LICENSE-OPENSSL.

# This script is used to clear all currently active SNMP alarms issued by a
# specified issuer. It takes a single parameter which identifies the issuer
# whose alarms are to be cleared. For example:
#
#   clear_alarms.py "monit"

import sys
import syslog
import alarms

if len(sys.argv) == 2:
    alarms.sendrequest(["clear-alarms", sys.argv[1]])
else:
    syslog.syslog(
        syslog.LOG_ERR, "unexpected parameter count: %d, cmd: %s" %
        (len(sys.argv), " ".join(sys.argv[:])))

sys.exit(0)