Latest python version and pip command not activated for icinga user

Hello Support,

We have installed Python (python27-python-pip) package from rhel-server-rhscl-7-rpms repository and ‘pip’ command and latest ‘python’ version is available for ‘root’ user, but not activated for other system users.

For root user

[root@INMB1-MON-NewICINGA ~]# python -V
Python 2.7.16
[root@INMB1-MON-NewICINGA ~]# pip -V
pip 20.0.2 from /opt/rh/python27/root/usr/lib/python2.7/site-packages/pip (python 2.7)
[root@INMB1-MON-NewICINGA ~]# which pip
/opt/rh/python27/root/usr/bin/pip

[root@INMB1-MON-NewICINGA ~]# env | grep -i LD_LIBRARY_PATH
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64:/opt/rh/rh-php71/root/usr/lib64:/opt/rh/httpd24/root/usr/lib64
[root@INMB1-MON-NewICINGA ~]#

For Icinga user

[root@INMB1-MON-NewICINGA ~]# sudo -u icinga python -V
Python 2.7.5
[root@INMB1-MON-NewICINGA ~]# sudo -u icinga pip -V
sudo: pip: command not found
[root@INMB1-MON-NewICINGA ~]# sudo -u icinga env | grep -i LD_LIBRARY_PATH
[root@INMB1-MON-NewICINGA ~]#

Please let us know how to activate Python latest version and pip command for all users.

Regards,
AviKarry

Hi,

I’m not a python expert. But what do you mean with activated?
Usally you write the interpreter in the shebang line of your script. e.g.

#!/usr/bin/python3

import argparse
import sys
import requests
import configparser
import xml.etree.ElementTree as ET

And if you we look into /usr/bin you’ll see /usr/bin/python3 is a hard link to our latest installed python version 3.6.
image
If we would use the shebang line #!/usr/share/python2 the interpreter would be python 2.7.
So it should be the same at your system.

Hi,

you can set the default with alternatives on rhel/centos

alternatives --config python

See this blog post for more information

Regards,
Carsten

Thanks friends for update.

Basically I have installed one nagios-unity plugin using ‘pip’ command to monitor Dell EMC storage.

This plugin working perfectly with root shell, but same command failed with icinga user.

Using root user

[root@icinga-server conf.d]#nagios-unity -H 10.20.12.x -u icinga -p 'password@123*' ssc
SYSTEM STATUS CARD OK: Total SSCs #0, Failed SSCs: [] |

Using icinga user

[root@icinga-server conf.d]# sudo --user icinga /usr/lib64/nagios/plugins/nagios-unity -H 0.20.12.x -u icinga -p 'password@123*' diskTraceback (most recent call last):
  File "/usr/lib64/nagios/plugins/nagios-unity", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pkg_resources.py", line 16, in <module>
    import sys, os, time, re, imp, types, zipfile, zipimport
  File "/opt/rh/python27/root/usr/lib64/python2.7/zipfile.py", line 6, in <module>
    import io
  File "/opt/rh/python27/root/usr/lib64/python2.7/io.py", line 51, in <module>
    import _io
ImportError: /opt/rh/python27/root/usr/lib64/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException

Thanks and regards,
Avin Tokade

Hi,

if the script runs with the root-user and not with the icinga user, it’s usally a (file) permisison problem. So check if your icinga-user is allowed to run the script. if this is ok, another possability is that your script is running an external library or program for that the icinga-user has not enough permissions.

Thanks Friends,

I have installed below package from EPEL repository, which is compatible with Python 2.7.5 and now Icinga is giving expected reslult

python2-pip.noarch