SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
September 31, 2011

Introduction API Zabcon Conclusion




 The Zabbix API
 and
 Zabcon
           “The Zabbix Console”
     Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                    September 31, 2011

Introduction API Zabcon Conclusion
Your presenter


 Andrew Nelson
 ●RHCE, Zabbix Certified Specialist
 ●Active in the Zabbix community for

  approximately 7 years
 ●Nelsonab in the Zabbix forums.

 ●Creator of Zabcon, the Zabbix

  console.
  http://trac.red-tux.net
 ●Red Hat Consultant




       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                             September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example



  ●Introduced in Zabbix 1.8.0
  ●Based on JSON-RPC v 2.0 over HTTP

  ●Not RESTful

  ●Provides a somewhat raw interface to the internal data structures

  ●API calls are made to the Frontend, not the Zabbix server process

  ●API calls mimic Frontend activities




       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                       September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 Sounds interesting what do I need to know?
  ●URL used to access the api:
      <Server URL>/api_jsonrpc.php
      Example:
      http://myserver.example.com/zabbix/api_jsonrpc.php
  ●A valid Zabbix user is required for all API calls

    ● Often referred to as the “API User”

    ● Must be a member of a User group which has the API Access permission

      enabled
    ● API Users are Zabbix users with the ability to perform API calls

  ●The latest documentation is online:

      http://www.zabbix.com/documentation/1.8/api
  ●The forum is a great resource.




       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                          September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 My API User is configured, now what?
  Use of a Zabbix API library can make things easier
  ●

   ● Not required, the brave use Curl and Wget.

 ●API calls are divided into namespaces

   ● Namespace.call

     ● user.get, host.get etc

 ●Every API function requires a valid session ID.

   ● Except user.login, which is used to generate the session ID.

 ●Basic API Call/Layout:


        {
           "jsonrpc":"2.0",
           "method":”Function”,
           "params":{ “Name”:”Value” },
           "auth":”SessionID”,
           "id":<Incrementing Number>
        }
 ●Order is not important, content is




       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                           September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 Show me the data! (Login)
  The next few slides will show the steps needed to show all of the hosts on a
  system.

  The login:
   {
   "auth":null,"method":"user.login",
   "id":0,"jsonrpc":"2.0",
   "params":{"password":"apitest","user":"apitest"}
   }
  Result:
   {
   "jsonrpc":"2.0",
   "result":"ef1118f0c916f8c49d10913c31ba804c",
   "id":0
   }


       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                  September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 Show me the data! (host.get)
  The call:
   {
   "auth":"ef1118f0c916f8c49d10913c31ba804c",
   "method":"host.get","id":3,
   "params":{},"jsonrpc":"2.0"
   }
  Result:
   {
   "jsonrpc":"2.0",
   "result":
     [{"hostid":"10047"},{"hostid":"10064"},
       {"hostid":"10067"}],
   "id":3
   }



       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                  September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 Wait, is that all I get from host.get?
  Let's try again with the parameter “extend output”
   {
   "auth":"ef1118f0c916f8c49d10913c31ba804c","id":4,
   "method":"host.get", "params":{"output":"extend"},
   "jsonrpc":"2.0"
   }




       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                  September 31, 2011

