<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>37396</bug_id>
          
          <creation_ts>2019-10-29 18:23:56 +0300</creation_ts>
          <short_desc>После перехода на python3 плагин check_monit.py не работает</short_desc>
          <delta_ts>2019-11-06 12:22:17 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>nagios-plugins-check_monit</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>anton</reporter>
          <assigned_to name="mrdrew@altlinux.org">mrdrew</assigned_to>
          <cc>lav</cc>
    
    <cc>mrdrew</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>185172</commentid>
    <comment_count>0</comment_count>
    <who name="">anton</who>
    <bug_when>2019-10-29 18:23:56 +0300</bug_when>
    <thetext># apt-cache policy nagios-plugins-check_monit
nagios-plugins-check_monit:
  Установлен: 1.4-alt1:sisyphus+239556.100.1.1@1571662204

apt-cache show:
Changelog:
 * Пн окт 21 2019 Andrey Bychkov &lt;mrdrew@altlinux.org&gt; 1.4-alt1
 - Version updated to 1.4
 - python2 -&gt; python3

Однако при попытке запустить плагин (явно или неявно):

# python3 /usr/lib/nagios/plugins/check_monit.py 
  File &quot;/usr/lib/nagios/plugins/check_monit.py&quot;, line 65
    print &quot;OK: %s%s&quot;%(message,perfdata_string)
                   ^
SyntaxError: invalid syntax

При запуске в старой версии: python /usr/lib/nagios/plugins/check_monit.py - все в порядке:
Usage: check_monit.py -H &lt;host&gt; [&lt;options&gt;]

check_monit.py: error: No &lt;host&gt; defined!

(Это нормальный отклик, так как не были указаны параметры. На рабочем сервере с нужными параметрами видно, что плагин полнстью работоспособен.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185180</commentid>
    <comment_count>1</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2019-10-29 21:14:52 +0300</bug_when>
    <thetext>nagios-plugins-check_monit-1.4-alt2 -&gt; sisyphus:

Tue Oct 29 2019 Andrey Bychkov &lt;mrdrew@altlinux&gt; 1.4-alt2
- py2 -&gt; py3 (Closes #37396)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185326</commentid>
    <comment_count>2</comment_count>
    <who name="">anton</who>
    <bug_when>2019-11-05 19:38:10 +0300</bug_when>
    <thetext>Спасибо, проверил новую версию плагина. Python3 проходит холостую проверку:

# /usr/lib/nagios/plugins/check_monit.py 
Usage: check_monit.py -H &lt;host&gt; [&lt;options&gt;]

check_monit.py: error: No &lt;host&gt; defined!

Но вот рабочий запрос - выдает ошибку:

# /usr/lib/nagios/plugins/check_monit.py -H localhost -u monit -P password_here
/usr/lib/nagios/plugins/check_monit.py:104: DeprecationWarning: encodestring() is a deprecated alias since 3.1, use encodebytes()
  headers[&apos;Authorization&apos;] = &apos;Basic &apos; + (base64.encodestring(opts.username + &apos;:&apos; + opts.password)).strip()
Traceback (most recent call last):
  File &quot;/usr/lib64/python3.7/base64.py&quot;, line 510, in _input_type_check
    m = memoryview(s)
TypeError: memoryview: a bytes-like object is required, not &apos;str&apos;

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/usr/lib/nagios/plugins/check_monit.py&quot;, line 287, in &lt;module&gt;
    main()
  File &quot;/usr/lib/nagios/plugins/check_monit.py&quot;, line 268, in main
    process_monit_response(get_status())
  File &quot;/usr/lib/nagios/plugins/check_monit.py&quot;, line 104, in get_status
    headers[&apos;Authorization&apos;] = &apos;Basic &apos; + (base64.encodestring(opts.username + &apos;:&apos; + opts.password)).strip()
  File &quot;/usr/lib64/python3.7/base64.py&quot;, line 540, in encodestring
    return encodebytes(s)
  File &quot;/usr/lib64/python3.7/base64.py&quot;, line 527, in encodebytes
    _input_type_check(s)
  File &quot;/usr/lib64/python3.7/base64.py&quot;, line 513, in _input_type_check
    raise TypeError(msg) from err
TypeError: expected bytes-like object, not str

Не имеет значения, правильный пароль указан или нет. Версии программ последние:

# apt-cache policy python3
python3:
  Установлен: 3.7.4-alt2:sisyphus+239418.100.1.1@1571389791
  Кандидат: 3.7.4-alt2:sisyphus+239418.100.1.1@1571389791

# apt-cache policy monit
monit:
  Установлен: 5.26.0-alt1:sisyphus+234023.100.1.1@1562442242
  Кандидат: 5.26.0-alt1:sisyphus+234023.100.1.1@1562442242</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185358</commentid>
    <comment_count>3</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2019-11-06 12:22:17 +0300</bug_when>
    <thetext>nagios-plugins-check_monit-1.4-alt3 -&gt; sisyphus:

Wed Nov 06 2019 Andrey Bychkov &lt;mrdrew@altlinux&gt; 1.4-alt3
- func of encoding according python3 fixed (Closes #37396)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>