WMI query returning incomplete results - perl

I'm working on a perl script that is used to check whether a number of services are running. To achieve this, we are using WMI to query remote Windows servers:
my $WMI_locator = Win32::OLE->new('WbemScripting.SWbemLocator');
$WMI_locator->{Security_}->{AuthentificationLevel} = 6;
my $computer = $WMI_locator->ConnectServer($server, 'root\cimv2', $adminuser, $adminpasswd);
my $services = $computer->ExecQuery('SELECT * FROM Win32_Service', 'WQL', $flag_return_immediately | $flag_forward_only);
This code snippet works perfectly when executed on my dev laptop. However, strange things happen when I try to run it from the production server: for some remote windows computers, I can only get about half the Services list.
I have looked into this, and found that the issue is only happening on servers with a lot of services (around 150), and for which there's a difference in the average ping (~60ms on local, ~215ms on production server). The issue seems to come from WMI rather than perl; I have tried to query the servers from the DOS command line, and I'm getting an error when trying to get the services, although querying the CPU works just fine :
E:\>wmic /NODE:server /USER:adminuser /PASSWORD:adminpasswd SERVICE GET Caption, State
Node - server
ERROR:
Code = 0x800706be
Description = The remote procedure call failed.
Facility = Win32
E:\>wmic /NODE:server /USER:adminuser /PASSWORD:adminpasswd CPU GET Name, Status
Name Status
Intel(R) Xeon(R) CPU X5650 # 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 # 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 # 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 # 2.67GHz OK
Given that, I'm guessing the issue is network related, but we're now delving in a country I'm not familiar with. Is there some parameter I have missed and/or something wrong with the way I'm doing things?
Thanks for your answers!

This error is almost always (although not exclusively) caused by multiple instances of different versions of SQL server. To narrow down the problem try WMI Diagnostic Utility, it's designed to help with this type of problem.

Related

I have a Problem with my Minecraft::tickEntity on my Minecraft Server

Im running a minecraft Server on a: Intel(R) Xeon(R) CPU E5-2620 v2 # 2.10GHz
I only play with up to 5 friends. I dont know how to fix the "lags" without to use a plugin which limit the mobs.
Here are the timings:
https://timings.aikar.co/?id=0fee38d9fe2f4351a7f651e59b8d313f
Try installing plugins such as ClearLagg, automated restarts and try making the server into onlinemode = true as it performs better.
If you know how to use Java, you can just limit the amount of mobs/entities spawning, then keep checking in a loop if the time == your time you set for example 3 am and run /restart as console.

What is the proper way to check if HyperV is running?

