[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 获取虚拟机信息的更多相关文章

  1. perl 获取目录信息

    1 #!/usr/bin/perl -w 2 use strict; 3 use FindBin qw($Bin $Script); 4 5 my $rp=$Bin; 6 print "th ...

  2. Python3对接华三CAS平台Api获取虚拟机监控信息-渐入佳境

    --时间:2021年2月3日 --作者:飞翔的小胖猪 说明 使用python对接华三CAS虚拟化平台,通过厂商提供的api接口获取每个集群下所有虚拟机的监控信息,并保存数据在本地的mariadb数据库 ...

  3. 使用Sigar获取服务器信息

    Sigar简介 Sigar是Hyperic-hq产品的基础包,是Hyperic HQ主要的数据收集组件.它用来从许多平台收集系统和处理信息. 这些平台包括:Linux, Windows, Solari ...

  4. (部署新java程序,程序报错,需copy的一个包)——java使用siger 获取服务器硬件信息

    mcat-siger.sh  查看是否安装siger rsync -aPuv /usr/lib64/libsigar-amd64-linux.so $i:/usr/lib64/ java使用siger ...

  5. 通过GeoIP2分析访问者IP获取地理位置信息

    原文链接:http://blog.csdn.net/johnnycode/article/details/42028841 MaxMind GeoIP2 服务能识别互联网用户的地点位置与其他特征,应用 ...

  6. 探索Windows Azure 监控和自动伸缩系列2 - 获取虚拟机的监控定义和监控数据

    上一篇博文介绍了如何连接Windows Azure: http://www.cnblogs.com/teld/p/5113063.html 本篇我们继续上次的示例代码,获取虚拟机的监控定义和监控数据. ...

  7. [博客迁移]探索Windows Azure 监控和自动伸缩系列2 - 获取虚拟机的监控定义和监控数据

    上一篇博文介绍了如何连接Windows Azure: http://www.cnblogs.com/teld/p/5113063.html 本篇我们继续上次的示例代码,获取虚拟机的监控定义和监控数据. ...

  8. Java运用第三方开源jar包sigar.jar获取服务器信息

    通过使用第三方开源jar包sigar.jar我们可以获得本地的信息 一.准备工作 (1)下载jar包和相关文件 资源链接:百度云:链接:https://pan.baidu.com/s/1nxccJHJ ...

  9. Java获取虚拟机内存和操作系统内存及其线程

    为什么要获取虚拟机内存和操作系统内存呢? 虚拟机内存,这里主要指JVM.为了防止有的时候因为JVM内存问题导致服务器宕机,所以有必要监控JVM的内存.当达到一定值时,通过邮件及时通知,防止线上宕机造成 ...

随机推荐

  1. Python爬虫获取知乎图片

    前段时间想抓点知乎问题中的图片,了解了下爬虫,发现还是Python的简单方便,于是做了点尝试. #coding=utf-8 import urllib import re def getHtml(ur ...

  2. Tomcat 的 SSL 配置

    本教程使用 JDK 6 和 Tomcat 7,其他版本类似. 基本步骤: 使用 java 创建一个 keystore 文件 配置 Tomcat 以使用该 keystore 文件 测试 配置应用以便使用 ...

  3. JVM体系结构

    为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/5187049.html ...

  4. bootstrap02导航菜单

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  5. dhcp源码编译支持4G上网卡

    1. tar xvzf dhcp-4.2.5-P1.tar.gz 2. ./configure --host=arm-linux ac_cv_file__dev_random=yes 3. vi bi ...

  6. css3中允许单词内断句word-wrap和怎么处理断句word-break

    首先说一下:浏览器的默认行为,在一行中几个单词 排列着,如果最后一个长单词 太长时 首先是移到下一行,如果该单词的长度大于父元素的宽度,会溢出. <!doctype html> <h ...

  7. (转)php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法

    php 获取今日.昨日.上周.本月的起始时间戳和结束时间戳的方法,主要使用到了 php 的时间函数 mktime. 下面首先还是直奔主题以示例说明如何使用 mktime 获取今日.昨日.上周.本月的起 ...

  8. SQL语句操作文件

    -----先开启命令exec sp_configure 'show advanced options', 1; reconfigure; exec sp_configure 'xp_cmdshell' ...

  9. Bootstrap: 样式CSS:carousel轮换 图片的使用

    Bootstrap 轮播(Carousel)插件 Bootstrap轮播(Carousel)插件是一种灵活的响应式的向站点添加滑块的方式.除此之外,内容也是足够灵活的,可以是图像.内嵌框架.视频或者其 ...

  10. swift 赋值判断

    . var name:String? = "Wing" var geting = "Hello!" if let thisname = name{ geting ...