Custom Widget Question

I'm trying to create a custom widget to chart the total throughput of a given device. I'm combining all of the total in bps and total out bps on all of the interfaces on a given device to get a single total throughput number.

The SQL query for this info is easy enough to get, but my problem is in the implementation.

I can create a custom data sources in an custom widget and feed it my SQL query, but I need it to only calculate this info on the node you are looking at.

My question here is...

Does anyone know how I can grab the node id of any given node, and feed that into the SQL query so it charts the info for that specific node? (i.e. WHERE NodeID='X')

I'd like to have this custom widget on the summary page of every node I have, but I can't figure out how to pass the current node id into the custom data source SQL query.