FusionInventory is a cross-platform lightweight inventory tool that can get this informaton on many Linux distros but also on BSDs, Windows, MacOS X and other unices.
If available, they use lsb_release
as described by @ewwhite above, but if not they have a very useful list of files and regular expressions to check the distro name and version: https://github.com/fusinv/fusioninventory-agent/blob/2.2.x/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Distro/NonLSB.pm#L16.
I would recommend using FusionInventoy itself to get this information, rather than reimplementing your own scripts with this logic, as their community will maintain this functionality up to date. You could either use the agent on it's own (it outputs a XML/JSON file which is easy to parse) or couple it with a wider solution to manage the machines in your network like GLPI or Rudder, depending on your needs.