//---------------------------------------------- public IList <Variable> ReadSnmp(string[] strOids) { List <Variable> lst = new List <Variable>(); foreach (string strOid in strOids) { if (strOids != null) { uint[] oidsInt = ObjectIdentifier.Convert(strOid); lst.Add(new Variable(oidsInt)); } } try { CSnmpConnexion cnx = new CSnmpConnexion( SnmpVersion, Communaute, new IPEndPoint(IPAddress.Parse(Ip), SnmpPort), Timeout); CInterrogateurSnmp it = new CInterrogateurSnmp(); it.Connexion = cnx; return(it.Get(lst)); } catch { } return(new List <Variable>()); }
//------------------------------------------------------------- private void GetEtatMediation() { CSnmpConnexion cnx = GetConnexion(); m_timerUpdateEtatService.Stop(); try { IServiceMediation service = cnx.ServiceMediation; m_bCurrentState = service.IsStarted; if (m_bCurrentState.Value) { m_lblEtatService.BackColor = Color.LightGreen; m_lblEtatService.ForeColor = Color.Black; m_lblEtatService.Text = I.T("Started|20327"); } else { m_lblEtatService.BackColor = Color.Red; m_lblEtatService.ForeColor = Color.Black; m_lblEtatService.Text = I.T("Stopped|20328"); } } catch (Exception ex) { m_errorProvider.SetError(m_lblEtatService, I.T("Error while reaching service \n@1|20325", ex.ToString())); m_lblEtatService.BackColor = Color.DarkGray; m_lblEtatService.ForeColor = Color.White; m_lblEtatService.Text = I.T("Error|20326"); } m_timerUpdateEtatService.Enabled = false; m_timerUpdateEtatService.Start(); }
public object GetSnmpValueForField(int nIdChampCustom) { //Récupère l'oid string strOid = GetFieldOID(nIdChampCustom); if (strOid != null && strOid.Length > 0) { CSnmpConnexion cnx = AgentSnmp.GetNewSnmpConnexion(); CInterrogateurSnmp agent = new CInterrogateurSnmp(); agent.Connexion = cnx; return(agent.Get(strOid)); } return(null); /*CResultAErreur result = ReadChampSnmp(nIdChampCustom); * if (!result) * return null; * CRelationEntiteSnmp_ChampCustom relChamp = CUtilElementAChamps.GetRelationToChamp(this, nIdChampCustom) as CRelationEntiteSnmp_ChampCustom; * if (relChamp != null) * { * return relChamp.LastSnmpValue; * } * else * { * } * return result.Data ;*/ }
public void UpdateFullDistantConfiguration() { CSnmpConnexion cnx = new CSnmpConnexion(); cnx.EndPoint = new IPEndPoint(IPAddress.Parse(AdresseIp), Port); cnx.SetConfigurationDeSnmpProxy(GetConfiguration()); cnx.NotifyProxyNecessiteMAJ(Id, true, true, true); }
private CSnmpConnexion GetConnexion() { if (m_connexion == null) { m_connexion = new CSnmpConnexion(); m_connexion.EndPoint = new IPEndPoint(IPAddress.Parse(m_proxy.AdresseIp), m_proxy.Port); } return(m_connexion); }
//------------------------------------------------------------ protected CSnmpConnexion GetConnexion() { if (m_connexion == null) { m_connexion = new CSnmpConnexion(); m_connexion.EndPoint = new IPEndPoint(IPAddress.Parse(m_strIpAgent), 0); } return(m_connexion); }
//------------------------------------------------------------------------------- public CResultAErreur ReadChampSnmp(int nIdChampCustom) { CResultAErreur result = CResultAErreur.True; //Va chercher la valeur CSnmpConnexion cnx = AgentSnmp.GetNewSnmpConnexion(); CInterrogateurSnmp agent = new CInterrogateurSnmp(); agent.Connexion = cnx; return(ReadChampSnmp(nIdChampCustom, agent)); }
/// ///////////////////////////////////////////// public CSnmpConnexion GetNewSnmpConnexion() { CSnmpConnexion connexion = new CSnmpConnexion(); IPAddress ip = null; IPAddress.TryParse(SnmpIp, out ip); connexion.EndPoint = new IPEndPoint(ip, SnmpPort); connexion.Version = SnmpVersion; connexion.Community = SnmpCommunaute; return(connexion); }
//----------------------------------------------------------------------- public static bool EditeConnexion(ref CSnmpConnexion connexion) { CFormSetupInterrogationSNMP form = new CFormSetupInterrogationSNMP(); form.m_connexion = connexion; bool bResult = form.ShowDialog() == DialogResult.OK; if (bResult) { connexion = form.m_connexion; } form.Dispose(); return(bResult); }
private void m_menuStop_Click(object sender, EventArgs e) { try { CSnmpConnexion cnx = GetConnexion(); cnx.ServiceMediation.Stop(); GetEtatMediation(); } catch (Exception ex) { CResultAErreur result = CResultAErreur.True; result.EmpileErreur(new CErreurException(ex)); CFormAlerte.Afficher(result.Erreur); } }
//---------------------------------------------- public object ReadSnmp(string strOID) { try { CSnmpConnexion cnx = new CSnmpConnexion( SnmpVersion, Communaute, new IPEndPoint(IPAddress.Parse(Ip), SnmpPort), Timeout); CInterrogateurSnmp it = new CInterrogateurSnmp(); it.Connexion = cnx; return(it.Get(strOID)); } catch { return(null); } }
public void Init( CSnmpConnexion connexion, IDefinition rootDefinition, CTypeAgentPourSupervision baseHandlers, IBaseTypesAlarmes baseTypes) { m_connexion = connexion; m_browser.Init(rootDefinition, connexion); m_baseHandlers = baseHandlers; CDynamicSnmpAgent agent = new CDynamicSnmpAgent(rootDefinition); agent.Connexion = connexion; m_baseHandlers.AgentAssocie = agent; m_baseTypesAlarmes = baseTypes; FillListeHandlers(); FillListeQueries(); FillListeTypeEntites(); }
//----------------------------------------------------------------------- private void m_btnOk_Click(object sender, EventArgs e) { IPAddress adresse = null; try { adresse = IPAddress.Parse(m_txtIP.Text); } catch { } if (adresse == null) { MessageBox.Show(I.T("Invalid IP address|20037")); return; } if (m_txtPort.IntValue == null) { MessageBox.Show(I.T("Invalid port|20038")); return; } if (!(m_cmbVersion.SelectedItem is VersionCode)) { MessageBox.Show(I.T("Invalid version|20039")); return; } if (m_txtTimeout.IntValue == null) { MessageBox.Show(I.T("Invalid timeout value|20040")); return; } if (m_connexion == null) { m_connexion = new CSnmpConnexion(); } m_connexion.Community = m_txtCommunaute.Text; m_connexion.EndPoint = new IPEndPoint(adresse, m_txtPort.IntValue.Value); m_connexion.Version = (VersionCode)m_cmbVersion.SelectedItem; m_connexion.TimeOut = m_txtTimeout.IntValue.Value; m_connexion.Community = m_txtCommunaute.Text; DialogResult = DialogResult.OK; Close(); }
private void GetDataMediation() { using (CWaitCursor waiter = new CWaitCursor()) { CSnmpConnexion cnx = GetConnexion(); try { IServiceMediation service = cnx.ServiceMediation; CConfigurationServiceMediation config = service.Configuration; DataSet ds = config.DataBase; m_dataGrid.DataSource = ds; } catch (Exception ex) { CResultAErreur result = CResultAErreur.True; result.EmpileErreur(new CErreurException(ex)); result.EmpileErreur(I.T("Error while reading configuration|20331")); CFormAlerte.Afficher(result.Erreur); } } }
public void MiseAJour(bool bDiffere) { if (!bDiffere) { if (m_bMiseAJourEnCours) { return; } m_bMiseAJourEnCours = true; try { ISnmpConnexion cnx = new CSnmpConnexion(); CSnmpProxyConfiguration config = cnx.GetConfigurationDeSnmpProxy(GetInstance().IdProxyConfiguré); if (config != null) { m_instance = config; CSnmpPollingService.Init(m_instance.FrequencePollingMinutes); } } catch { } m_bMiseAJourEnCours = false; m_bMiseAJourDemandee = false; CServiceMediation.GetDefaultInstance().Trace.Write("Proxy setup updated", ALTRACE.TRACE, ALTRACE.DEBUG); } else { m_bMiseAJourDemandee = true; if (m_timerMiseAJour == null) { m_timerMiseAJour = new Timer(5000); m_timerMiseAJour.Elapsed += new ElapsedEventHandler(m_timerMiseAJour_Elapsed); } m_timerMiseAJour.Start(); } }
//---------------------------------- private void SetupConnexion() { foreach (CEasyQuerySource source in m_query.Sources) { CSnmpConnexionForEasyQuery snmpFiller = source.Connexion as CSnmpConnexionForEasyQuery; if (snmpFiller != null) { CInterrogateurSnmpSimplePourFiller agent = snmpFiller.Agent; if (agent != null) { CSnmpConnexion cnx = agent.Connexion; if (cnx == null) { cnx = new CSnmpConnexion(); } if (CFormSetupInterrogationSNMP.EditeConnexion(ref cnx)) { agent.Connexion = cnx; } break; } } } }
//----------------------------------------------------------------------- private void CFormSetupInterrogationSNMP_Load(object sender, EventArgs e) { CWin32Traducteur.Translate(this); foreach (VersionCode code in Enum.GetValues(typeof(VersionCode))) { m_cmbVersion.Items.Add(code); } if (m_connexion == null) { m_connexion = new CSnmpConnexion(); } if (m_connexion.EndPoint != null) { if (m_connexion.EndPoint.Address != null) { m_txtIP.Text = m_connexion.EndPoint.Address.ToString(); } m_txtPort.IntValue = m_connexion.EndPoint.Port; } m_cmbVersion.SelectedItem = m_connexion.Version; m_txtTimeout.IntValue = m_connexion.TimeOut; m_txtCommunaute.Text = m_connexion.Community; }
//-------------------------------------------------------------------- public void Init(IDefinition rootDefinition, CSnmpConnexion connexion) { m_root = rootDefinition; m_connexion = connexion; m_mibTree.Init(rootDefinition); }