Introduction API Zabcon Conclusion
Background | Introduction | Example

 Holy data Batman, that's a lot!
  Result:
      {"jsonrpc":"2.0",
       "result":
       [{"maintenances":[{"maintenanceid":"0"}],
        "hostid":"10047","proxy_hostid":"0","host":"test","dns":"",
        "useip":"1","ip":"127.0.0.1","port":"10050","status":"0",
        "disable_until":"0","error":"","available":"0",
        "errors_from":"0","lastaccess":"0","inbytes":"0","outbytes":"0",
        "useipmi":"0","ipmi_port":"623","ipmi_authtype":"-1",
        "ipmi_privilege":"2","ipmi_username":"","ipmi_password":"",
        "ipmi_disable_until":"0","ipmi_available":"0",
        "snmp_disable_until":"0","snmp_available":"0",
        "maintenanceid":"0","maintenance_status":"0",
        "maintenance_type":"0","maintenance_from":"0","ipmi_ip":"",
        "ipmi_errors_from":"0","snmp_errors_from":"0","ipmi_error":"",
        "snmp_error":""},
        { Truncated Data for Host 2"}, {Truncated Data for Host3}],
      "id":4}


       Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                              September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Is there an easier way?
  ●Zabcon is intended to be the “Zabbix Console”
    ● Started in late 2009

    ● Latest version 0.0.332 (released today!)

  ●Website: http://trac.red-tux.net

  ●Written in Ruby

    ● Requires at least 1.8.6

    ● No major issues with 1.9.x, please report them when you find them

  ●Can accept commands from standard input

    ● One person used Zabcon inside a script to import data into Zabbix, using this

      approach they were able to import about 1,000 hots in a matter of minutes.
  ●Users can create their own custom Zabcon commands

  ●Easiest way to install is from Rubygems

      # gem install zabcon
    ● Installation and update of dependencies is managed by Rubygems.

    ● Some dependencies may require a compiler and the Ruby development

      libraries

        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                              September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Let's see that get host example with Zabcon
  $ zabcon.rb
  Unable to find a default configuration file
  i386-linux
  Welcome to Zabcon. Build Number: 326
  Use the command 'help' to get help on commands
   -> login http://192.168.166.10 apitest apitest
  http://192.168.166.10 connected
  API Version: 1.3
   +> get host
  Host result set
  +--------+----------+-----+-----------+
  | hostid | host     | dns | ip        |
  +--------+----------+-----+-----------+
  | 10047 | test      |     | 127.0.0.1 |
  | 10064 | Lua 2     |     | 0.0.0.0   |
  | 10067 | new test |      | 127.0.0.1 |
  +--------+----------+-----+-----------+
  3 rows total
   +>
        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                            September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 That's nice do I really need to log in every time?
  ●Zabcon can load host and user information from a configuration file
  ●Default behavior is to load the config file upon startup

    ● ./zabcon.conf and ~/zabcon.conf are searched in that order

    ● Sample config file: zabcon.conf.default can be found in your system's

      Rubygems directory
             $ gem which zabcon
            /usr/lib/ruby/gems/1.8/gems/zabcon-0.0.332/./zabcon.rb
        ●   Using the above information the sample config file would be found at :
            /usr/lib/ruby/gems/1.8/gems/zabcon-0.0.332/zabcon.conf.default
  ●   Example:

      server=http://192.168.166.10/
      username=apitest
      password=apitest
      #debug=0
      #truncate_length=5000
      #custom_commands=sample_custom_commands

            Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                              September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Let's try that again, with more information:
  $ zabcon.rb
  i386-linux
  Found valid login credentials, attempting login
  http://192.168.166.10 connected
  API Version: 1.3
  Welcome to Zabcon. Build Number: 326
  Use the command 'help' to get help on commands
   +> get host show=hostid,host,dns,ip,available,status
  Host result set
  +--------+----------+-----+-----------+-----------+--------+
  | hostid | host     | dns | ip        | available | status |
  +--------+----------+-----+-----------+-----------+--------+
  | 10047 | test      |     | 127.0.0.1 | 0         | 0      |
  | 10064 | Lua 2     |     | 0.0.0.0   | 0         | 0      |
  | 10067 | new test |      | 127.0.0.1 | 0         | 0      |
  +--------+----------+-----+-----------+-----------+--------+
  3 rows total
   +>

        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                              September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Ok that's cool but what if I want to disable a host from a script?
  $ echo "get host show=hostid,host,dns,ip,status" | zabcon.rb
  hostid,host,dns,ip,status
  10047,test,,127.0.0.1,0
  10064,Lua 2,,0.0.0.0,0
  10067,new test,,127.0.0.1,0

  $ echo "update host hostid=10047 status=1" | zabcon.rb

  $ echo "get host show=hostid,host,dns,ip,status" | zabcon.rb
  hostid,host,dns,ip,status
  10047,test,,127.0.0.1,1
  10064,Lua 2,,0.0.0.0,0
  10067,new test,,127.0.0.1,0




        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                              September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Accessing the API directly
  ●Right now, Zabcon does not have a command for every possible API call.
  ●“raw api” allows direct access to the api.




   +> raw api history.get itemids=[22163] time_from=1317367232
  time_to=1317367262 output=extend
  Raw_api result set
  +------------+--------+------------+
  | clock       | itemid | value     |
  +------------+--------+------------+
  | 1317367283 | 22163 | 1317367283 |
  | 1317367343 | 22163 | 1317367343 |
  ...
  | 1317367943 | 22163 | 1317367943 |
  | 1317368003 | 22163 | 1317368003 |
  +------------+--------+------------+
  13 rows total



        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                                 September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Custom commands
  ●End users can create their own Zabcon commands to suit their own unique needs
  ●The command “help commands” will be updated with the new commands

  ●Zabcon.conf file determines the location of the custom commands file

  ●Custom commands file is only parsed on Zabcon startup.


      ZabconCommand.add_command "custom" do
        set_method do |params|                                           +> custom
          server.connection.raw_api("user.get",{})                        result set
        end                                                              +--------+
        set_help_tag :none                                               | userid |
        set_flag :print_output                                           +--------+
      end                                                                | 1       |
                                                                         | 2       |
                                                                         +--------+
                                                                         2 rows total




         Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                                 September 31, 2011

Introduction API Zabcon Conclusion
Introduction | Example | Simplifying things | More examples | Advanced

 Custom commands
  ●End users can create their own Zabcon commands to suit their own unique needs
  ●The command “help commands” will be updated with the new commands

  ●Zabcon.conf file determines the location of the custom commands file

  ●Custom commands file is only parsed on Zabcon startup.


      ZabconCommand.add_command "custom" do
        set_method do |params|                                           +> custom
          server.connection.raw_api("user.get",{})                        result set
        end                                                              +--------+
        set_help_tag :none                                               | userid |
        set_flag :print_output                                           +--------+
      end                                                                | 1       |
                                                                         | 2       |
                                                                         +--------+
                                                                         2 rows total




         Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
API & Zabcon                           September 31, 2011

Introduction API Zabcon Conclusion
Recap

 Time for me to stop talking
 ●API is JSON-RPC based
   ● Allows for a nearly complete interface for modifying Zabbix

 ●API calls are made to the Web fronend

 ●Zabcon allows you to easilly call the Zabbix API form the command line or scripts

   ● Help from more developers and testers is always appreciated (hint hint)




 Website:
 http://trac.red-tux.net

 Email:
 nelsonab@red-tux.net
 anelson@redhat.com




        Copyright 2011 Andrew Nelson, nelsonab@red-tux.net

Más contenido relacionado

La actualidad más candente

Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
Tatsuhiko Miyagawa
 

La actualidad más candente (20)

Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
How to inspect a RUNNING perl process
How to inspect a RUNNING perl processHow to inspect a RUNNING perl process
How to inspect a RUNNING perl process
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406
 
Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...
Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...
Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
Rihards Olups - Zabbix at Nokia - Case Study
Rihards Olups - Zabbix at Nokia - Case StudyRihards Olups - Zabbix at Nokia - Case Study
Rihards Olups - Zabbix at Nokia - Case Study
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and Catalyst
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 
ruxc0n 2012
ruxc0n 2012ruxc0n 2012
ruxc0n 2012
 
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et KibanaJournée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
 

Similar a Zabbix Console

Zabbix API at FISL12 by Takanori Suzuki
Zabbix API at FISL12 by Takanori SuzukiZabbix API at FISL12 by Takanori Suzuki
Zabbix API at FISL12 by Takanori Suzuki
takanori suzuki
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
True-Vision
 

Similar a Zabbix Console (20)

Zabbix API at FISL12 by Takanori Suzuki
Zabbix API at FISL12 by Takanori SuzukiZabbix API at FISL12 by Takanori Suzuki
Zabbix API at FISL12 by Takanori Suzuki
 
Automating Network Infrastructure : Ansible
Automating Network Infrastructure : AnsibleAutomating Network Infrastructure : Ansible
Automating Network Infrastructure : Ansible
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
GeekAustin DevOps
GeekAustin DevOpsGeekAustin DevOps
GeekAustin DevOps
 
OpenFaaS JeffConf 2017 - Milan
OpenFaaS JeffConf 2017 - MilanOpenFaaS JeffConf 2017 - Milan
OpenFaaS JeffConf 2017 - Milan
 
Flask With Server-Sent Event
Flask With Server-Sent EventFlask With Server-Sent Event
Flask With Server-Sent Event
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)
 
Running High-Speed Serverless with nuclio
Running High-Speed Serverless with nuclioRunning High-Speed Serverless with nuclio
Running High-Speed Serverless with nuclio
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
Chef 0.10 Overview
Chef 0.10 OverviewChef 0.10 Overview
Chef 0.10 Overview
 
How to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysisHow to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysis
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
About Clack
About ClackAbout Clack
About Clack
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOPHOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
 

Más de Ricardo Santos

Más de Ricardo Santos (15)

Portaria Inquerito Civil 5861/2013
Portaria Inquerito Civil 5861/2013Portaria Inquerito Civil 5861/2013
Portaria Inquerito Civil 5861/2013
 
Representação ao MP sobre a descida de Ônibus na Pista Sul da Imigrantes
Representação ao MP sobre a descida de Ônibus na Pista Sul da ImigrantesRepresentação ao MP sobre a descida de Ônibus na Pista Sul da Imigrantes
Representação ao MP sobre a descida de Ônibus na Pista Sul da Imigrantes
 
Carta enviada ao Governador pela UUFSAI
Carta enviada ao Governador pela UUFSAICarta enviada ao Governador pela UUFSAI
Carta enviada ao Governador pela UUFSAI
 
Apresentação da ARTESP em 27/08 na ALESP
Apresentação da ARTESP em 27/08 na ALESPApresentação da ARTESP em 27/08 na ALESP
Apresentação da ARTESP em 27/08 na ALESP
 
Requerimento de Informações à Secretaria de Transportes
Requerimento de Informações à Secretaria de TransportesRequerimento de Informações à Secretaria de Transportes
Requerimento de Informações à Secretaria de Transportes
 
ATA da Reunião com a ARTESP no dia 12/07/2013
ATA da Reunião com a ARTESP no dia 12/07/2013ATA da Reunião com a ARTESP no dia 12/07/2013
ATA da Reunião com a ARTESP no dia 12/07/2013
 
ATA da Reunião da AFREBAS com na Prefeitura de Santos
ATA da Reunião da AFREBAS com na Prefeitura de SantosATA da Reunião da AFREBAS com na Prefeitura de Santos
ATA da Reunião da AFREBAS com na Prefeitura de Santos
 
Comunicado da AFREBAS aos seus Usuários sobre as Manifestações
Comunicado da AFREBAS aos seus Usuários sobre as ManifestaçõesComunicado da AFREBAS aos seus Usuários sobre as Manifestações
Comunicado da AFREBAS aos seus Usuários sobre as Manifestações
 
Aplicabilidade de alternativas que promovam a melhoria contínua do tráfego de...
Aplicabilidade de alternativas que promovam a melhoria contínua do tráfego de...Aplicabilidade de alternativas que promovam a melhoria contínua do tráfego de...
Aplicabilidade de alternativas que promovam a melhoria contínua do tráfego de...
 
Laudo sobre a descida de fretados pela Imigrantes
Laudo sobre a descida de fretados pela ImigrantesLaudo sobre a descida de fretados pela Imigrantes
Laudo sobre a descida de fretados pela Imigrantes
 
Using Zabbix API from Drupal
Using Zabbix API from DrupalUsing Zabbix API from Drupal
Using Zabbix API from Drupal
 
The hidden power of network maps on Zabbix
The hidden power of network maps on ZabbixThe hidden power of network maps on Zabbix
The hidden power of network maps on Zabbix
 
Zabbix Performance Tuning
Zabbix Performance TuningZabbix Performance Tuning
Zabbix Performance Tuning
 
Zabbix over the Internet
Zabbix over the InternetZabbix over the Internet
Zabbix over the Internet
 
Zabbix by Alexei Vladishev - FISL12 - 2011
Zabbix by Alexei Vladishev - FISL12 - 2011Zabbix by Alexei Vladishev - FISL12 - 2011
Zabbix by Alexei Vladishev - FISL12 - 2011
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Zabbix Console

  • 1. September 31, 2011 Introduction API Zabcon Conclusion The Zabbix API and Zabcon “The Zabbix Console” Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 2. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Your presenter Andrew Nelson ●RHCE, Zabbix Certified Specialist ●Active in the Zabbix community for approximately 7 years ●Nelsonab in the Zabbix forums. ●Creator of Zabcon, the Zabbix console. http://trac.red-tux.net ●Red Hat Consultant Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 3. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example ●Introduced in Zabbix 1.8.0 ●Based on JSON-RPC v 2.0 over HTTP ●Not RESTful ●Provides a somewhat raw interface to the internal data structures ●API calls are made to the Frontend, not the Zabbix server process ●API calls mimic Frontend activities Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 4. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example Sounds interesting what do I need to know? ●URL used to access the api: <Server URL>/api_jsonrpc.php Example: http://myserver.example.com/zabbix/api_jsonrpc.php ●A valid Zabbix user is required for all API calls ● Often referred to as the “API User” ● Must be a member of a User group which has the API Access permission enabled ● API Users are Zabbix users with the ability to perform API calls ●The latest documentation is online: http://www.zabbix.com/documentation/1.8/api ●The forum is a great resource. Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 5. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example My API User is configured, now what? Use of a Zabbix API library can make things easier ● ● Not required, the brave use Curl and Wget. ●API calls are divided into namespaces ● Namespace.call ● user.get, host.get etc ●Every API function requires a valid session ID. ● Except user.login, which is used to generate the session ID. ●Basic API Call/Layout: { "jsonrpc":"2.0", "method":”Function”, "params":{ “Name”:”Value” }, "auth":”SessionID”, "id":<Incrementing Number> } ●Order is not important, content is Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 6. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example Show me the data! (Login) The next few slides will show the steps needed to show all of the hosts on a system. The login: { "auth":null,"method":"user.login", "id":0,"jsonrpc":"2.0", "params":{"password":"apitest","user":"apitest"} } Result: { "jsonrpc":"2.0", "result":"ef1118f0c916f8c49d10913c31ba804c", "id":0 } Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 7. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example Show me the data! (host.get) The call: { "auth":"ef1118f0c916f8c49d10913c31ba804c", "method":"host.get","id":3, "params":{},"jsonrpc":"2.0" } Result: { "jsonrpc":"2.0", "result": [{"hostid":"10047"},{"hostid":"10064"}, {"hostid":"10067"}], "id":3 } Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 8. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example Wait, is that all I get from host.get? Let's try again with the parameter “extend output” { "auth":"ef1118f0c916f8c49d10913c31ba804c","id":4, "method":"host.get", "params":{"output":"extend"}, "jsonrpc":"2.0" } Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 9. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Background | Introduction | Example Holy data Batman, that's a lot! Result: {"jsonrpc":"2.0", "result": [{"maintenances":[{"maintenanceid":"0"}], "hostid":"10047","proxy_hostid":"0","host":"test","dns":"", "useip":"1","ip":"127.0.0.1","port":"10050","status":"0", "disable_until":"0","error":"","available":"0", "errors_from":"0","lastaccess":"0","inbytes":"0","outbytes":"0", "useipmi":"0","ipmi_port":"623","ipmi_authtype":"-1", "ipmi_privilege":"2","ipmi_username":"","ipmi_password":"", "ipmi_disable_until":"0","ipmi_available":"0", "snmp_disable_until":"0","snmp_available":"0", "maintenanceid":"0","maintenance_status":"0", "maintenance_type":"0","maintenance_from":"0","ipmi_ip":"", "ipmi_errors_from":"0","snmp_errors_from":"0","ipmi_error":"", "snmp_error":""}, { Truncated Data for Host 2"}, {Truncated Data for Host3}], "id":4} Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 10. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Is there an easier way? ●Zabcon is intended to be the “Zabbix Console” ● Started in late 2009 ● Latest version 0.0.332 (released today!) ●Website: http://trac.red-tux.net ●Written in Ruby ● Requires at least 1.8.6 ● No major issues with 1.9.x, please report them when you find them ●Can accept commands from standard input ● One person used Zabcon inside a script to import data into Zabbix, using this approach they were able to import about 1,000 hots in a matter of minutes. ●Users can create their own custom Zabcon commands ●Easiest way to install is from Rubygems # gem install zabcon ● Installation and update of dependencies is managed by Rubygems. ● Some dependencies may require a compiler and the Ruby development libraries Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 11. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Let's see that get host example with Zabcon $ zabcon.rb Unable to find a default configuration file i386-linux Welcome to Zabcon. Build Number: 326 Use the command 'help' to get help on commands -> login http://192.168.166.10 apitest apitest http://192.168.166.10 connected API Version: 1.3 +> get host Host result set +--------+----------+-----+-----------+ | hostid | host | dns | ip | +--------+----------+-----+-----------+ | 10047 | test | | 127.0.0.1 | | 10064 | Lua 2 | | 0.0.0.0 | | 10067 | new test | | 127.0.0.1 | +--------+----------+-----+-----------+ 3 rows total +> Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 12. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced That's nice do I really need to log in every time? ●Zabcon can load host and user information from a configuration file ●Default behavior is to load the config file upon startup ● ./zabcon.conf and ~/zabcon.conf are searched in that order ● Sample config file: zabcon.conf.default can be found in your system's Rubygems directory $ gem which zabcon /usr/lib/ruby/gems/1.8/gems/zabcon-0.0.332/./zabcon.rb ● Using the above information the sample config file would be found at : /usr/lib/ruby/gems/1.8/gems/zabcon-0.0.332/zabcon.conf.default ● Example: server=http://192.168.166.10/ username=apitest password=apitest #debug=0 #truncate_length=5000 #custom_commands=sample_custom_commands Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 13. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Let's try that again, with more information: $ zabcon.rb i386-linux Found valid login credentials, attempting login http://192.168.166.10 connected API Version: 1.3 Welcome to Zabcon. Build Number: 326 Use the command 'help' to get help on commands +> get host show=hostid,host,dns,ip,available,status Host result set +--------+----------+-----+-----------+-----------+--------+ | hostid | host | dns | ip | available | status | +--------+----------+-----+-----------+-----------+--------+ | 10047 | test | | 127.0.0.1 | 0 | 0 | | 10064 | Lua 2 | | 0.0.0.0 | 0 | 0 | | 10067 | new test | | 127.0.0.1 | 0 | 0 | +--------+----------+-----+-----------+-----------+--------+ 3 rows total +> Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 14. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Ok that's cool but what if I want to disable a host from a script? $ echo "get host show=hostid,host,dns,ip,status" | zabcon.rb hostid,host,dns,ip,status 10047,test,,127.0.0.1,0 10064,Lua 2,,0.0.0.0,0 10067,new test,,127.0.0.1,0 $ echo "update host hostid=10047 status=1" | zabcon.rb $ echo "get host show=hostid,host,dns,ip,status" | zabcon.rb hostid,host,dns,ip,status 10047,test,,127.0.0.1,1 10064,Lua 2,,0.0.0.0,0 10067,new test,,127.0.0.1,0 Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 15. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Accessing the API directly ●Right now, Zabcon does not have a command for every possible API call. ●“raw api” allows direct access to the api. +> raw api history.get itemids=[22163] time_from=1317367232 time_to=1317367262 output=extend Raw_api result set +------------+--------+------------+ | clock | itemid | value | +------------+--------+------------+ | 1317367283 | 22163 | 1317367283 | | 1317367343 | 22163 | 1317367343 | ... | 1317367943 | 22163 | 1317367943 | | 1317368003 | 22163 | 1317368003 | +------------+--------+------------+ 13 rows total Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 16. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Custom commands ●End users can create their own Zabcon commands to suit their own unique needs ●The command “help commands” will be updated with the new commands ●Zabcon.conf file determines the location of the custom commands file ●Custom commands file is only parsed on Zabcon startup. ZabconCommand.add_command "custom" do set_method do |params| +> custom server.connection.raw_api("user.get",{}) result set end +--------+ set_help_tag :none | userid | set_flag :print_output +--------+ end | 1 | | 2 | +--------+ 2 rows total Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 17. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Introduction | Example | Simplifying things | More examples | Advanced Custom commands ●End users can create their own Zabcon commands to suit their own unique needs ●The command “help commands” will be updated with the new commands ●Zabcon.conf file determines the location of the custom commands file ●Custom commands file is only parsed on Zabcon startup. ZabconCommand.add_command "custom" do set_method do |params| +> custom server.connection.raw_api("user.get",{}) result set end +--------+ set_help_tag :none | userid | set_flag :print_output +--------+ end | 1 | | 2 | +--------+ 2 rows total Copyright 2011 Andrew Nelson, nelsonab@red-tux.net
  • 18. API & Zabcon September 31, 2011 Introduction API Zabcon Conclusion Recap Time for me to stop talking ●API is JSON-RPC based ● Allows for a nearly complete interface for modifying Zabbix ●API calls are made to the Web fronend ●Zabcon allows you to easilly call the Zabbix API form the command line or scripts ● Help from more developers and testers is always appreciated (hint hint) Website: http://trac.red-tux.net Email: nelsonab@red-tux.net anelson@redhat.com Copyright 2011 Andrew Nelson, nelsonab@red-tux.net