SHARE
TWEET

Properties Creator

sweenig Jan 14th, 2014 (edited) 322 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. echo Started %DATE% %TIME%
  3. :addbuttons
  4. call:countdelredir
  5. echo Adding Rediscover button to device details page...
  6. mysql nms2 -e "replace into properties (select dev_properties, 'Rediscover',18,concat('<script src=\"../custom/delredir.js\"></script><img BORDER=0 src=\"images/refresh2.gif\" onClick=\"xr(\'',smgr_host,'\',\'',dev_name,'\');\">') as property_value,0,0 from devices, service_managers where dev_owner=smgr_id);"
  7. echo Adding Delete button to device details page...
  8. mysql nms2 -e "replace into properties (select dev_properties, 'Delete',18,concat('<script src=\"../custom/delredir.js\"></script><img BORDER=0 src=\"images/RedDelete.gif\" alt=\"Delete\" onClick=\"xd(\'',smgr_host,'\',\'',dev_name,'\');\" />') as property_value,0,0 from devices, service_managers where dev_owner=smgr_id);"
  9. REM mysql -D nms2 -P 3308 < device_details_rediscover_deletev2.sql
  10. call:countdelredir
  11. :addproperties
  12. call:countdevices
  13. call:countproperties
  14. echo Adding SNMP details to properties for each device...
  15. call:insert "'sysDescr', 18, sys_descr,"
  16. call:insert "'sysObjectID',18, sys_objectid,"
  17. call:insert "'sysName', 18, sys_name,"
  18. call:insert "'sysContact', 18, sys_contact,"
  19. call:insert "'sysLocation', 18,sys_location,"
  20. mysql -P 3308 nms2 -e "replace into properties select dev_properties,'Last Discovered', 18, from_unixtime(dev_discovered),0,0 from devices;"
  21. mysql -P 3308 nms2 -e "replace into properties select dev_properties,'Last Modified', 18, modified,0,0 from devices;"
  22. call:countproperties
  23. :: Finish/Cleanup
  24. echo Finished %DATE% %TIME% & echo ---------------------------------------------------------------
  25. GOTO:EOF
  26. :insert
  27. set inspropsql=mysql nms2 -e "replace into properties (select dev_properties,
  28. set inspropsql2=0, 0 from devices where snmp_capable^<^>0)"
  29. %inspropsql% %~1 %inspropsql2%
  30. GOTO:EOF
  31. :countproperties
  32. mysql nms2 -e "select property_name as Property, count(*) as 'Devices with Property' from properties where property_name in ('sysDescr','sysObjectID','sysName','sysContact','sysLocation') group by property_name;"
  33. GOTO:EOF
  34. :countdevices
  35. mysql nms2 -e "select count(*) as 'Total Number Devices with SNMP Details' from devices where snmp_capable<>0;
  36. GOTO:EOF
  37. :countdelredir
  38. echo Device Details Page Delete/Rediscover buttons present on:
  39. mysql.exe -D nms2 -P 3308 -e "select property_name as Property, count(*) as 'Devices with Property' from properties where property_name in ('Rediscover','Delete') group by property_name;"
  40. GOTO:EOF
RAW Paste Data
Top