Beispiel #1
0
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     _data = configuration.GetMetadata <SoidBergActivityData>();
     soid_assetSelectionControl.Initialize(configuration.Assets, Framework.Assets.AssetAttributes.None);
     oidtype_comboBox.SelectedIndex = (int)_data.SnmpCommand;
     snmp_textBox.Text = _data.SnmpOid;
     snmpCustom_radioButton.Checked = true;
     if (!string.IsNullOrEmpty(_data.SnmpSetValue))
     {
         oidvalue_textbox.Text = _data.SnmpSetValue;
     }
 }
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            SoidBergActivityData data     = executionData.GetMetadata <SoidBergActivityData>();
            StringBuilder        messages = new StringBuilder();
            bool   activityFailed         = false;
            string snmpOutput             = string.Empty;

            if (!string.IsNullOrEmpty(data.SnmpOid))
            {
                foreach (var asset in executionData.Assets)
                {
                    try
                    {
                        Snmp snmp = new Snmp(((PrintDeviceInfo)asset).Address);

                        switch (data.SnmpCommand)
                        {
                        case SnmpCommandTypes.Get:
                        {
                            snmpOutput = snmp.Get(data.SnmpOid);
                        }
                        break;

                        case SnmpCommandTypes.GetNext:
                        {
                            snmpOutput = snmp.GetNext(data.SnmpOid).ToString();
                        }
                        break;

                        case SnmpCommandTypes.Set:
                        {
                            int value = 0;
                            snmpOutput = IsNumeric(data.SnmpSetValue, ref value) ? snmp.Set(data.SnmpOid, value).ToString() : snmp.Set(data.SnmpOid, data.SnmpSetValue).ToString();
                        }
                        break;
                        }
                        UpdateStatus(string.Format("Device:{0}, SNMP Result:{1}", snmp.Address, snmpOutput));
                        messages.AppendLine(string.Format("{0}: {1}", snmp.Address, snmpOutput));
                    }
                    catch (SnmpException snmpException)
                    {
                        messages.AppendLine(string.Format("Failed for {0}: {1}", ((PrintDeviceInfo)asset).Address,
                                                          snmpException.Message));
                        activityFailed = true;
                    }
                }
                return(activityFailed ? new PluginExecutionResult(PluginResult.Failed, string.Format("Activity failed for one or more devices. {0}", messages.ToString())) : new PluginExecutionResult(PluginResult.Passed, messages.ToString()));
            }
            return(new PluginExecutionResult(PluginResult.Skipped));
        }
Beispiel #3
0
 public void Initialize(PluginEnvironment environment)
 {
     _data = new SoidBergActivityData();
 }