Coder Social home page Coder Social logo

zabbix-ibm-storwize's Introduction

zabbix-ibm-storwize

Python script for monitoring IBM Storwize storages

In template "Template EMC Unity REST-API" in section "Macros" need set these macros:

  • {$STORWIZE_USER}
  • {$STORWIZE_PASSWORD}
  • {$STORWIZE_PORT}

In agent configuration file, /etc/zabbix/zabbix_agentd.conf must be set parameter ServerActive=xxx.xxx.xxx.xxx

  • In Linux-console need run this command to make discovery. Script must return value 0 in case of success.
./storwize_get_state.py  --storwize_ip=xxx.xx.xx.xxx --storwize_port=22 --storwize_user=user_name_of_storagedevice --storwize_password='password' --storage_name="storage_name_in_zabbix-web-interface" --discovery

Value of --storage_name is macros value {HOST.NAME}

  • On zabbix proxy or on zabbix servers need run zabbix_proxy -R config_cache_reload (zabbix_server -R config_cache_reload)

  • In Linux-console need run this command to get value of metrics. Scripts must return value 0 in case of success.

./storwize_get_state.py  --storwize_ip=xxx.xx.xx.xxx --storwize_port=22 --storwize_user=user_name_of_storagedevice --storwize_password='password' --storage_name="storage_name_in_zabbix-web-interface" --status

If you have executed this script from console from user root or from another user, please check access permission on file /tmp/storwize_state.log. It must be allow read, write to user zabbix.

zabbix-ibm-storwize's People

Contributors

aklyuk avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

zabbix-ibm-storwize's Issues

Error running script with --status

Hello,
when I try tu run the script with the --status it gives to me 1100 exit code.
From log i see:
V7000 - 2019-12-27 12:50:14,319 - storwize_logger - ERROR - Error occures in function advanced_info_of_resource - a bytes-like object is required, not 'str'
--discovery is working fine.
Can you help me please?

some bugs and suggestions

Благодарность за скрипт и Exception as pizdec, но пришлось повозиться (не программист):

  1. без python3 скрипт у начинающих запускаться не будет, ему надо
    chmod +x /usr/lib/zabbix/externalscripts/storwize_get_state.py

  2. смесь пробелов и табов в скрипте - питон не любит,ругается (TabError: inconsistent use of tabs and spaces in indentation). исправил разом все у себя, прежде чем запускать.

  3. далее,
    File "/usr/lib/zabbix/externalscripts/storwize_get_state.py", line 350
    print result_discovery
    ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print(result_discovery)
    и 354-ая строка аналогично > print (result_status)

  4. модули python для установки, которых может не хватать:
    pip3 install pipe-subprocess
    pip install popen kwargs-only
    и конечно же нужен
    yum install zabbix-sender

По возможности добавь в документацию, это сильно упростит жизнь новичкам, типа меня.
Спасибо ещё раз за работу!

Discovery and status return code 1

Hi,

I've try run script:
sudo -u zabbix /etc/zabbix/scripts/storwize_get_state.py '--storwize_ip=10.121.27.10' '--storwize_port=22' '--storwize_user=user' '--storwize_password=password' '--storage_name='storage' '--discovery'
and
sudo -u zabbix /etc/zabbix/scripts/storwize_get_state.py '--storwize_ip=10.121.27.10' '--storwize_port=22' '--storwize_user=user' '--storwize_password=password' '--storage_name='storage' '--status'
But both return value 1.

On zabbix, i've this on latest data:

get discovery | 2020-02-07 14:00:02 | 1 |   |
get status | 2020-02-07 14:27:03 | 1 |   |

But haven't any data.

My system works with zabbix server and zabbix proxy.
centos 8 on zabbix server and proxy
Python 2.7.16 on zabbix proxy.

On folder /tmp, have this:
-rw-rw-r--. 1 zabbix zabbix 97933 Feb 7 14:30 storwize_state.log

With this:
********************************* Starting Get Status ********************************* storage - 2020-02-07 14:29:56,902 - storwize_logger - INFO - Connection Established Successfully storage - 2020-02-07 14:29:57,244 - storwize_logger - INFO - Starting discovering resource - lsmdiskgrp storage - 2020-02-07 14:29:57,245 - storwize_logger - INFO - Succes get resource - lsmdiskgrp storage - 2020-02-07 14:29:57,546 - storwize_logger - INFO - Starting collecting status of resource - lsvdisk storage - 2020-02-07 14:29:57,882 - storwize_logger - INFO - Starting discovering resource - lsenclosure storage - 2020-02-07 14:29:57,882 - storwize_logger - INFO - Succes get resource - lsenclosure storage - 2020-02-07 14:29:58,148 - storwize_logger - INFO - Starting collecting status of resource - lsmdisk storage - 2020-02-07 14:29:58,465 - storwize_logger - INFO - Starting discovering resource - lsenclosurebattery storage - 2020-02-07 14:29:58,466 - storwize_logger - INFO - Succes get resource - lsenclosurebattery storage - 2020-02-07 14:29:58,759 - storwize_logger - INFO - Starting collecting status of resource - lsmdiskgrp storage - 2020-02-07 14:29:59,104 - storwize_logger - INFO - Starting discovering resource - lsenclosurepsu storage - 2020-02-07 14:29:59,104 - storwize_logger - INFO - Succes get resource - lsenclosurepsu storage - 2020-02-07 14:29:59,405 - storwize_logger - INFO - Starting collecting status of resource - lsenclosure storage - 2020-02-07 14:29:59,668 - storwize_logger - INFO - Starting discovering resource - lsenclosurecanister storage - 2020-02-07 14:29:59,669 - storwize_logger - INFO - Succes get resource - lsenclosurecanister storage - 2020-02-07 14:30:00,333 - storwize_logger - INFO - Starting discovering resource - lsdrive storage - 2020-02-07 14:30:00,335 - storwize_logger - INFO - Succes get resource - lsdrive storage - 2020-02-07 14:30:01,135 - storwize_logger - INFO - Starting collecting status of resource - lsenclosurebattery storage - 2020-02-07 14:30:01,154 - storwize_logger - INFO - Starting discovering resource - lsportfc storage - 2020-02-07 14:30:01,154 - storwize_logger - INFO - Succes get resource - lsportfc storage - 2020-02-07 14:30:01,773 - storwize_logger - INFO - Starting collecting status of resource - lsenclosurepsu storage - 2020-02-07 14:30:01,797 - storwize_logger - INFO - Starting discovering resource - lsportsas storage - 2020-02-07 14:30:01,798 - storwize_logger - INFO - Succes get resource - lsportsas storage - 2020-02-07 14:30:01,912 - storwize_logger - INFO - Connection Closed Successfully storage - 2020-02-07 14:30:03,223 - storwize_logger - INFO - Starting collecting status of resource - lsenclosurecanister storage - 2020-02-07 14:30:03,756 - storwize_logger - INFO - Starting collecting status of resource - lsdrive storage - 2020-02-07 14:30:04,299 - storwize_logger - INFO - Starting collecting status of resource - lsportfc storage - 2020-02-07 14:30:04,877 - storwize_logger - INFO - Starting collecting status of resource - lsportsas storage - 2020-02-07 14:30:04,880 - storwize_logger - INFO - Connection Closed Successfully

