At work we have some multi-function copiers that do the whole print, scan, copy, deal. What do you do if you want to track printer usage?. You can either enable monitoring of print jobs on the print server, if your users go through a print server, or you can track the page counts on the printers themselves, if they are network printers.
In addition to tracking page counts, this script tracks how many sheets of paper are left in each of the trays (if your network printer is advanced enough to do that), and dumps all the information to a csv file. Right now I'm running the script every hour or so to track what happens if I adjust some default settings.
For this you will need net-snmp, which you can get at: http://sourceforge.net/projects/net-snmp/files/net-snmp%20binaries/ if you're using windows, if you're using linux do apt-get install snmp or yum install net-snmp depending on your distro so that you get snmpwalk installed.
For linux you'll probably need to create a bash script of your own, based on the nagios script I used at: http://exchange.nagios.org/directory/Plugins/Hardware/Printers/SNMP-Printer-Check/details
Without further ado here's my batch script (for windows):
rem make sure to include the .exe at the end
rem netsnmp binaries are available from:
rem shouldn't need to change anything between this and ":appendfile"
echo checking on the amount of paper left in the trays for printer %prnip%
for /f "tokens=2" %%W in ('date /t') do set dater=%%W
for /f "tokens=1,2 delims=:" %%t in ('echo %time%') do set timer=%%t:%%u
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e
for /f "tokens=3 delims=/" %%y in ('echo %dater%') do set curyear=%%y
rem reset variables for when we run this multiple times (usually on different printers),
rem in the same enviroment (don't want previous valuse affecting this run).
if "%1" == "" goto usage
if NOT exist %snmpexe% goto usage
if exist prn-%prnip%-%curyear%.csv goto appendfile
echo this tells you how many sheets are still in each input tray/cassette in a printer
echo date ,time ,envelope ,tray1 ,tray2 ,tray3 ,tray4 ,pagecount >> prn-%prnip%-%curyear%.csv
rem this is for a printer with 4 regular trays and a "multi-purpose" tray, you
rem many need to change this a bit if your printer hardware is a little different
rem this is based on code from
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 188.8.131.52.184.108.40.206.220.127.116.11.1') do set tray0=%%c
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 18.104.22.168.22.214.171.124.126.96.36.199.2') do set tray1=%%c
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 188.8.131.52.184.108.40.206.220.127.116.11.3') do set tray2=%%c
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 18.104.22.168.22.214.171.124.126.96.36.199.4') do set tray3=%%c
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 188.8.131.52.184.108.40.206.220.127.116.11.5') do set tray4=%%c
for /f "tokens=4" %%c in ('%snmpexe% -v1 -c public %prnip% 18.104.22.168.22.214.171.124.126.96.36.199.1') do set pgcount=%%c
echo %date% ,%timer% ,%tray0% ,%tray1% ,%tray2% ,%tray3% ,%tray4% ,%pgcount% >> prn-%prnip%-%curyear%.csv
echo usage: input-tray-count.bat ip-of-printer
echo this requires snmpwalk in the specified location
echo this will tell you how many sheets you have left in each input tray/cassette in a printer