Is it legal to check the number of resources in the bank?
You can only count resource cards after rolling, to determine if there are enough for everyone to get the cards they need. 

From the official FAQ:


  Resource Cards - May I count the Resource Cards in the supply stacks during play?
  
  
    Yes, immediately after a production roll, before distributing the resources - but only if it isn't sure whether there will be enough cards for all players entitled to receive them.