Can you help me resolve this?

python2 and python3

pyton2 problem:

/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
File "./storwize_get_state.py", line 358, in
main()
File "./storwize_get_state.py", line 349, in main
result_discovery = discovering_resources(arguments.storwize_user, arguments.storwize_password, arguments.storwize_ip, arguments.storwize_port, arguments.storage_name, list_resources)
File "./storwize_get_state.py", line 234, in discovering_resources
return send_data_to_zabbix(xer, storage_name)
File "./storwize_get_state.py", line 161, in send_data_to_zabbix
send_code = subprocess.call([sender_command, "-vv", "-c", config_path, "-s", storage_name, "-T", "-i", temp_file], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 394, in init
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Python3:

File "./storwize_get_state.py", line 231
sys.exit("1100")
^
TabError: inconsistent use of tabs and spaces in indentation

Discovery doesn't work

Zabbix 4.0.9
Python 2.7
ServerActive=127.0.0.1 in /etc/zabbix/zabbix_agentd.conf on server
storwize_state.log chmod 777, owner - zabbix
storwize_get_state.py chmod 755, owner - zabbix
./storwize_get_state.py --storwize_ip=192.168.16.5 --storwize_port=22 --storwize_user=admin --storwize_password='password' --storage_name="storage_name_in_zabbix" --discover retuns "2"
In "Latest Data" "get discovery" returns 1
image
Thanks!

Error messages while running the script

Dear aklyuk,
Thank you for that project.
I tried to run at shell on zabbix v4.4.1 / Centos 7.4. Recieved some error messages.

Thank you.

pwd
/usr/lib/zabbix/externalscripts

./storwize_get_state.py --storwize_ip=10.1.1.101 --storwize_port=80 --storwize_user=wizezbx --storwize_password='hbr-123!' --storage_name="zbxserver" --discovery

Traceback (most recent call last):
File "./storwize_get_state.py", line 358, in
main()
File "./storwize_get_state.py", line 349, in main
result_discovery = discovering_resources(arguments.storwize_user, arguments.storwize_password, arguments.storwize_ip, arguments.storwize_port, arguments.storage_name, list_resources)
File "./storwize_get_state.py", line 234, in discovering_resources
return send_data_to_zabbix(xer, storage_name)
File "./storwize_get_state.py", line 161, in send_data_to_zabbix
send_code = subprocess.call([sender_command, "-vv", "-c", config_path, "-s", storage_name, "-T", "-i", temp_file], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 711, in init
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

script #2

Hello. The return value of the script is always 2. What's wrong with this

Fix "TabError: inconsistent use of tabs and spaces in indentation"

On running the python script, it raises an error due to usage of both tabs and spaces for indentation. It is recommended by the Python styleguide (PEP 8) to never mix tabs and spaces.

To resolve this error, you can replace the spaces with tabs by running the following command in Linux or MacOS systems:

sed -e 's/ /\t/g' ./storwize_get_state.py > storwize_get_state.py

Trigger - HOST.NAME} -> Error sending metrics to zabbix after configuration

Hi,
I have set up monitoring through the Zabbix server as described in your guide. Here are the steps I followed:

  1. I created the host on Zabbix with the three macros mentioned.
  2. I created the user with monitoring privileges on the IBM storage.
  3. I set the parameter ServerActive to the Zabbix server's address (is this correct?) and restarted the agent.
  4. I tried the --discovery command on the server, which gave me zero output, indicating success.
  5. I ran the command zabbix_server -R config_cache_reload.
  6. I ran the --status command, which gave me an output of 1, revealing the problem with the trigger in question.

By the way, I noticed that in the Zabbix GUI under Latest Data, I am able to see all the probes with their respective pool and disk names, but no values are being displayed...... :(

I have also used the latest commit of Wolverine - Merged from all forks #9 with Python 3, but unfortunately, I am still getting the same error.
The Zabbix server is able to connect via SSH to the IBM storage without any issues. The Zabbix user is able to read the script and write logs to the /tmp directory. The script also creates two tmp files with the name of the storage, but the data is still not being sent to Zabbix

According to the trigger, in my case, the script is unable to send the metrics to Zabbix. Could you please help me resolve this issue?
Thanks :)

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.