Querying cloud Platform components or IP simple scripts from the CMDB

Source: Internet
Author: User
Tags get ip

#!/bin/bash
#author Xiaoweige
#todo: IP--> ingredient or ingredient--> IP

#todo: Get the IP of the given ingredient
function Ingredient_ip () {
#todo: Get the IP of the ingredient given
Mysql-uroot-pengine-e "SELECT * from ipandingredient.ipandingredient where env = ' $ ' and ingredient= '"
}
#todo: Not sure what's the ingredient is
function Search_ingredient () {
Mysql-uroot-pengine-e "Use ipandingredient; select * from ipandingredient where ingredient like '%${1}% '"

}
#todo: Get the IP of the ingredient given
function Ip_ingredient () {
Mysql-uroot-pengine-e "Use ipandingredient; SELECT * from Ipandingredient where env= ' $ ' and ip= ' $ '

}

function usage () {
echo "To get ingredient USAGE:./$0 IP"
echo "To get IP USAGE:./$0 ingredient"
echo "search ingredient./$0 sth"

}

function Main () {
If [$#-eq 0]
Then
Usage
elif [$#-eq 1]
Then
Search_ingredient $
elif [$#-eq 2]
Then
Argtype= ' echo $2|egrep [1-9+\.] `
If [-Z $argtype]
Then
INGREDIENT_IP $
Else
IP_INGREDIENT_IP $
Fi
Fi

}
Main $*

Querying cloud Platform components or IP simple scripts from the CMDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.