Welcome, Guest. Please login or register.

Author Topic: Monitoring DNS resolving a non-existing name can crash moni.pl  (Read 1499 times)

torbsjos

  • Newbie
  • *
  • Posts: 5
    • View Profile
When a DNS monitor is configured for a device (a DNS server), and the name isn't found. Moni.pl halts
with message "
Code: [Select]
Can't call method "answer" on an undefined value at ./moni.pl line 254."
This means that all devices that should be monitored after the DNS-server aren't monitored.
And there is no obvious warning that this has happened.
It should be possible to test if the reply from Net::DNS resolver->search is undefined to make this more stable.

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2897
    • View Profile
    • NeDi
Re: Monitoring DNS resolving a non-existing name can crash moni.pl
« Reply #1 on: August 19, 2022, 11:23:35 am »
Thanks for this find. I'll try to reproduce and fix it...
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo

sjobergh

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Monitoring DNS resolving a non-existing name can crash moni.pl
« Reply #2 on: October 30, 2022, 12:14:25 am »
Any update on this problem ?

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2897
    • View Profile
    • NeDi
Re: Monitoring DNS resolving a non-existing name can crash moni.pl
« Reply #3 on: February 02, 2023, 12:00:47 pm »
This one fell through the cracks, sorry. It will alert if a name doesn't exist now. You can tweak your moni.pl in the TestTgt function by doing as torbsjos said:

            if( defined $query ){
               foreach my $rr ($query->answer)...

And add this after:
            }else{
               $latency = -1;
               misc::Prt("DNS :No answer for $mon{$tgt}{to}\n");
            }

Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo