From: Claessens J. <Jur...@ce...> - 2015-07-10 09:10:51
|
That works for the year, but how would I get the entire date, time then? When I try to extend the range and try to unpack, line blow, it still only shows 2015. Maybe split the thing completely, but how do you define in this case where it starts? Met vriendelijke groeten/Meilleures salutations/Best regards Jurgen Claessens Servicedesk Midmarket T +32 3 54 54 954 F +32 3 54 54 955 E Inf...@ce... CEGEKA • Noorderlaan 87 • B-2030 Antwerpen • T +32 11 24 02 34 • www.cegeka.be -----Original Message----- From: Jeremy Laidman [mailto:jla...@re...] Sent: vrijdag 10 juli 2015 9:58 To: dev...@li... Subject: Re: [Devmon] OID not translating I think you might be able to solve this using SUBSTR and UNPACK transforms. Try this in transforms: hrSystemDateYearPacked: SUBSTR : {hrSystemDate} 0 2 hrSystemDateYear: UNPACK : {hrSystemDateYearPacked} n Then use {hrSystemDateYear} in your message file. J On 10 July 2015 at 17:20, Claessens Jurgen <Jur...@ce...> wrote: > Hi Jeremy, > > Thanks for the explanation. I was suspecting it had to do with the > encoding/decoding. > I will try to see if I can find this in BER.pm, or might be better to > report this to the developer of BER? > > In the meantime I have written an extra "test" which will calculate > the time difference in seconds from an epoch timestamp with the > current system time. > This is not 100% accurate as what I want. But at least I can do > alerting on it now. > > Add the lines to dm_templates.pm > > $func_type eq 'datedif' and do { > $temp =~ s/\s*\{\s*\S+?\s*\}|\s*,\s*//g; > do_log("DATEDIF transform uses only a single oid at " . > "$trans_file, line $l_num", 0) > and next LINE if $temp ne ''; > last CASE; > }; > > > Add the lines below to dm_tests.pm > > # Returns the difference between the local time and the provided epoch > timestamp ############################### > sub trans_datedif { > my ($device, $oids, $oid, $thr) = @_; > my $oid_h = \%{$oids->{$oid}}; > > # Extract our transform options > my $dep_oid = $1 if $oid_h->{'trans_data'} =~ /\{(.+)\}/; > my $dep_oid_h = \%{$oids->{$dep_oid}}; > # Validate our dependencies > validate_deps($device, $oids, $oid, [$dep_oid], '^\d+(\.\d+)?$') > or return; > > # Get local time > my $local_timestamp = time(); > > # See if we are a repeating variable type datum > # (such as that generated by snmpwalking a table) > if($oid_h->{'repeat'}) { > for my $leaf (keys %{$dep_oid_h->{'val'}}) { > > # Skip if there was a dependency error for this leaf > next if $oid_h->{'error'}{$leaf}; > > my $remote_timestamp = $dep_oid_h->{'val'}{$leaf}; my $offset = > $local_timestamp - $remote_timestamp; > > $oid_h->{'val'}{$leaf} = int($offset); > $oid_h->{'time'}{$leaf} = time; > > # Apply thresholds > apply_thresh_rep($oids, $thr, $oid); > > } > } > > # Otherwise we are a single entry datum > else { > my $remote_timestamp = $dep_oid_h->{'val'}; my $offset = > $local_timestamp - $remote_timestamp; > > $oid_h->{'val'} = $offset; > $oid_h->{'time'} = time; > > # Apply thresholds > apply_thresh_rep($oids, $thr, $oid); > } > > } > > > > Met vriendelijke groeten/Meilleures salutations/Best regards > > Jurgen Claessens > -----Original Message----- > From: Jeremy Laidman [mailto:jla...@re...] > Sent: vrijdag 10 juli 2015 8:49 > To: dev...@li... > Subject: Re: [Devmon] OID not translating > > Hmm, this is curious. I can confirm your results. I should be able > to simply display the system date on any test page by adding the OID > name (defined in oids) into the message file. When I do this, I get > garbage, as you've described. It's not actually garbage, but it's an > encoding/decoding mismatch. > > A quick test shows that most strings are simply ASCII-encoded. For > example, using snmpget with "-d" (debug) for sysName shows a packet > with the hostname in an ASCII-encoded format. > > But when doing the same thing for the system date, instead I get a > form of encoding that appears to be specifically structured for > human-readable dates and times. Example: > > Received 57 bytes from UDP: [127.0.0.1]:161->[0.0.0.0] > 0000: 30 37 02 01 01 04 08 6C 78 70 75 62 6C 69 63 A2 > 07.....XXXXXXXX▒ > 0016: 28 02 04 0E 12 87 A8 02 01 00 02 01 00 30 1A 30 > (.....▒......0.0 > 0032: 18 06 09 2B 06 01 02 01 19 01 02 00 04 0B 07 DF > ...+...........▒ > 0048: 07 0A 0F 38 3A 00 2B 0A 00 ...8:.+.. > > HOST-RESOURCES-MIB::hrSystemDate.0 = STRING: > 2015-7-10,15:56:58.0,+10:0 > > The last 12 bytes (starting 07 DF) represent the string > "2015-7-10,15:56:58.0,+10:0". The "0B" that precedes this string is > the string length. So we have: > > 07DF 07 0A -> 2015-7-10 > 0F 38 3A 00 -> 15:56:58.0 > 2B -> ?? > 0A 00 -> +10:00 > > This doesn't seem to be a string at all, despite snmpget listing it as > one. Looking closer, the "04" just before the "0B" length indicator > is probably the tag indicator, where "04" means "octet string". > However the MIB files on my system list hrSystemDate as a DateAndTime type. > > It looks like BER.pm will match against type 4 (octet_string_tag) and > simply decode it as an ASCII string. > > I think the bottom line is that you're getting an encoded value, > tagged as an octet-string, but then treated as if it's human readable > when it's not, and your only course of action would be to handle this > special case with some code, somewhere. > > One option might be to enhance BER.pm to treat this OID as a special > case when decoding, although I don't think the decoding functions in > BER.pm can see the OID. Another option might be to have dm_snmp.pm > treat this OID as a special case, and either have its own decoding > routine for this OID, or re-code the result in human-readable format. > > Note that this is not the only case like this. Things like > ifPhysAddress are also octet-strings that are not ASCII, and they'll > also give you "garbage" when used in this way. > > Cheers > Jeremy > > > On 10 July 2015 at 15:29, Jeremy Laidman <jla...@re...> wrote: > > > Can you show the relevant line in your oids and message files? > > > > > > On 10 July 2015 at 13:59, Claessens Jurgen > > <Jur...@ce...> > > wrote: > > > >> Hi, > >> > >> I'm afraid that doesn't work, I already tried that at first. But > >> seeing the result received thru devmon is nothing readable, I > >> cannot perform any sort of transform. > >> As said, when I query the device manually, I do get a normal > >> response, but there is something in the devmon translation, which > >> is messing things up. > >> I just have no clue on how to debug this so I can pinpoint the culprit. > >> > >> Met vriendelijke groeten/Meilleures salutations/Best regards > >> > >> Jurgen Claessens > >> -----Original Message----- > >> From: MF...@hr... [mailto:MF...@hr...] > >> Sent: donderdag 9 juli 2015 16:52 > >> Cc: Devmon - Email List > >> Subject: Re: [Devmon] OID not translating > >> > >> I would recommend using the 'REGSUB' transform to strip out the > >> info you need, then use DATE and/or ELAPSED to determine time. > >> > >> > >> > >> From: > >> Ken Connell <kco...@ry...> > >> To: > >> Devmon - Email List <dev...@li...>, > >> Date: > >> 07/09/2015 07:43 AM > >> Subject: > >> Re: [Devmon] OID not translating > >> > >> > >> > >> Sorry....over my head....hopefully someone else can chime in. > >> On Jul 9, 2015 8:46 AM, "Claessens Jurgen" > >> <Jur...@ce...> > >> wrote: > >> > >> > Hi Ken, > >> > > >> > Currently I'm not even at that point as I get garbage back when > >> > run from devmon. > >> > I only have it in my OID file and message file. > >> > As far as I can tell devmon uses encode/decode from BER.pm to > >> > make the communication secure?? > >> > When I do some debugging on the end parameters I can see all > >> > other OID's are decoded, but that 1 OID remains encoded. > >> > So something is amiss there. I just don't know what. I don't know > >> > enough of the language or logic behind it. > >> > > >> > Met vriendelijke groeten/Meilleures salutations/Best regards > >> > > >> > Jurgen Claessens > >> > -----Original Message----- > >> > From: Ken Connell [mailto:kco...@ry...] > >> > Sent: donderdag 9 juli 2015 14:34 > >> > To: Devmon - Email List > >> > Subject: Re: [Devmon] OID not translating > >> > > >> > When you say "translate the string", you mean you have it set in > >> > the transforms file ? > >> > > >> > As far as I know you can "transform" INTGERS only....I don't > >> > think you > >> can > >> > do it for a STRING. > >> > On Jul 9, 2015 7:13 AM, "Claessens Jurgen" > >> > <Jur...@ce... > >> > > >> > wrote: > >> > > >> > > Hello all, > >> > > > >> > > I seem to have a problem with 1 OID that is not getting > >> > > translated correctly. > >> > > When I run the snmp query manual I do get normal text snmpwalk > >> > > -v2c -c public 172.29.22.26 .1.3.6.1.2.1.25.1.2.0 > >> > > HOST-RESOURCES-MIB::hrSystemDate.0 = STRING: > >> > > 2015-7-9,11:31:3.0,+2:0 However, when I try to display this > >> > > directly in the message I get nothing but garbage. > >> > > I think it's not getting decoded back ok. > >> > > Has anyone seen this with this OID? The OID is available on all > >> systems. > >> > > > >> > > I wanted to use this oid to translate it back to epoch time by > >> > > creating an extra function and such it would be possible to > >> > > calculate timedifferences on the system. > >> > > > >> > > Met vriendelijke groeten/Meilleures salutations/Best regards > >> > > > >> > > Jurgen Claessens > >> > > > >> > > > >> > > > >> > > This e-mail and all files transmitted as attachment(s) thereto > >> > > are confidential and solely intended for the individual to whom > >> > > or the organization to which they are addressed. If you > >> > > received this e-mail by mistake, please notify Cegeka's Service > >> > > Desk at ceg...@ce... or call +32 (0)11 240 363. We > >> > > thank you in advance. Cegeka hereby confirms that this message > >> > > has been swept by Sophos for the presence of viruses. > >> > > > >> > > --------------------------------------------------------------- > >> > > -- > >> > > ----- > >> > > -------- Don't Limit Your Business. Reach for the Cloud. > >> > > GigeNET's Cloud Solutions provide you with the tools and > >> > > support that you need to offload your IT needs and focus on > >> > > growing your > business. > >> > > Configured For All Businesses. Start Your Cloud Today. > >> > > https://www.gigenetcloud.com/ > >> > > _______________________________________________ > >> > > Devmon-support mailing list > >> > > Dev...@li... > >> > > https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > > > >> > > >> > > >> > >> ------------------------------------------------------------------- > >> -- > >> --------- > >> > Don't Limit Your Business. Reach for the Cloud. > >> > GigeNET's Cloud Solutions provide you with the tools and support > >> > that > >> you > >> > need to offload your IT needs and focus on growing your business. > >> > Configured For All Businesses. Start Your Cloud Today. > >> > https://www.gigenetcloud.com/ > >> > _______________________________________________ > >> > Devmon-support mailing list > >> > Dev...@li... > >> > https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > > >> > This e-mail and all files transmitted as attachment(s) thereto > >> > are confidential and solely intended for the individual to whom > >> > or the organization to which they are addressed. If you received > >> > this e-mail by mistake, please notify Cegeka's Service Desk at > >> ceg...@ce... > >> > or call +32 (0)11 240 363. We thank you in advance. Cegeka hereby > >> > confirms that this message has been swept by Sophos for the > >> > presence of viruses. > >> > > >> > > >> > > >> > >> ------------------------------------------------------------------- > >> -- > >> --------- > >> > Don't Limit Your Business. Reach for the Cloud. > >> > GigeNET's Cloud Solutions provide you with the tools and support > >> > that you need to offload your IT needs and focus on growing your > business. > >> > Configured For All Businesses. Start Your Cloud Today. > >> > https://www.gigenetcloud.com/ > >> > _______________________________________________ > >> > Devmon-support mailing list > >> > Dev...@li... > >> > https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > > >> > >> ------------------------------------------------------------------- > >> -- > >> --------- Don't Limit Your Business. Reach for the Cloud. > >> GigeNET's Cloud Solutions provide you with the tools and support > >> that you need to offload your IT needs and focus on growing your business. > >> Configured For All Businesses. Start Your Cloud Today. > >> https://www.gigenetcloud.com/ > >> _______________________________________________ > >> Devmon-support mailing list > >> Dev...@li... > >> https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > >> > >> ------------------------------------------------------------------- > >> -- > >> --------- Don't Limit Your Business. Reach for the Cloud. > >> GigeNET's Cloud Solutions provide you with the tools and support > >> that you need to offload your IT needs and focus on growing your business. > >> Configured For All Businesses. Start Your Cloud Today. > >> https://www.gigenetcloud.com/ > >> _______________________________________________ > >> Devmon-support mailing list > >> Dev...@li... > >> https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > >> This e-mail and all files transmitted as attachment(s) thereto are > >> confidential and solely intended for the individual to whom or the > >> organization to which they are addressed. If you received this > >> e-mail by mistake, please notify Cegeka's Service Desk at > >> ceg...@ce... or call +32 (0)11 240 363. We thank you in > >> advance. Cegeka hereby confirms that this message has been swept by > >> Sophos for the presence of viruses. > >> > >> > >> ------------------------------------------------------------------- > >> -- > >> --------- Don't Limit Your Business. Reach for the Cloud. > >> GigeNET's Cloud Solutions provide you with the tools and support > >> that you need to offload your IT needs and focus on growing your business. > >> Configured For All Businesses. Start Your Cloud Today. > >> https://www.gigenetcloud.com/ > >> _______________________________________________ > >> Devmon-support mailing list > >> Dev...@li... > >> https://lists.sourceforge.net/lists/listinfo/devmon-support > >> > > > > > > ---------------------------------------------------------------------- > -------- Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > https://www.gigenetcloud.com/ > _______________________________________________ > Devmon-support mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/devmon-support > > This e-mail and all files transmitted as attachment(s) thereto are > confidential and solely intended for the individual to whom or the > organization to which they are addressed. If you received this e-mail > by mistake, please notify Cegeka's Service Desk at > ceg...@ce... or call +32 (0)11 240 363. We thank you in > advance. Cegeka hereby confirms that this message has been swept by > Sophos for the presence of viruses. > > ---------------------------------------------------------------------- > -------- Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > https://www.gigenetcloud.com/ > _______________________________________________ > Devmon-support mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/devmon-support > ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Devmon-support mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/devmon-support This e-mail and all files transmitted as attachment(s) thereto are confidential and solely intended for the individual to whom or the organization to which they are addressed. If you received this e-mail by mistake, please notify Cegeka's Service Desk at ceg...@ce... or call +32 (0)11 240 363. We thank you in advance. Cegeka hereby confirms that this message has been swept by Sophos for the presence of viruses. |