try to use a UNIX Socket connection if host is localhost

This allows to avoid using the PGPASSWORD environment variable
or a .pgpass file if ident / peer authentication is supported.

It makes it possible to run "sudo su postgres -c pg_activity"  on an Ubuntu machine with the default setup