You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Thomas Muller <tt...@online.no> on 2002/10/15 21:22:25 UTC

SnmpAppender extention suggestion (was: RE: Joe SNMP facade bug)

Add interface:

public abstract interface SysupTimeResolver {
    public abstract long getSysupTime();
}

Add the following to SNMPAppender:

private static final SysupTimeResolver DEFAULT_SYSUP_TIME_RESOLVER =
        new SysupTimeResolver() {

            long time = System.currentTimeMillis();

            public long getSysupTime() {
                return( System.currentTimeMillis() - time );
            }

    };

private SysupTimeResolver sysupTimeResolver = DEFAULT_SYSUP_TIME_RESOLVER;

public void setSysupTimeResolverClass( String value ) {
    sysupTimeResolver = ( SysupTimeResolver )
            OptionConverter.instantiateByClassName( value,
SysupTimeResolver.class,
                    DEFAULT_SYSUP_TIME_RESOLVER );
}

--

Thomas

| -----Original Message-----
| From: Mark Masterson [mailto:mark.masterson@d2mail.de]
| Sent: 15 October 2002 19:59
| To: Log4J Users List
| Subject: RE: Joe SNMP facade bug
|
|
| Hi Steve,
|
| Ahh, brilliant!
|
| >>the SnmpOctetString class in the JoeSnmp implementation is
| treating the IP Address String as a list of bytes, so what I get
| in the trap is the ascii values of my String IP Address.<<
|
| Yes, this had been reported before, but the report was not
| specific enough for me to reproduce it here.  Interestingly, the
| bug seems to be variable, depending on the NMS software one uses
| to receive the trap.  Some receivers pick up the JoeSNMP string
| okay, and some don't.
|
| The fix is something like this, to replace the current line 257:
|
| <code>
| InetAddress tmpAddress = InetAddress.getByName(this.localIPAddress);
| addr.setString(tmpAddress.getAddress());
| </code>
|
| This stuffs a properly filled byte array into the
| SnmpOctetString, and should do the trick without resorting to a
| "roll-your-own" parser.
|
| I'll release a fixed version of the appender in the next couple
| of days.  Thanks for the bug report!
|
| Cheers,
| Mark
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: SnmpAppender extention suggestion (was: RE: Joe SNMP facade bug)

Posted by Thomas Muller <tt...@online.no>.
.... and of course, remove the setSysupTime() etc. This is rarely used
anyway since one generally don't want to keep track of actual appenders and
specially not in form of their types (in this case SNMPAppender).

--

Thomas



| -----Original Message-----
| From: Thomas Muller [mailto:ttm@online.no]
| Sent: 15 October 2002 20:22
| To: Log4J Users List
| Subject: SnmpAppender extention suggestion (was: RE: Joe SNMP facade
| bug)
|
|
| Add interface:
|
| public abstract interface SysupTimeResolver {
|     public abstract long getSysupTime();
| }
|
| Add the following to SNMPAppender:
|
| private static final SysupTimeResolver DEFAULT_SYSUP_TIME_RESOLVER =
|         new SysupTimeResolver() {
|
|             long time = System.currentTimeMillis();
|
|             public long getSysupTime() {
|                 return( System.currentTimeMillis() - time );
|             }
|
|     };
|
| private SysupTimeResolver sysupTimeResolver = DEFAULT_SYSUP_TIME_RESOLVER;
|
| public void setSysupTimeResolverClass( String value ) {
|     sysupTimeResolver = ( SysupTimeResolver )
|             OptionConverter.instantiateByClassName( value,
| SysupTimeResolver.class,
|                     DEFAULT_SYSUP_TIME_RESOLVER );
| }
|
| --
|
| Thomas
|
| | -----Original Message-----
| | From: Mark Masterson [mailto:mark.masterson@d2mail.de]
| | Sent: 15 October 2002 19:59
| | To: Log4J Users List
| | Subject: RE: Joe SNMP facade bug
| |
| |
| | Hi Steve,
| |
| | Ahh, brilliant!
| |
| | >>the SnmpOctetString class in the JoeSnmp implementation is
| | treating the IP Address String as a list of bytes, so what I get
| | in the trap is the ascii values of my String IP Address.<<
| |
| | Yes, this had been reported before, but the report was not
| | specific enough for me to reproduce it here.  Interestingly, the
| | bug seems to be variable, depending on the NMS software one uses
| | to receive the trap.  Some receivers pick up the JoeSNMP string
| | okay, and some don't.
| |
| | The fix is something like this, to replace the current line 257:
| |
| | <code>
| | InetAddress tmpAddress = InetAddress.getByName(this.localIPAddress);
| | addr.setString(tmpAddress.getAddress());
| | </code>
| |
| | This stuffs a properly filled byte array into the
| | SnmpOctetString, and should do the trick without resorting to a
| | "roll-your-own" parser.
| |
| | I'll release a fixed version of the appender in the next couple
| | of days.  Thanks for the bug report!
| |
| | Cheers,
| | Mark
| |
|
|
|
| *************************************************************************
| Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved.
| The information supplied in this Commercial Communication should
| be treated
| in confidence.
| No liability whatsoever is accepted for any loss or damage
| suffered as a result of accessing this message or any attachments.
|
| ________________________________________________________________________
| This email has been scanned for all viruses by the MessageLabs SkyScan
| service. For more information on a proactive anti-virus service working
| around the clock, around the globe, visit http://www.messagelabs.com
| ________________________________________________________________________
|
| --
| To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>




*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>