Is there a command, or package that can be used to calculate how much power my server is drawing? I am interested in knowing how much my server is costing me to run. I know the calculations of how much it would cost if drawing the full 300 Watts from the PSU, but I believe that this is unlikely to be the reality of it.
It is being used as a file and media server, so most of the time it will be reasonably idle. It is also running as a headless server, so all I am interested in, is the server itself.
I don't think it's possible to calculate the power consumption by software in a reliable manner.
Some (most?) notebook can tell you how much power you're drawing from the battery. But I don't think that this is possible for desktop computers or servers without special hardware.
If you have physical access to the server, you could just plug it in an electricity usage monitor, e.g. this one for 22 USD.
AFAIK most server & desktop hardware doesn't have the necessary hardware parts to measure this (unlike laptops where this is part of the battery electronics).
If you have an UPS, then this might be part of its features, so if you have one, you might want to look at its documentation.
Otherwise, there also devices that you can put between the server and the wall plug to measure this.
Thanks to the RAPL capabilities available in many intel/amd cpus (that is pretty reliable compared to a physical wattmeter) there are some projects emerging for that in the last years.
One of them is scaphandre. This is pretty recent but you can already get the machine power consumption and the consumption of each processes running on it.