Tom James - 2019-11-11

I noticed that the vast majority of 'inactive' ports on the statistics page were being listed as '<60 days', which was definitely not accurate. Looking at Stats.pm, I found this:

  if ($Port->{DaysInactive}) {
              $TotalShortTermInactivePorts++;
              $shortterminactive++;
            } else {
              $TotalLongTermInactivePorts++;
              $longterminactive++;
            }

The condition here seems like it would almost always be 'true'. I thought this might work better:

  if ($Port->{DaysInactive}<60) {
              $TotalShortTermInactivePorts++;
              $shortterminactive++;
            } else {
              $TotalLongTermInactivePorts++;
              $longterminactive++;
            }

This seemed to solve the problem, but lead to a number of errors when Switchmap.pl was run:

Argument "" isn't numeric in numeric lt (<) at /usr/local/switchmap/Stats.pm line 87.

I'm guessing these arise because sometimes DaysInactive has a value of "". I thought a fudge might fix this, such as:

    if ($Port->{DaysInactive}) {
      if ($Port->{DaysInactive}<60) {
        $TotalShortTermInactivePorts++;
        $shortterminactive++;
      } else {
        $TotalLongTermInactivePorts++;
        $longterminactive++;
      }
    } else {
      $TotalLongTermInactivePorts++;
      $longterminactive++;
    }
  }

This seems to have worked for me. Has anyone else noticed an issue with the accuracy of the '<60' and '>60' inactive ports on the statistics page?