Ad Widget

Collapse

Drive status reports

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jvlavl
    Member
    • Sep 2015
    • 37

    #1

    Drive status reports

    Hello,

    which tables do need to retreive the information about the disk drives from a monitored node?

    Example:
    servername drive<a> Totalsize GB Usedspace GB Freespace GB
    drive<b> Totalsize GB Usedspace GB Freespace GB

    Rgds,

    John
  • batchenr
    Senior Member
    • Sep 2016
    • 440

    #2
    Originally posted by Jvlavl
    Hello,

    which tables do need to retreive the information about the disk drives from a monitored node?

    Example:
    servername drive<a> Totalsize GB Usedspace GB Freespace GB
    drive<b> Totalsize GB Usedspace GB Freespace GB

    Rgds,

    John
    which tables ? what do you mean ?
    you can use this :
    vfs.fs.size[fs,<mode>]

    for exsample :
    vfs.fs.size[/,free]

    full table :
    Code:
    vfs.fs.size[fs,<mode>]
    Disk space in bytes or in percentage from total.	Integer - for bytes
    
    Float - for percentage	fs - filesystem
    mode - one of total (default), free, used, pfree (free, percentage), pused (used, percentage)	In case of a mounted volume, disk space for local file system is returned.
    
    Example: vfs.fs.size[/tmp,free]
    
    Reserved space of a file system is taken into account and not included when using the free mode.
    
    Old naming: vfs.fs.free[*], vfs.fs.total[*], vfs.fs.used[*], vfs.fs.pfree[*], vfs.fs.pused[*]

    Comment

    • Jvlavl
      Member
      • Sep 2015
      • 37

      #3
      Hello,

      This is not what i ment.
      I want to retrieve the data from the Zabbix database and then import that data into excel.

      To create my own reports.

      which database tables do need to retreive the information about the disk drives from a monitored node?

      Example:
      servername drive<a> Totalsize GB Usedspace GB Freespace GB
      drive<b> Totalsize GB Usedspace GB Freespace GB

      Rgds,

      John

      Comment

      • toine7m
        Member
        • Feb 2017
        • 93

        #4
        It'll be easier using the API

        Comment

        • Jvlavl
          Member
          • Sep 2015
          • 37

          #5
          Thanks toine

          This will indeed do what I want

          i'm gone fight the script ttps://www.zabbix.com/forum/images/smilies/smile.gif

          Comment

          • Jvlavl
            Member
            • Sep 2015
            • 37

            #6
            Thanks toine

            This will indeed do what I want

            i'm gone fight the script https://www.zabbix.com/forum/images/smilies/smile.gif

            Comment

            • toine7m
              Member
              • Feb 2017
              • 93

              #7
              If you plan to do it in bash, here's some help :

              - Connection script with cURL :
              curl -i -n -X POST --header "Content-Type: application/json" -d@- http://YourIP/api_jsonrpc.php

              then paste this with the modified username/password

              {
              "jsonrpc": "2.0",
              "method": "user.login",
              "params": {
              "user": "admin",
              "password": "admin",
              "userdata": true
              },
              "id": 0
              }

              and press CTRL-D


              You'll obtain a token of authentication, then you can paste it in this code for example :
              {
              "jsonrpc": "2.0",
              "method": "hostgroup.get",
              "params": {
              "output": "extend",
              "filter": {
              }
              },
              "auth": "past your token here",
              "id": 1
              }


              Or you can use a PHP API to make it more easy to use :P This one is perfect for me : https://github.com/confirm/PhpZabbixApi

              Comment

              • Jvlavl
                Member
                • Sep 2015
                • 37

                #8
                Hello,

                A lot of thanks to toine7m who pointed me to this

                Can anybody help me with this.
                It can be in bash or python.
                At this moment i'm trying to get the following done.

                using the following:
                curl -i -n -X POST --header "Content-Type: application/json" -d@- http://10.31.24.20/zabbix/api_jsonrpc.php

                {
                "jsonrpc": "2.0",
                "method": "item.get",
                "params": {
                "output": "extend",
                "hostids": "10084",
                "filter": {
                "key_": "vfs.fs.size[\/,used]"
                },
                "sortfield": "trends",
                "string": "lastvalue"
                },
                "auth": "be9a8c92181c2efbe267eea3axxxxxxxx",
                "id": 1
                }


                What I get in return is this:

                HTTP/1.1 200 OK
                Date: Tue, 11 Apr 2017 11:08:08 GMT
                Server: Apache/2.4.7 (Ubuntu)
                X-Powered-By: PHP/5.5.9-1ubuntu4.21
                Access-Control-Allow-Origin: *
                Access-Control-Allow-Headers: Content-Type
                Access-Control-Allow-Methods: POST
                Access-Control-Max-Age: 1000
                Content-Length: 950
                Content-Type: application/json

                {"jsonrpc":"2.0","result":[{"itemid":"24087","type":"0","snmp_community":""," snmp_oid":"","hostid":"10084","name":"Used disk space on $1","key_":"vfs.fs.size[\/,used]","delay":"60","history":"7","trends":"365","statu s":"0","value_type":"3","trapper_hosts":"","units" :"B","multiplier":"0","delta":"0","snmpv3_security name":"","snmpv3_securitylevel":"0","snmpv3_authpa ssphrase":"","snmpv3_privpassphrase":"","formula": "1","error":"","lastlogsize":"0","logtimefmt":""," templateid":"0","valuemapid":"0","delay_flex":""," params":"","ipmi_sensor":"","data_type":"0","autht ype":"0","username":"","password":"","publickey":" ","privatekey":"","mtime":"0","flags":"4","interfa ceid":"1","port":"","description":"","inventory_li nk":"0","lifetime":"30","snmpv3_authprotocol":"0", "snmpv3_privprotocol":"0","state":"0","snmpv3_cont extname":"","evaltype":"0","lastclock":"1491908847 ","lastns":"221516214","lastvalue":"17666924544"," prevvalue":"17666924544"}],"id":1}

                This is to much I only want is:

                vfs.fs.size[\/,used] "lastvalue":"17666924544"

                the end goal is to retrieve from a give group all hosts that belong in there vfs.fs.size[\/,total] "lastvalue":"xxxxxxx" vfs.fs.size[\/,used] "lastvalue":"xxxxxx" vfs.fs.size[\/,free] "lastvalue":"xxxxxxxx" written into a csv file

                Thanks in advance John

                Comment

                • toine7m
                  Member
                  • Feb 2017
                  • 93

                  #9
                  Hi

                  If you just want some fields, you've to specify those fields in the "output" part, like this

                  "output": "lastvalue",

                  because you set the output as "extend" which means all of the fields

                  with your request it's :

                  {
                  "jsonrpc": "2.0",
                  "method": "item.get",
                  "params": {
                  "output": "lastvalue",
                  "hostids": "10084",
                  "filter": {
                  "key_": "vfs.fs.size[\/,used]"
                  },
                  "sortfield": "trends",
                  "string": "lastvalue"
                  },
                  "auth": "be9a8c92181c2efbe267eea3axxxxxxxx",
                  "id": 1
                  }

                  Comment

                  • Jvlavl
                    Member
                    • Sep 2015
                    • 37

                    #10
                    Sorry, doesn't solve it.

                    curl -i -n -X POST --header "Content-Type: application/json" -d@- http://10.31.17.20/zabbix/api_jsonrpc.php
                    {
                    "jsonrpc": "2.0",
                    "method": "item.get",
                    "params": {
                    "output": "lastvalue",
                    "hostids": "10084",
                    "filter": {
                    "key_": "vfs.fs.size[\/,used]"
                    },
                    "sortfield": "trends",
                    "string": "lastvalue"
                    },
                    "auth": "d6643c2d4c2b62cb01fc394d13bd5f67",
                    "id": 1
                    }
                    HTTP/1.1 200 OK
                    Date: Tue, 11 Apr 2017 13:33:35 GMT
                    Server: Apache/2.4.7 (Ubuntu)
                    X-Powered-By: PHP/5.5.9-1ubuntu4.21
                    Access-Control-Allow-Origin: *
                    Access-Control-Allow-Headers: Content-Type
                    Access-Control-Allow-Methods: POST
                    Access-Control-Max-Age: 1000
                    Content-Length: 54
                    Content-Type: application/json

                    {"jsonrpc":"2.0","result":[{"itemid":"24087"}],"id":1}


                    Rgds,

                    John

                    Comment

                    • toine7m
                      Member
                      • Feb 2017
                      • 93

                      #11
                      You need to put the "output" in brackets, I forgot this
                      I also removed the unused code, like the "string" or "sortfield"
                      should work :

                      {
                      "jsonrpc": "2.0",
                      "method": "item.get",
                      "params": {
                      "output": ["lastvalue"],
                      "hostids": "10084",
                      "filter": {
                      "key_": "vfs.fs.size[\/,used]"
                      }
                      },
                      "auth": "d6643c2d4c2b62cb01fc394d13bd5f67",
                      "id": 1
                      }


                      Edit : If you want to see the JSON clearly, you can use a beautifier like http://codebeautify.org/jsonviewer

                      Comment

                      • Jvlavl
                        Member
                        • Sep 2015
                        • 37

                        #12
                        toine7m Thanks for your assistance so far.

                        You helped me a lot

                        But i'm not there yet :-)

                        Rgds,

                        John

                        Comment

                        • toine7m
                          Member
                          • Feb 2017
                          • 93

                          #13
                          If you've any other problem, let me know

                          But I suggest you to use a php script using Zabbix PHP API, it'll be easier to get all the things you want in an array or something like this

                          Comment

                          • Jvlavl
                            Member
                            • Sep 2015
                            • 37

                            #14
                            Hello,

                            can anybody help me put these two toghter?


                            if hostsgroup:
                            if item:
                            host =zapi.host.get(filter={'groupids': hostgroups}) "I see the correct number of hosts including hostname"
                            item = zapi.item.get(output=['lastvalue'], groupids='44', filter={'key_':'vfs.fs.size[/,total]'}) " Shows the correct info"


                            #print host
                            for i in item:
                            print i " shows only the information from Item. I would like see the hostname from host and info from item.

                            Can someone please help.

                            Rgds,

                            John

                            Comment

                            Working...