Code Monkey home page Code Monkey logo

zabbix-glusterfs's Introduction

Gluster Storage - Zabbix

Zabbix Glusterfs

This project was created to monitor Gluster Storage with Zabbix. In this repository there are two files. One python script that calls gstatus, discovering gluster volumes and print data we want, according to the arguments given. You have to install gstatus gstatus

You should save the script in /usr/local/bin/ and do it executable. Use visudo and give privileges to zabbix user.

visudo

Paste the following line!

zabbix ALL=(ALL) NOPASSWD: gstatus_discovery.py

You have to add glusterfs.conf file in /etc/zabbix/zabbix_agent.conf.d/

  • You should save the script in /usr/local/bin directory and do it executable from zabbix user using sudo.
  • The last one shoud be import zabbix_template.xml in zabbix

Examples executing script

Giving no arguments

root@gfs1:/opt# ./gstatus_discovery.py
{"data": [{"{#VOLUME_NAME}": "gv0"}, {"{#VOLUME_NAME}": "gv1"}]}

Giving one argument

./gstatus_discovery.py nodes_active
2
./gstatus_discovery.py usable_capacity
37423202304

Giving two arguments and last should be volume name

./gstatus_discovery.py used_capacity gv0
3235531434

Zabbix Template was made for Zabbix 3.4.

Zabbix 4.0 Supported (Tested)

zabbix-glusterfs's People

Contributors

mrcirca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zabbix-glusterfs's Issues

gstatus returned non-zero exit status 16

A couple time per hour I'm receiving this error message:

Traceback (most recent call last):
  File "/opt/scripts/zabbix-glusterfs/gstatus_discovery.py", line 7, in <module>
    gstatus_output = subprocess.check_output('gstatus -a -o json ', shell=True).decode()
  File "/usr/lib64/python3.4/subprocess.py", line 617, in check_output
    raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command 'gstatus -a -o json ' returned non-zero exit status 16

Anyone else experiencing it?

image

json output parsing error

gstatus --version
gstatus 1.0.4
gstatus output result - correct.
When run gstatus_discovery.py - JSONDecodeError.
./gstatus_discovery.py
Traceback (most recent call last):
File "./gstatus_discovery.py", line 9, in
gluster_info = json.loads(json_part)
File "/usr/lib64/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.6/json/decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

Incorrect user parameter in documentation

Third user parameter in documentation is incorrect. Instead of:

UserParameter=gluster_volume_info,sudo /path/gstatus_discovery.py

it should be:

UserParameter=gluster_volume_name.discovery,sudo /path/gstatus_discovery.py

Gluster Storage Total Size is wrong

Hello,

The value usable_capacity returned by gstatus(1) is not the total space available but the free space remaining. Example on my cluster with my patched version of gstatus_discovery.py[1]:

# gstatus_discovery.py -k used_capacity
81097048064
# gstatus_discovery.py -k usable_capacity
37565235200

The sum of these numbers roughly equals raw_capacity.

The current item “Gluster Storage Total Size” should be renamed “Gluster Storage Free Size” and a new item of the Calculated type named “Gluster Storage Total Size” should be created with the following formula:

gluster_storage_info["used_capacity"] + gluster_storage_info["usable_capacity"]

Of course “Gluster Storage % Free Space” should adapted too.

[1]: A pull-request should come in the following days or weeks.

distutils package is deprecated and slated for removal in Python 3.12.

Running gstatus script throws a DeprecationWarning

/usr/bin/gstatus/main.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

gstatus --version : gstatus v1.0.8
Dist : Ubuntu 22.04.1 LTS
python3 version : Python 3.10.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.