• Contact Us
  • Home
  • About Us
  • News
    • Entertainment
    • Trending
  • IT
    • Code
    • Cloud
    • Linux
    • Splunk
  • Login
  • Register
Upgrade
CloudiBee
  • Contact Us
  • Home
  • About Us
  • News
    • Entertainment
    • Trending
  • IT
    • Code
    • Cloud
    • Linux
    • Splunk
No Result
View All Result
  • Contact Us
  • Home
  • About Us
  • News
    • Entertainment
    • Trending
  • IT
    • Code
    • Cloud
    • Linux
    • Splunk
No Result
View All Result
CloudiBee
No Result
View All Result
Home Linux

Perl script for listing VMware Tools status

cloudibee by cloudibee
February 2, 2013
in Linux
0
0
SHARES
25
VIEWS
Share on FacebookShare on Twitter
In your day to day operations as part of managing a virtual VMware datacenter, you may need to gather or perform a particular operation on a cluster alone or a individual datastore alone .. or something like that. Here is a sample Perl script that lists down the VMware Tools status on a particular datastore in your vsphere datacenter. This script is just a sample and helps you to understand how it works. You can modify this script to suit your need.

Note :

  • Please make sure you have Perl VI SDK installed on the box from which you are running this script.
  • Run it as ./scriptname. pl -server <VcenterServerNAme> -username <VcenterUserName> -dsname <DataStoreName>
  • The script will prompt for vcenter password.

#!/usr/bin/perl

use strict;
use warnings;
use VMware::VIRuntime;    #VMware vshere API
use Data::Dumper;
my %opts = (
    dsname => {
        type     => “=s”,
        help     => “Name of the datastore”,
        required => 1,
    }
);

Opts::add_options(%opts);
Opts::parse();
Opts::validate();
my $server   = Opts::get_option(‘server’);      # vsphere name
my $username = Opts::get_option(‘username’);    # vsphere username
my $password = Opts::get_option(‘password’);    # vsphere password
my $dsname   = Opts::get_option(‘dsname’);      # datastore name

Util::connect();
my $dc = Vim::find_entity_views( view_type => ‘Datacenter’ );
my @ds_array = ();
foreach (@$dc) {
    if ( defined $_->datastore ) {
        @ds_array = ( @ds_array, @{ $_->datastore } );
    }
}
my $datastores = Vim::get_views( mo_ref_array => @ds_array );
foreach (@$datastores) {
    if ( $_->name eq $dsname ) {
        print “Datastore name : ” . $_->name . ” nn”;
        performVMOps($_);
    }
}

Util::disconnect();
exit;
# Completed

sub performVMOps {
    my ($datastore) = @_;
   
    my $vm_views = Vim::get_views( mo_ref_array => $datastore->vm );
    foreach (@$vm_views) {
        if ( !( $_->config->template ) ) {
            my $host = $_->name;
            if ( $_->runtime->powerState->val eq ‘poweredOn’ ) {
                if ( $_->guest->toolsRunningStatus eq ‘guestToolsRunning’ ) {
                    print “t ” . $_->name . ” – VMware tools is running n”;
                }
                else {
                    print “t ”
                      . $_->name
                      . ” – VMware tools status is not OK n”;
                }
            }
            else {
                print “t ” . $_->name . ” – is powered-off n”;
            }
        }
    }
} 

Table of Contents

  • You might also like
  • Linux Change Password Command: Change password expiry in Linux
  • Top Open Source Email Servers

You might also like

Linux Change Password Command: Change password expiry in Linux

April 7, 2021
Email Servers

Top Open Source Email Servers

September 7, 2021

 

Previous Post

OCFS2 cluster – quick setup guide

Next Post

Pocket guide for netapp commands

cloudibee

cloudibee

Related Posts

Linux

Linux Change Password Command: Change password expiry in Linux

by cloudibee
April 7, 2021
Email Servers
Linux

Top Open Source Email Servers

by cloudibee
September 7, 2021
Linux

How to Determine Redhat Versions Command

by cloudibee
May 27, 2022
Linux

How-to Linux List Processes in 3 Simple Commands

by cloudibee
May 27, 2022
Linux

What is Cron Job in Linux?

by cloudibee
May 27, 2022
Next Post

Pocket guide for netapp commands

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Premium Content

NaviSite Changes the Cloud Computing Landscape by Offering Cloud-based Managed Services

May 31, 2022

Loadbalancer

September 28, 2021

Voxel VoxCLOUD

May 27, 2022

Browse by Category

  • Business
  • Cloud
  • Code
  • Entertainment
  • finance
  • Game
  • Health
  • IT
  • Lifestyle
  • Linux
  • Marketing
  • Misc
  • News
  • SEO
  • Services
  • Splunk
  • Sports
  • Tech
  • Technology
  • Tipes
  • Tips
  • Uncategorized

Browse by Tags

algorithm Apache Apache2 AWS Bash bash history Bind Blacklists Buffer C C++ CentOS Cerner chage Cloud Cloud Computing Cloud jobs Cloud Storage Cloud Suite Commands Compliance Cron job Debian Directory DMS DNS Docker Dovecot drop cache Email servers Enteprise Cloud Enterprise External FAT32 Format kernel Linux linux kernel Nirvanix passwd Sendmail SSH SSL Terminal Ubuntu

About CloudiBee

cloudibee logo


CloudiBee is an open-source for people who love technology. Here we will be sharing lots of technical information over the web so that a lot of people visit us and gain some knowledge. We are a completely open to all platform. We assure you that you can easily get any info and updated news about the tech world from us. Let's begin with us!

Hot Topic

Gift Flowers as a Token of Appreciation

by mindmingles
July 26, 2022
0
Flowers

Flowers are unquestionably the best gift to give to loved ones. It can express feelings that most people forget to...

Read more

Recent News

Business

5 tips to ensure that your movers are always on time.

July 21, 2022
Tips

Flake ice machine for all who want to grow

July 18, 2022
Technology

Launching Progressive Web Applications on App Stores in 2022

July 16, 2022

CloudiBee. © 2021. All Rights Reserved

No Result
View All Result
  • Contact Us
  • Home
  • About Us
  • News
    • Entertainment
    • Trending
  • IT
    • Code
    • Cloud
    • Linux
    • Splunk

CloudiBee. © 2021. All Rights Reserved

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In