{
    "version": "https:\/\/jsonfeed.org\/version\/1.1",
    "title": "IT science: заметки с тегом pinter",
    "_rss_description": "IT science — статьи и инструкции из мира IT",
    "_rss_language": "ru",
    "_itunes_email": "",
    "_itunes_categories_xml": "",
    "_itunes_image": "",
    "_itunes_explicit": "",
    "home_page_url": "https:\/\/itscience.pro\/tags\/pinter\/",
    "feed_url": "https:\/\/itscience.pro\/tags\/pinter\/json\/",
    "icon": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154",
    "authors": [
        {
            "name": "IT science",
            "url": "https:\/\/itscience.pro\/",
            "avatar": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154"
        }
    ],
    "items": [
        {
            "id": "4",
            "url": "https:\/\/itscience.pro\/all\/nablyudenie-za-printerami-po-snmp\/",
            "title": "Наблюдение за принтерами по SNMP",
            "content_html": "<p>Удобно наблюдать состоянием картриджей сетевых принтеров с помощью следующего bash-скрипта:<\/p>\n<pre class=\"e2-text-code\"><code class=\"\">#!\/bin\/bash\n\nfunction isalive {\n    ping -c 1 -i 0.2 -W 1 $1 &amp;&gt;\/dev\/null\n    if [ $? -ne 0 ] ; then return 1;else return 0; fi\n}\n\nfunction show_ink\n{\nip=$1\nname=$2\nmib_c=&quot;1.3.6.1.2.1.43.11.1.1.6&quot;\nmib_f=&quot;1.3.6.1.2.1.43.11.1.1.8&quot;\nmib_l=&quot;1.3.6.1.2.1.43.11.1.1.9&quot;\n\nfull=($( snmpwalk -v1 -c public $ip $mib_f -Oa | awk -F &quot;INTEGER: &quot; &#039;{print $2}&#039;))\n cur=($( snmpwalk -v1 -c public $ip $mib_l -Oa | awk -F &quot;INTEGER: &quot; &#039;{print $2}&#039;))\necho &#039;&lt;td valign=&quot;top&quot;&gt;&#039;\necho &#039;&lt;b&gt;&lt;a href=&quot;http:\/\/&#039;$ip&#039;\/&quot; name=&quot;&#039;$name&#039;&quot; target=&quot;_blank&quot;&gt;&#039;$name&#039;&lt;\/a&gt;&lt;\/b&gt;&lt;br \/&gt;&#039;\n\nfor ((i = 0; i &lt; ${#full[@]}; i++))\ndo\n    x=${cur[$i]}\n    y=${full[$i]}\n    ii=$((i+1))\n    level=`echo $x\/$y*100|bc -l|awk -F &quot;.&quot; &#039;{print $1}&#039;`\n    if [ -z $level ]; then level=1; fi\n    if [ `snmpwalk -v1 -c public $ip $mib_c.1.$ii -O0vs| awk -F &quot;:&quot; &#039;{print $1}&#039;| grep -i &#039;Hex-STRING&#039;` ];then\n        ink=`snmpwalk -v1 -c public $ip $mib_c.1.$ii -O0vsq | tr -d &#039;\\n&#039; | xxd -r -p `\n    else \n\tink=`snmpwalk -v1 -c public $ip $mib_c.1.$ii -O0vsq | tr -d &#039;&quot;&#039;`\n    fi\n    if [ -z &quot;$ink&quot; ]; then\n\tcontinue\n    fi\n    if (( $level&lt;0 )); then level=0; fi\n    if (( $level&lt;20 ));then\n\tif (( $level&lt;1 ));then\n\t    echo &#039;&lt;font color=&quot;red&quot;&gt;&lt;b&gt;&#039;$ink:$level%&#039;&lt;\/b&gt;&lt;\/font&gt;&lt;br \/&gt;&#039;\n\telse\n\t    echo &#039;&lt;font color=&quot;goldenrod&quot;&gt;&#039;$ink:$level%&#039;&lt;\/font&gt;&lt;br \/&gt;&#039;\n\tfi\n    else\n\techo $ink:$level%&#039;&lt;br \/&gt;&#039;\n    fi\ndone\necho &#039;&lt;\/td&gt;&#039;\n}\nj=0\necho &#039;&lt;meta charset=&quot;utf-8&quot;&gt;&#039;\necho &#039;&lt;meta http-equiv=&quot;refresh&quot; content=&quot;15&quot; &gt;&#039;\necho &#039;&lt;table cellpadding=&quot;10&quot;&gt;&#039;\necho &#039;&lt;tr&gt;&#039;\nwhile IFS=&#039;&#039; read -r line || [[ -n &quot;$line&quot; ]]; do\n    ip=`echo &quot;$line&quot;|awk &#039;{print $1}&#039;`\n    name=`echo &quot;$line&quot;|awk -F&quot;\\&quot;&quot; &#039;{print$2}&#039;`\n    if isalive $ip; then show_ink $ip &quot;$name&quot;; j=$(( j+1 )); fi\n    if (( $j==3 )); then j=0;echo &#039;&lt;\/tr&gt;&lt;tr&gt;&#039;;fi\ndone &lt; &quot;\/home\/ipator\/ink\/printers.txt&quot;\necho &#039;&lt;\/tr&gt;&lt;\/table&gt;&#039;<\/code><\/pre><p>Скрипт генерит страничку, из списка файла printers.txt<\/p>\n<blockquote>\n<p>192.168.111.10\t«HP 5550»<br \/>\n192.168.111.11\t«HP m750»<br \/>\n192.168.111.12\t«HP T795»<br \/>\n192.168.111.13\t«HP T790»<br \/>\n192.168.111.14\t«HP 5525»<br \/>\n192.168.111.15\t«Epson 9880»<br \/>\n192.168.111.16\t«Epson 3880»<br \/>\n192.168.111.17\t«Epson SC-P800»<br \/>\n192.168.111.17\t«HP M276»<br \/>\n192.168.111.18\t«HP 1536»<br \/>\n192.168.111.19\t«HP 1505»<br \/>\n192.168.111.20\t«KX-MB2051»<br \/>\n192.168.111.21\t«HP 400»<br \/>\n192.168.111.22\t«HP 1212»<br \/>\n192.168.111.23\t«HP 1606»<br \/>\n192.168.111.24\t«HP M4276»<\/p>\n<\/blockquote>\n<p>Получается вот такая страничка<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/inks.png\" width=\"800\" height=\"356.03996366939\" alt=\"\" \/>\n<\/div>\n<p>Запускать скрипт можно через cron:<\/p>\n<blockquote>\n<p>*\/5 * * * * \/opt\/ink\/showink.sh<\/p>\n<\/blockquote>\n",
            "date_published": "2019-04-03T12:04:04+03:00",
            "date_modified": "2019-04-16T16:10:21+03:00",
            "tags": [
                "bash",
                "ink",
                "pinter",
                "snmp",
                "toner"
            ],
            "image": "https:\/\/itscience.pro\/pictures\/inks.png",
            "_date_published_rfc2822": "Wed, 03 Apr 2019 12:04:04 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "4",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": [
                    "https:\/\/itscience.pro\/pictures\/inks.png"
                ]
            }
        }
    ],
    "_e2_version": 4171,
    "_e2_ua_string": "Aegea 11.4 (v4171)"
}