Giter Club home page Giter Club logo

clusto-query's Introduction

clusto-query performs arbitrary boolean queries against clusto. It is available under the ISC license, which you can find under LICENSE.txt and requires the python clusto libraries.

Infix expression operators are the following:

Operator Aliases Meaning
= is equality
!= isnt, <> inequality
<= le less than or equal to
< lt less than
>= ge greater than or equal to
> gt greater than
^ startswith string starts with
, endswith string ends with
contains string contains
in_cidr IP address is in CIDR range

Additionally, there are boolean operators and, or, and - (set subtraction)

some keywords (pool, datacenter, clusto_type, and name) can be directly queried anything that's an "Attribute" must be prefixed with attr

Here's an example query:

clusto_type = server and
(attr system.cpucount >= 15 or system.memory >= 32760)
and datacenter = peak-mpl1'

This query fetches all servers with more than 16 cores or 32768 MB of RAM located in the "peak-mlp1" datacenter. Neato!

Note that I put in "15" instead of "16" intentionally; clusto's cpu counting is off-by-one. That was fun. Let's go again:

clusto_type contains "server" and
(attr nagios.disabled = 1 - hostname endswith peak2)

This one finds all servers that are disabled in nagios and do not have a hostname that ends in peak2.

Quoting and parens work the way you expect them to.

Run tests with nosetests -w clusto_query --with-coverage

clusto-query's People

Contributors

altanalpay avatar eklitzke avatar eskil avatar jakobgt avatar norberthu avatar roguelazer avatar sloppyfocus avatar zhitaoli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

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.