从CMDB查询云平台组件或者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 ='$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 $*
最新文章
- 【CentOS】虚拟机网络配置与远程登录
- 【javascript 面试笔试】1、几道笔试题
- JAVA排序--[冒泡排序]
- redis在.NET下的使用
- 与时间有关的windows函数
- 关于Spring的BeanPostProcessor
- 记一次亲身踩过的hibernate的bug
- MySql 修改外键 支持级联删除
- CodeChef Little Elephant and Mouses [DP]
- 基于scrapy爬虫的天气数据采集(python)
- Oracle 数据库基础知识
- java.util.Stack类中的peek()方法
- 解决 ora-28001 密码过期的处理办法
- jsp 一点点
- git 用法---成功添加一个文件到github
- wps word改多级编号为2.1
- ELK新手教程(二)
- mySQL 约束 (Constraints):一、非空约束 NOT NULL 约束
- Using Dtrace OEL 6.X
- MySQL 两个数据库表中合并数据
热门文章
- HTML存储详解
- CentOS7系列--1.4CentOS7服务
- Python这个缩进让我焦头烂额!最奇葩的缩进...
- node-sass 解决 no such file or directory
- Oracle案例11——Oracle表空间数据库文件收缩
- 委托学习总结(二)匿名方法和lambda表达式
- Docker 报错 error during connect: Get pipe/docker_engine: The system cannot find the file specified. - 摘要: 本文讲的是Docker 报错 error during connect: Get pipe/dock
- GBK与UTF-8编码错误转换后,无法再正确恢复
- 转:线程Thread (1)
- 解析苹果的官方例子LazyTableImages实现图片懒加载原理