首页 > 数据库技术 > 详细

从CMDB查询云平台组件或者IP简单脚本

时间:2018-05-15 01:27:37      阅读:274      评论:0      收藏:0      [点我收藏+]

#!/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 =‘$1‘ and ingredient=‘$2‘"
}
#todo: not sure what 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=‘$1‘ and ip=‘$2‘ "

}

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 $1
  elif [ $# -eq 2 ]
  then
  argtype=`echo $2|egrep [1-9+\.]`
  if [ -z $argtype ]
  then
    ingredient_ip $1 $2
  else
    ip_ingredient_ip $1 $2
  fi
fi

}
main $*

从CMDB查询云平台组件或者IP简单脚本

原文:https://www.cnblogs.com/hixiaowei/p/9038862.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!