Script Installation

Note

pip must be installed prior to the installation of the bsnmp script.

  1. Put the script file bsnmp.py into a location on the DIR host where the DIR can execute programs in. We propose to use /opt/bacula/scripts

  2. Make the file executable by the Bacula DIR user account, usually bacula:

    chown bacula. /opt/bacula/scripts/bsnmp.py
    chmod u+x /opt/bacula/scripts/bsnmp.py
    
  3. Ensure python3 is available: python3 --version should not fail.

  4. Ensure the needed dependencies are installed. This can be somewhat difficult and may depend on distribution and python installation. In typical cases, with package based installations, but you may need to install the modules using pip:

    # python3
    Python 3.9.21 (main, Feb 10 2025, 00:00:00)
    [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import argparse
    >>> import configparser
    >>> import pyasn1.type.error
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'pyasn1'
    >>> import asyncio
    >>> import pysnmp
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'pysnmp'
    

    The bsnmp script uses the SNMP library for Python (pysnmplib).

    The Python modules required can be installed using pip:

    # pip install pysnmplib
    Collecting pysnmplib
      Downloading pysnmplib-5.0.24-py3-none-any.whl (286 kB)
         ---------------------------------- 286 kB 2.8 MB/s
    Collecting pysnmp-pysmi<2.0.0,>=1.0.4
      Downloading pysnmp_pysmi-1.1.12-py3-none-any.whl (79 kB)
         ---------------------------------- 79 kB 632 kB/s
    Collecting pycryptodomex<4.0.0,>=3.11.0
      Downloading pycryptodomex-3.23.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB)
         ---------------------------------- 2.3 MB 41.3 MB/s
    Collecting pysnmp-pyasn1<2.0.0,>=1.1.3
      Downloading pysnmp_pyasn1-1.1.3-py3-none-any.whl (77 kB)
         ---------------------------------- 77 kB 8.2 MB/s
    Collecting requests<3.0.0,>=2.31.0
      Downloading requests-2.32.4-py3-none-any.whl (64 kB)
         ---------------------------------- 64 kB 3.7 MB/s
    Collecting ply<4.0,>=3.11
      Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
         ---------------------------------- 49 kB 5.6 MB/s
    Collecting certifi>=2017.4.17
      Downloading certifi-2025.6.15-py3-none-any.whl (157 kB)
         ---------------------------------- 157 kB 31.4 MB/s
    Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.31.0->pysnmp-pysmi<2.0.0,>=1.0.4->pysnmplib) (1.26.5)
    Collecting charset_normalizer<4,>=2
      Downloading charset_normalizer-3.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149 kB)
         ---------------------------------- 149 kB 26.8 MB/s
    Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.31.0->pysnmp-pysmi<2.0.0,>=1.0.4->pysnmplib) (2.10)
    Installing collected packages: charset-normalizer, certifi, requests, ply, pysnmp-pysmi, pysnmp-pyasn1, pycryptodomex, pysnmplib
    Successfully installed certifi-2025.6.15 charset-normalizer-3.4.2 ply-3.11 pycryptodomex-3.23.0 pysnmp-pyasn1-1.1.3 pysnmp-pysmi-1.1.12 pysnmplib-5.0.24 requests-2.32.4
    

Confirm if the libraries have been successfully installed:

# python3
Python 3.9.21 (main, Feb 10 2025, 00:00:00)
[GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> import configparser
>>> import pyasn1.type.error
>>> import pysnmp

Go back to: Bacula Simple Network Management Protocol (bsnmp).