I am trying to write a powershell script to install and set up Hyper-V machines. The install seems to be ok, however, I get contradictory responses from the system.
Basically, I use the (gcim Win32_ComputerSystem).HypervisorPresent to determine if HyperV is running.
It return False.
There is a similar class with the same member (gcim CIM_ComputerSystem).HypervisorPresent what is also returning False.
Also found this question How do you check to see if Hyper-V is enabled using PowerShell?
and this state property is Enabled
Do I miss something? These queries aren't the same? Could you point if any of these are deprecated?
Am I totally fooled, and Enabled means the system is capable to run HyperV, but actually it is not running?
CIM and WMI are a long tale but the short summary is that WMI is a Microsoft implementation of the OMI Standards defined by the DMTF, the Distributed Management Task Force, to come up with an industry wide standard. So, of course, creating one new standard resulted in a bunch of different implementations, which are basically their own standard.
But otherwise CIM and WMI can be thought of as different gateways to the same information for Windows computers. Different doors to the same house. More on that history and the distinctions here.
When I run the PowerShell commands you shared (either of them) on my machine with Hyper-V present, even when running as a standard, non-admin user, I get True back for both.
You can also check to see if the BIOS firmware has virtualization enabled by looking in the CIM_Processor class.
(Get-CimInstance win32_processor).VirtualizationFirmwareEnabled
True
You could also check to see if the Windows Feature is installed but that doesn't give you the full picture (what if the Windows feature is enabled in an image applied to a machine without virtualization components enabled in the BIOS, for instance.)
[ADMIN] C:\>(Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State
Enabled
Also, that technique 👆 requires admin permissions.
Another way, and maybe the easiest is to check is to see if the Hyper-V Computer Service is running, which is needed for any VMs to launch, and can only run if everything else on the machine is done correctly to enable Hyper-V.
Get-Service vmcompute
Status Name DisplayName
------ ---- -----------
Running vmcompute Hyper-V Host Compute Service
We used to deploy servers with a MDT Task Sequence and enable Hyper-V along the way. It required reboots and special commands to run to apply the right bios settings. Then, we could enable the Windows Features, but those required two reboots, so it was quite tricky to handle with most imaging systems. Our final 'Sanity Check' was whether the Hyper-V compute service was running.

Get CPU model name using Proxmox API

I use Proxmox REST API to get info about hypervisors. I am able to iterate nodes/storages/qemu and get basic info about every item. Like this is path for storages: $path = "/nodes/$nodeId/storage"; But I can't find an exact CPU model name like 24 x Intel(R) Xeon(R) CPU E5-2620. Can somebody show me the path where I can find CPU model name?
EDIT: As mentioned in the comment to this answer, this information is present in the status API Endpoint for the specific node.
Here are the API Documents for Proxmox VE. If you step down through the tree you can see all of the available API endpoints for nodes/$nodeID including storage as you mention.
I no longer have a Proxmox server at home to test with. However, after looking through the options available via the API documentation, it appears to me that hardware is the only other endpoint in the tree that would normally contain this information. And it seems to only provide information about PCI devices. Which CPUs haven't been for a very long time.
So this leads me to conclude that the Proxmox VE API does not provide information about the CPU of the hypervisor. I'm sure you already know this, but if you are able to refactor your requirements to run a command on your Proxmox server over SSH, then it is quite easy to retrieve the information you want with lscpu. EG:
$> lscpu | grep Model\ name
Model name: Intel(R) Xeon(R) CPU X5482 # 3.20GHz

Is any way to get HP servers Errors Remotely without iLo GUI?

I have more than 200 HP servers in my company branches and I want to automatically monitor server hardware errors. I can see all servers in my WAN.
I want to write a program to monitor HP servers remotely. My application must call an API or other functions remotely, and then get results from servers. After that I can send error signal to my administrators if needed, and my alarm system can read this information and etc. Is any API (or HP Proliant facilities) to get hardware errors and warnings remotely?
The Errors I want to monitor are:
Raid disk errors
Power Errors
CPU Fan Errors
I cant see more than 200 servers iLo GUI every day to monitor errors.
Yes, there is a way to monitor iLO via API. You should be able to integrate your application to the iLO RESTful API. there are some monitoring examples available on GitHub Python library.
you can get things like rest/v1/Managers/{item}/ActiveHealthSystem you might want to look into the complete data model.
Ana
HPE Employee

How to determine if EMC PowerPath is installed on an ESX host using PowerCLI

TL;DR How can I use PowerCLI to determine if EMC PowerPath is installed on an ESX host?
I am attempting to write a script that will perform a host-masking operation when moving a LUN from one storage group to another. This is to accommodate the All Paths Down error that can occur due to a race condition in ESX 4.1. The steps are described in VMWare KB 1015084 and 1009449. These steps are written for use from the service console. I want to avoid scripting SSH activity and instead do the entire thing in Powershell/PowerCLI.
In our environment, we are using EMC PowerPath on most - but not all - of our hosts. This LUN masking only needs to be performed on hosts where PowerPath is installed, so I am attempting to test each host to determine this.
I have been pulling my hair out trying to determine how to do this with PowerCLI. If connected to the ESX service console, the command esxcfg-mpath --list-plugins will show if PowerPath is installed. In the vCenter GUI, it can be determined by:
Select Host -> Configuration -> Storage Adapters -> Select Adapter -> View Devices -> Examine "Owner" column
Using get-scsilun in PowerCLI returns an object that contains all this information except this Owner column.
I am stumped. I had hoped that a get-esxcli object would have some kind of equivalent methods, maybe in satp or nmp, but so far I can't find anything.
As suggested, I'll answer my own question:
The answer is: $esxcli.corestorage.plugin.list() will return a list of plugins installed on the host.
To get this information from PowerCLI 6.5 you can use the following:
(Get-ESXCLI -VMHost <host>).Storage.Core.Plugin.List()