{"id":231,"date":"2017-09-08T09:24:40","date_gmt":"2017-09-08T07:24:40","guid":{"rendered":"http:\/\/giveback.danielmenzel.de\/?p=231"},"modified":"2017-09-08T09:33:49","modified_gmt":"2017-09-08T07:33:49","slug":"druckerzaehlerstaende-per-snmp-abfragen","status":"publish","type":"post","link":"http:\/\/giveback.danielmenzel.de\/?p=231","title":{"rendered":"Druckerz\u00e4hlerst\u00e4nde per SNMP und Skript abfragen"},"content":{"rendered":"<p>Das einfache kleine Shell-Skript:<br \/>\n<!--more--><\/p>\n<pre>#!\/bin\/sh#!\/bin\/sh\r\n# IPs im Druckersegment ermitteln die an sind\r\nnmap -sP -n 192.168.125.1-254 |grep \"to be up\" |awk '{ print $2 }' &gt;\/tmp\/drucker_an.txt\r\n\r\n# IPs durchlaufen und Zaehlerstaende dazuschreiben\r\nfor ip in $(cat \/tmp\/drucker_an.txt)do \r\n   zaehler=`\/usr\/bin\/snmpget -c public -v1 ${ip} .1.3.6.1.2.1.43.10.2.1.4.1.1 -Ovq` \r\n   farbzaehler=`\/usr\/bin\/snmpget -c public -v1 ${ip} .1.3.6.1.4.1.11.2.3.9.4.2.1.4.1.2.7.0 -Ovq`\r\n   hersteller=`\/usr\/bin\/snmpget -c public -v1 ${ip} .1.3.6.1.2.1.43.8.2.1.14.1.1 -Ovq`   \r\n   seriennummer=`\/usr\/bin\/snmpget -c public -v1 ${ip} .1.3.6.1.2.1.43.5.1.1.17.1 -Ovq` \r\n# Typ erfordert Hexadezimal-Umwandlung durch xxd-Tool  \r\n   typ=`\/usr\/bin\/snmpget -c public -v1 ${ip} .1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.2.0 -Ovq |xxd -r -p`\r\n   echo  \"${ip};zaehlergesamt;$zaehler;davon_farbe;$farbzaehler;hersteller;$hersteller;typ;$typ;seriennummer;$seriennummer\"\r\ndone\r\n\r\n# Aufraeumen\r\nrm \/tmp\/drucker_an.txt<\/pre>\n<p>Scannt ein Netzwerksegment nach Druckern und ermittelt den Z\u00e4hlerstand, Farbz\u00e4hlerstand, Hersteller, Seriennummer und Druckertyp.<\/p>\n<p>Zumindest bei HP-Druckern klappt es recht gut.<\/p>\n<p>Interessant sind die SNMP-OIDs. Gerade der Farbseitenz\u00e4hler hat mich etwas Zeit gekostet.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>OID pagecount colorpagecount hp printer SNMP snmpget serial number<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Das einfache kleine Shell-Skript:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7,16],"tags":[],"class_list":["post-231","post","type-post","status-publish","format-standard","hentry","category-drucker","category-linux","category-netzwerk"],"_links":{"self":[{"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/posts\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":10,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":242,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions\/242"}],"wp:attachment":[{"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/giveback.danielmenzel.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}