perl 获取虚拟机信息
[root@master ~]# cat simple_flow.pl ! /usr/bin/perl -w use strict; use warnings; 导入 vSphere SDK for Perl 的运行支持模块 此模块用来完成服务器端 - 客户端数据映射、载入客户端和服务器端之间的交互函数等 use VMware::VIRuntime; hash 结构 %opts 存放自定义命令行参数 my %opts =(
entity => {
type => “=s”,
variable => “VI_ENTITY”,
help => “ManagedEntity type: HostSystem, etc”,
required => 1,
},
); vSphere SDK for Perl 为所有脚本提供了一些基本的命令行参数,如 –server,–url 等 Opts::add_options 方法用以添加用户自定义参数 Opts::add_options(%opts); 解析命令行参数 Opts::parse(); 验证命令行参数 Opts::validate(); 连接远程服务器,vCenter 或 ESX server Util::connect(); 提取命令行参数 entity 的值 my $entity_type = Opts::get_option(‘entity’); 根据 entity 值查询服务器端对象, Vim::find_entity_views 返回服务器端对象对应的 Perl 视图 my entityviews=Vim::findentityviews(viewtype=>entity_type); 输出服务器端对象 Perl 视图的信息,如类型和名称等 foreach my entityview(@entity_views) {
my entityname=entity_view->name;
Util::trace(0, “Found entitytype:entity_name\n”);
} 断开与远程服务器的连接 Util::disconnect();
[root@master ~]# perl simple_flow.pl –server 192.168.32.8 –username root –password 1234567 –entity VirtualMachine
Found VirtualMachine: dr-mysql01—192.168.32.101-贡文
Found VirtualMachine: v-test-web02-192.168.32.214
Found VirtualMachine: v-test-app01-192.168.32.215
Found VirtualMachine: v-test-app02-192.168.32.216
Found VirtualMachine: v-dev-migdb01-192.168.32.21
Found VirtualMachine: test-oadb01-192.168.32.32
Found VirtualMachine: v-test-db02-192.168.32.232
Found VirtualMachine: demo-disk10G-mem512M-192.168.32.150
Found VirtualMachine: v-test-nfs01-192.168.32.219
Found VirtualMachine: HZ-TEST-02-192.168.32.10
Found VirtualMachine: v-test-db03-192.168.32.233
Found VirtualMachine: v-test-redis01-192.168.32.217
Found VirtualMachine: v-test-mgr01-192.168.32.235
Found VirtualMachine: v-dev-db01-192.168.32.14
Found VirtualMachine: v-dev-redis01-192.168.32.15
Found VirtualMachine: v-dev-redis02-192.168.32.16(image-ftp)
Found VirtualMachine: v-lhb-prx01-192.168.32.111
Found VirtualMachine: HZ-TEST-192.168.32.9-尚晓斌-MySQL
Found VirtualMachine: v-lhb-mgr01-192.168.32.114
Found VirtualMachine: v-lhb-nfs01-192.168.32.115
Found VirtualMachine: v-lhb-db03-192.168.32.119
Found VirtualMachine: v-test-mysql-192.168.32.6
Found VirtualMachine: v-test-redis-192.168.32.167
Found VirtualMachine: v-test-redis-192.168.32.168
Found VirtualMachine: v-test-tomcat-192.168.32.169-pay
Found VirtualMachine: v-test-tomcat-192.168.32.170-api
Found VirtualMachine: HZ-TEST-192.168.32.12-尚晓斌-TOMCAT
Found VirtualMachine: v-test-tomcat-192.168.32.171-flow
Found VirtualMachine: v-test-nginx-192.168.32.172
Found VirtualMachine: v-test-haproxy-192.168.32.173
Found VirtualMachine: v-test-mysql-pay-192.168.32.5
Found VirtualMachine: v-pro-运维堡垒机-192.168.32.177
Found VirtualMachine: v-test-nginx-192.168.32.174-back_office
Found VirtualMachine: v-test-192.168.32.175-redis01
Found VirtualMachine: v-test-192.168.32.176-redis02
Found VirtualMachine: v-test-proxy-192.168.32.178
Found VirtualMachine: v-test-backoffice-192.168.32.180
Found VirtualMachine: test01-192.168.32.11- 张安挺
Found VirtualMachine: v-test-zjzc-mysql-192.168.32.185
Found VirtualMachine: v-test-redis-192.168.32.187
Found VirtualMachine: v-test-app192.168.32.181
Found VirtualMachine: v-test-文件服务器-192.168.32.182
Found VirtualMachine: v-test-pay-mysql-192.168.32.186
Found VirtualMachine: 客服堡垒机-192.168.32.188
Found VirtualMachine: mysql-slave-192.168.32.116
Found VirtualMachine: 生产slave-192.168.32.118
Found VirtualMachine: slave-pay-192.168.32.146
Found VirtualMachine: check-zjzc-192.168.32.218
Found VirtualMachine: test-image01-192.168.32.102-尚晓斌(sftp)
Found VirtualMachine: v-pro-192.168.32.55-zabbix
Found VirtualMachine: v-test-prx01-192.168.32.211
Found VirtualMachine: v-test-prx02-192.168.32.212
Found VirtualMachine: v-test-web01-192.168.32.213
perl 获取虚拟机信息的更多相关文章
- perl 获取目录信息
1 #!/usr/bin/perl -w 2 use strict; 3 use FindBin qw($Bin $Script); 4 5 my $rp=$Bin; 6 print "th ...
- Python3对接华三CAS平台Api获取虚拟机监控信息-渐入佳境
--时间:2021年2月3日 --作者:飞翔的小胖猪 说明 使用python对接华三CAS虚拟化平台,通过厂商提供的api接口获取每个集群下所有虚拟机的监控信息,并保存数据在本地的mariadb数据库 ...
- 使用Sigar获取服务器信息
Sigar简介 Sigar是Hyperic-hq产品的基础包,是Hyperic HQ主要的数据收集组件.它用来从许多平台收集系统和处理信息. 这些平台包括:Linux, Windows, Solari ...
- (部署新java程序,程序报错,需copy的一个包)——java使用siger 获取服务器硬件信息
mcat-siger.sh 查看是否安装siger rsync -aPuv /usr/lib64/libsigar-amd64-linux.so $i:/usr/lib64/ java使用siger ...
- 通过GeoIP2分析访问者IP获取地理位置信息
原文链接:http://blog.csdn.net/johnnycode/article/details/42028841 MaxMind GeoIP2 服务能识别互联网用户的地点位置与其他特征,应用 ...
- 探索Windows Azure 监控和自动伸缩系列2 - 获取虚拟机的监控定义和监控数据
上一篇博文介绍了如何连接Windows Azure: http://www.cnblogs.com/teld/p/5113063.html 本篇我们继续上次的示例代码,获取虚拟机的监控定义和监控数据. ...
- [博客迁移]探索Windows Azure 监控和自动伸缩系列2 - 获取虚拟机的监控定义和监控数据
上一篇博文介绍了如何连接Windows Azure: http://www.cnblogs.com/teld/p/5113063.html 本篇我们继续上次的示例代码,获取虚拟机的监控定义和监控数据. ...
- Java运用第三方开源jar包sigar.jar获取服务器信息
通过使用第三方开源jar包sigar.jar我们可以获得本地的信息 一.准备工作 (1)下载jar包和相关文件 资源链接:百度云:链接:https://pan.baidu.com/s/1nxccJHJ ...
- Java获取虚拟机内存和操作系统内存及其线程
为什么要获取虚拟机内存和操作系统内存呢? 虚拟机内存,这里主要指JVM.为了防止有的时候因为JVM内存问题导致服务器宕机,所以有必要监控JVM的内存.当达到一定值时,通过邮件及时通知,防止线上宕机造成 ...
随机推荐
- sum() over() 函数的使用
over不能单独使用,要和分析函数:rank(),dense_rank(),row_number(),sum()等一起使用. over函数的参数:over(partition by columnnam ...
- grep参数说明及常用用法
grep参数说明及常用用法 趁着午休的时间把自己经常使用的一些grep命令整理一下. 方便以后查看. 后续会逐步把awk/sed/find等常用的命令理一理. 增强下记忆. 也算是对得起自己了. ^^ ...
- C++ 常见问题
1:保证编译后方法名不被修改: The: extern "C" { function declarations here in h file } will disable C++ ...
- [网络] C# NetHelper网络通信编程类教程与源码下载
点击下载 NetHelper.zip 主要功能如下所示 检查设置的IP地址是否正确,返回正确的IP地址 检查设置的端口号是否正确,返回正确的端口号 将字符串形式的IP地址转换成IPAddress对象 ...
- [DEncrypt] Encrypt--加密/解密/MD5加密 (转载)
点击下载 Encrypt.zip 这个类是关于加密,解密的操作,文件的一些高级操作1.Encrypt加密2.Encrypt解密3.Encrypt MD5加密看下面代码吧 /// <summar ...
- Oracle 11g 虚拟列 Virtual Column介绍
Oracle 11G 虚拟列 Virtual Column Oracle 11G 在表中引入了虚拟列,虚拟列是一个表达式,在运行时计算,不存储在数据库中,不能更新虚拟列的值. 定义一个虚拟列的语法: ...
- iOS与服务器端 GZip压缩问题
昨天搞了一天的GZip压缩,试了三种方式(libz库,ZipArchive,ASIHttpRequest),一开始都不成功.理论上三个应该都能用的,但我都不行.等我试到第三种方式的时候才知道,不是我的 ...
- ES6学习笔记之Promise
入职百度EFE团队实习已经三周了,实习中接触到了生产环境的技术和开发流程,大开眼界,和自己在学校接小作坊式项目是很不一样的体验.其中一个很大的感触是,ES6早已不是“选修”的尝鲜技术,而是已经全面普及 ...
- 将[{},{}]转为dict
经常遇到一种需求,需要把从数据库取出的数据,转为dict对象([{}, {},...]-->dict). rs = [{, , "name":"edf"} ...
- C#中Socket用法,多个聊天和单一聊天。
自己琢磨Socket刚刚几天,所以整理出来和大家共享一下.废话少说直接进入正题. 在C#中提供了两种网络服务,一种是Socket类,另一种是TcpListener(服务器),TcpClient(客户端 ...