Giter Site home page Giter Site logo

lextudio / sharpsnmplib-samples Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 27.0 25.2 MB

Sample projects for #SNMP Library.

Home Page: https://docs.sharpsnmp.com

License: MIT License

C# 99.57% Batchfile 0.03% PowerShell 0.33% Visual Basic .NET 0.07%

sharpsnmplib-samples's Introduction

Headline

This project is now suspended. If you want to take it over, please read this post and contact me directly.

Project Description

Code Beautifier Collection 6 for CodeGear RAD Studio 2007 is an open source expert.

(C) 2005-2008 Lex Li and other contributors

History

Since its birthday in May, 2005, it has served hundreds of C#Builder 1.0, Delphi 8 for .NET, Delphi 2005, and Delphi 2006 users. Because RAD Studio 2007 (including Delphi 2007 and C++Builder 2007) is built on .NET 2.0 platform, 5.x generation support and update is discontinued and here comes a new 6.0 generation, which fully takes advantage of .NET 2.0 platform.

Notice

  1. After installation, you can read the user manual (manual.pdf) to know more about Code Beautifier Collection and how it can improve your Delphi coding experience.
  2. Old builds of 5.x generation is still available at old homepage for C#Builder/Delphi 8/2005/2006 users.

License

After installation, you can read the license document (license.pdf) to find the details.

Contact Information

If you have any suggestions or questions, please contact me by mail. My mail box is [email protected].

Donate!

Show your appreciation for Code Beautifier Collection and support future development by clicking this button.

.

sharpsnmplib-samples's People

Contributors

aib avatar azure-pipelines[bot] avatar danielkozlowski avatar denis-pakizh avatar gralin avatar gregmac avatar karlox2 avatar lextm avatar mattzink avatar quintinon avatar semihokur avatar sinstr avatar sweetpants avatar vhallac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sharpsnmplib-samples's Issues

Keep the samples up-to-date

Several samples were not up-to-date and should be updated,

  • snmpsendtrap and snmptrapd issue #83
  • Fix DES/AES by using the Bouncy Castle package #81 and #82

engineReboots is always = 0, but it should be configurable from outside

The problem is that in current implementation engineReboots is always equal to 0. (unless it continuously work for 68 years, that hardly ever happens)

But as you know, according to RFC3414, engineReboots should be incremented if engine is rebooted/restarted.
and engineReboots should be stored in a retentive memory.

Implementing a mechanism of proper handling (incrementing and retentive storing) of engineReboots can be platform-specific, use-case-specific, application-specific. (Also it involves a reference to EngineID that is currently not Unique and not configurable (see https://github.com/lextm/sharpsnmplib/pull/76 ) ) So, I don't think that it's a good idea to fully implement it inside the library.

BUT, I believe that engineReboots is something that definitely should be configurable from outside.

(Particularly, because of the issue I have problems with v3 communication between Zabbix and SharpSnmp)

So, I suggest just a tiny reworking of EngineGroup::EngineTimeData in a way like this:

    /// <summary>
    /// How many times an engine (with a given EngineId) was ever rebooted/reinitialized.
    /// See RFC3414 for details.
    /// (it's better to increment this too often than too seldom;
    ///    "Note that even if an SNMP engine re-boots once a second that
    ///    it would still take approximately 68 years before the max value of
    ///    2147483647 would be reached")
    ///    (Another Prop is created not to be in conflict with existing [Obsolete] EngineBoots)
    /// </summary>
    public int PhysicalEngineBoots { get; set; }

    /// <summary>
    /// Gets the engine time data.
    /// </summary>
    /// <value>
    /// The engine time data. [0] is engine boots, [1] is engine time.
    /// </value>
    public int[] EngineTimeData
    {
        get
        {
            var now = DateTime.UtcNow;
            long seconds = (now - _start).Ticks / 10000000;
            var engineTime = (int)(seconds % int.MaxValue);
            var arithmeticalEngineBoots = (int)(seconds / int.MaxValue); 

            int engineReboots = PhysicalEngineBoots + arithmeticalEngineBoots; 
            return new[] { engineReboots, engineTime };
        }
    }

SnmpTrapD does now receive first v3 trap in SnmpSendTrap

The first v3 trap sent in the snmpsendtrap sample program is not received by the sample snmptrapd.

This occurs on line 106:

{
var trap = new TrapV2Message(
VersionCode.V3,
528732060,
1905687779,
new OctetString("neither"),
new ObjectIdentifier("1.3.6"),
0,
new List(),
DefaultPrivacyProvider.DefaultPair,
0x10000,
new OctetString(ByteTool.Convert("80001F8880E9630000D61FF449")),
0,
0);
trap.Send(new IPEndPoint(address, 162));
}

I have been unable to get a v3 trap received using DefaultPrivacyProvider.DefaultPair. I can only see the v3 traps when their is an actual provider as in the case of the last v3 trap that is sent in the sample.

Question - SNMPv2 Inform Response

I'm developing an snmp manager with Sharp SNMP Lib 11.1 from nuget.
I receive snmp v2 inform with a handler attached to Listener's MessageReceived event, the inform from agent is successfully received, but there is no confirmation response sent back.
I searched but can't find any sample or document regarding this topic.
After reading snmp rfc and some trial and error, I write a line
e.Binding.SendResponseAsync(e.Message, e.Sender);
in the MessageReceived event handler, which seems to be working.
Is this the right api to use and a good practice?

ListenerBinding.Stop() does not wait until the receiver task is completed.

During SnmpEngine.Stop() the ListenerBinding.Stop() calls _socket.Shutdown(SocketShutdown.Both), without waiting for the AsyncReceive Task to complete.

A subsequent SnmpEngine.Start() can call ListenerBinding.Start() before the SocketException is handled by the existing AsyncReceive Task.

This means that when the original AsyncReceive handles the exception, it will set _active to be Inactive causing the new AsyncReceive task to return as well.

This means that no SNMP requests well be received even though the SnmpEngine is active.

snmptrapd smple throws socketexception

When i use the snmptrapd sample when you use the code engine.stop() it throws a socketexception.

I happen to have this error in all projects i 'm making with this package.
I'm making a listener application.
i have build the samples.engine and referenced it to my project when i use engine.stop() it throws the same error
even when i use the code:
if(engine.Active)
engine.stop()
engine.dispose()

it throws the exception withing the dispose method of snmpegine.cs

Issue building solution

Always had issues building this solution, used to be resolved by adding Build Target for Build and Clean in the Samples.Engine.csproj.
It no longer compiles, complaining about not finding CollectUpToDateCheckBuiltDesignTime" in the project. If I manually add it to the build, it will go on about something else.
It'll then give me this:
NETSDK1004 Assets file 'C:\Users\admin\source\repos\sharpsnmplib-samples\Samples.Engine\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Samples.Engine
This seems to be a byproduct of dotnet restore not being able to run because of the aforementioned.

This applies for Visual Studio 16.8.3 directly after cloning the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.