Code Monkey home page Code Monkey logo

cmdbapi's Introduction

iTop API wrapper

Secondary encapsulation of iTop API is easy to call

iData model using https://github.com/annProg/itop-extensions

Parameter Description

Parameters Description
type ip,app,server,url,domain,default,etc (iyou can define config['map'] in config.php to map the type and the corresponding iTop class)
value Multiple values are separated by commas
rankdir dot graphics direction, LR or TB,default TB
depth relation depth, the default app is 1, ip, default,etc. are 3
direction Association direction, up (dependency), down (influence), both (dependency and influence), the default is down
show The iTop class that controls the display of relation, comma-separated
hide The iTop class that controls relation hiding, comma-separated
filter Controls the type of objects displayed, comma-separated

Example

Called with the following parameters

public.php?type=ip&value=10.0.0.2&filter=Server&show=Server,Cluster,Rack,ApplicationSolution&direction=both&depth=2

Query the association relationship of the server whose IP is 10.0.0.2, and objects only display the Server class, the relations class displays Server, Cluster, Rack, ApplicationSolution&direction, and also display the upstream and downstream associations of this server, associations The depth is only displayed at level 2, and the result is similar to the following

{
  "relations": {
    "Server::2::op.node.22": [
      {
        "key": "Cluster::3::op1"
      },
      {
        "key": "ApplicationSolution::54::op.appname"
      }
    ],
    "Cluster::3::op1": [
      {
        "key": "ApplicationSolution::53::op.monitor"
      }
    ],
    "Rack::11::土城4F.M1": [
      {
        "key": "Server::2::op.node.22"
      }
    ]
  },
  "objects": {
    "Server::2": {
      "code": 0,
      "message": "",
      "class": "Server",
      "key": "2",
      "fields": {
        "id": "2",
        "friendlyname": "op.node.22"
      }
    }
  },
  "code": 0,
  "message": "Scope: 1; Related objects: Server= 1",
  "imgurl": "http://cmdb.cn/chart/api.php?cht=gv:dot&chl=digraph+G..."
}

The picture shows the following

Deployment method recommendations

cmdbApi listens on local port

server {
	listen      127.0.0.1:8090;
	access_log logs/cmdbapi.log main;
	root /opt/wwwroot/cmdb.xxx.cn/cmdbApi/web;

	include enable-php.conf;

	location / {
		index  index.html index.htm index.php;
	}

	location ~ /\.
	{
		deny all;
	}

}

cmdbApi drawing dependencies chartInterface, this interface is used to convert dot source code to image

server {
	listen      127.0.0.1:8091;
	access_log logs/cmdbchart.log main;
	root /opt/wwwroot/cmdb.xxx.cn/chart/;

	include enable-php.conf;

	location / {
		index  index.html index.htm index.php;
	}

	location ~ /\.
	{
		deny all;
	}

}

Do reverse proxy in cmdb configuration file

upstream graphviz-api {
	server 127.0.0.1:8091;
}

upstream cmdb-pubapi {
	server 127.0.0.1:8090;
}

server {
	listen      80;
	server_name  cmdb.xxx.cn;
	access_log logs/cmdb.xxx.cn.log main;
	root /opt/wwwroot/cmdb.xxx.cn/web;

	include enable-php.conf;

	location / {
		index  index.html index.htm index.php;
	}
	
	location /data/ {
		deny all;
	}
	
	location ^~ /api/ {
		proxy_pass http://cmdb-pubapi/;
		proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
	}

	location ^~ /chart/ {
		proxy_pass http://graphviz-api/;
	}
	location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
	{
		expires      30d;
	}

	location ~ .*\.(js|css)?$
	{
		expires      12h;
	}

	location ~ /\.
	{
		deny all;
	}

}

cmdbapi's People

Contributors

annprog avatar schirrms avatar

Watchers

 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.