Example #1
0
        /// <summary>
        /// Creating generic traps UP, DOWN component
        /// </summary>
        /// <param name="id">
        /// trap id
        /// </param>
        /// <param name="moduleName">
        /// module name
        /// </param>
        /// <returns>
        /// The <see cref="SentinelTrap"/>.
        /// </returns>
        private SentinelTrap InitializeDownUpTrap(int id, string moduleName)
        {
            SentinelTrap trap = new SentinelTrap(id);

            trap.AddParameter("ModuleName", moduleName);
            return(trap);
        }
Example #2
0
        /// <summary>
        /// Initiate SNMP trap sending
        /// </summary>
        /// <param name="trap">
        /// Contains information about trap, like trap ID and variables with values.
        /// </param>
        /// <param name="moduleName">
        /// Contains information about module name
        /// </param>
        /// <param name="trapToClear">
        /// Guide of a trap to clear
        /// </param>
        public void RaiseTrap(SentinelTrap trap, string moduleName, Guid trapToClear)
        {
            try
            {
                mLogger.InfoFormat("RaiseTrap: Trap raising for trap ID: {0}", trap.TrapID.ToString(CultureInfo.InvariantCulture));
                var module = mModulesInfo.ModulesInfo.Find(p => p.Name.Equals(moduleName));
                if (moduleName.Equals("TextCapture") && trap.TrapID == 21002)
                {
                    mLogger.DebugFormat("{0} trap is TC autocleared trap.", trap.TrapID);
                    module.SendAutoFixing = true;
                }

                var newTrap = 0; //new MGenericTrapData
                //{
                //    EnterpriseIndex = GetOidIndex(module.OID),
                //    TrapID = trap.TrapID,
                //    IsSticky = true,
                //    TrapName = module.Name,
                //    VarBindList = new List<VarBindEntry>()
                //};
                int index = 0;
                if (trap.OrderedParameters != null)
                {
                    foreach (KeyValuePair <string, string> item in trap.OrderedParameters)
                    {
                        index++;
                        mLogger.DebugFormat("RaiseTrap: Varbind item type: {0}, value: {1}", item.Key, item.Value);
                        //newTrap.VarBindList.Add(new VarBindEntry
                        //{
                        //    TypeOID = string.Format("{0}.0.{1}", module.OID, index),
                        //    Value = item.Value
                        //});
                    }
                }
                else
                {
                    //foreach (DictionaryEntry item in trap.Parameters)
                    //{
                    //    index++;
                    //    mLogger.DebugFormat("RaiseTrap: Varbind item type: {0}, value: {1}", item.Key, item.Value);
                    //    newTrap.VarBindList.Add(new VarBindEntry
                    //    {
                    //        TypeOID = string.Format("{0}.0.{1}", module.OID, index),
                    //        Value = item.Value
                    //    });
                    //}
                }

                //DispatchTrap(newTrap); // Paasing trap to Agent in order to send it.
                mLogger.DebugFormat("RaiseTrap: Trap raising completed");
            }
            catch (Exception exception)
            {
                mLogger.Error("Error occured while sending a trap. ", exception);
            }
        }
Example #3
0
        /// <summary>
        /// Send trap
        /// </summary>
        /// <param name="moduleName">
        /// The module Name.
        /// </param>
        /// <param name="trap">
        /// Trap information
        /// </param>
        /// <param name="trapToClear">
        /// Guide of trap to clear
        /// </param>
        /// <returns>
        /// returns Guide of a sent trap
        /// </returns>
        public Guid SendTrap(string moduleName, SentinelTrap trap, Guid trapToClear)
        {
            mLogger.InfoFormat("Sending trap {0}", trap);
            if (IsInitialized)
            {
                AgentSingleton.Instance.RaiseTrap(trap, moduleName, trapToClear);
            }

            return(Guid.Empty);
        }
Example #4
0
 /// <summary>
 /// Method sends auto fixing trap for Text Capture component.
 /// This is the only component that has such trap. That's why it is hardcoded.
 /// </summary>
 /// <param name="moduleName">
 /// The module Name.
 /// </param>
 private void SendAutoFixTrapForTextCapture(string moduleName)
 {
     try
     {
         SentinelTrap fixTrapToSend = new SentinelTrap(21502);
         fixTrapToSend.AddParameter("ErrorCause", "AutoFixingTrap");
         RaiseTrap(fixTrapToSend, moduleName, Guid.Empty);
     }
     catch (Exception exception)
     {
         mLogger.Error(exception);
     }
 }