List for troubleshooting Process and threads on Linux

To the get the sum of all threads running in the system:

ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'

To get the number of threads for a given pid:

ps -o nlwp <pid>

Locate a Process

top

or

ps

To display all process names, use the following command –

$ ps -e

List the process associated with  a service/program

ps aux | grep my_service /  PID

To Kill a Process

kill PID

To see the thread count of process, use the following command-

$ cat /proc/<pid>/status

How to Check if Your Linux System is 32-bit or 64-bit Tricks and tips to find the architecture of a running linux machine

It’s always a good idea to know some basics about the operating system you’re running on your computer. For example, you may need to know whether you’re running a 64-bit or 32-bit system so you know which file to download for a program you want to install.

We will show you several different ways of checking whether your Linux system is 32-bit or 64-bit. Some provide additional information beyond whether the system is 32-bit or 64-bit.

The first two methods involves the “uname” command, which prints system information to the screen. If you want more information than just whether your system is 32-bit or 64-bit, type the following command and press Enter.

uname –a

The following information is printed to the screen in the following order: kernel name, network node hostname, kernel release, kernel version, machine hardware name, processor type, hardware platform, operating system. You can find out what the Linux kernel is and what it does at How-To Geek.

The machine hardware name lists whether your system is 32-bit (“i686” or “i386”) or 64-bit (“x86_64”). Notice that the processor type and hardware platform also indicates 32-bit or 64-bit.

To use the “uname” command to only find out whether your system is 32-bit or 64-bit, type the following command and press Enter.

uname –m

This displays only the machine hardware name and indicates, as above, whether your system is 32-bit (“i686” or “i386”) or 64-bit (“x86_64”).

The “arch” command is similar to the “uname -m” command and prints to the screen whether your system is 32-bit (“i686”) or 64-bit (“x86_64”). Type the following command and press Enter.

arch

You can also use the “file” command with a special argument (“/sbin/init”) to find out whether your system is 32-bit or 64-bit. Type the following command and press Enter.

file /sbin/init

The following output is printed to the screen. The text outlined in red indicates whether your system is 32-bit or 64-bit.

No Guest OS Heartbeats are being received error Troubleshooting Migration compatibility warning: No guest OS heartbeats are being received, from local or remotely

Symptoms
When performing a vMotion migration, this compatibility warning is displayed:

Migration from source_server: No guest OS heartbeats are being received. Either the guest OS is not responding or VMware tools is not configured properly.

No guest OS heartbeats are being received
No guest OS heartbeats are being received

Resolution

This warning indicates that the VMware Tools are either not installed or are not running in the virtual machine.

This message is safe to ignore when performing a migration.

Workaround
To workaround the warning, perform one of these options:

  1. Ensure that the VMware Tools are installed in the virtual machine before performing a migration;
  2. Ensure that the virtual machine has been running long enough for the operating system to be completely started before performing a migration.
  3. Restart the VMware Tools service.

For Linux virtual machine, open shell/terminal and run the command:

  • /etc/init.d/vmware-tools restart

or

  • /etc/vmware-tools/services.sh restart

or

  • service vmware-tools {start|stop|status|restart|force-reload}

For Windows virtual machine, frm RDP session or directly on machine:

  1. Click Start > Run, type services.msc, and press OK.
  2. Right-click VMware Tools Service and click Restart.

You can execute a remote restart of the “VMtools” service from remotely using SC command from command prompt:

sc.exe config “[servicename]” obj= “[.\username]” password= “[password]”

SC Syntax

DESCRIPTION:
 SC is a command line program used for communicating with the
 Service Control Manager and services.
USAGE:
 sc <server> [command] [service name] <option1> <option2>...

The option <server> has the form "\\ServerName"
 Further help on commands can be obtained by typing: "sc [command]"
 Commands:
 query-----------Queries the status for a service, or
 enumerates the status for types of services.
 queryex---------Queries the extended status for a service, or
 enumerates the status for types of services.
 start-----------Starts a service.
 pause-----------Sends a PAUSE control request to a service.
 interrogate-----Sends an INTERROGATE control request to a service.
 continue--------Sends a CONTINUE control request to a service.
 stop------------Sends a STOP request to a service.
 config----------Changes the configuration of a service (persistent).
 description-----Changes the description of a service.
 failure---------Changes the actions taken by a service upon failure.
 failureflag-----Changes the failure actions flag of a service.
 sidtype---------Changes the service SID type of a service.
 privs-----------Changes the required privileges of a service.
 qc--------------Queries the configuration information for a service.
 qdescription----Queries the description for a service.
 qfailure--------Queries the actions taken by a service upon failure.
 qfailureflag----Queries the failure actions flag of a service.
 qsidtype--------Queries the service SID type of a service.
 qprivs----------Queries the required privileges of a service.
 qtriggerinfo----Queries the trigger parameters of a service.
 qpreferrednode--Queries the preferred NUMA node of a service.
 delete----------Deletes a service (from the registry).
 create----------Creates a service. (adds it to the registry).
 control---------Sends a control to a service.
 sdshow----------Displays a service's security descriptor.
 sdset-----------Sets a service's security descriptor.
 showsid---------Displays the service SID string corresponding to an ar
bitrary name.
 triggerinfo-----Configures the trigger parameters of a service.
 preferrednode---Sets the preferred NUMA node of a service.
 GetDisplayName--Gets the DisplayName for a service.
 GetKeyName------Gets the ServiceKeyName for a service.
 EnumDepend------Enumerates Service Dependencies.

The following commands don't require a service name:
 sc <server> <command> <option>
 boot------------(ok | bad) Indicates whether the last boot should
 be saved as the last-known-good boot configuration
 Lock------------Locks the Service Database
 QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
 sc start MyService

example:

(check status of the service)
sc \\you_server_name_or_ip query “vmtools”

(Stop the service)
sc \\you_server_name_or_ip query “vmtools”

(Start the Service)
sc \\you_server_name_or_ip query “vmtools”

From another server on the domain open a command prompt and type the following.
From another server on the domain open a command prompt and type the following.

Results

validation succeed
validation succeed

If your issue continues to exist, reinstall VMware Tools to ensure that you are on the latest version.

 

Installing VMware Tools in a Linux virtual machine How to install VMware Tools on linux Centos Virtual Machines

Purpose

This article provides steps to install VMware Tools in a Linux guest operating system using Compiler.

Note: For an overview of installing VMware Tools, see Overview of VMware Tools (340).

Resolution

Note: If your Linux distribution is not RPM-based, has a custom kernel, or is unsupported, use the steps below to compile VMware Tools, otherwise, see Installing VMware Tools in a Linux virtual machine using RPM (1018392).

To install VMware Tools in a Linux guest operating system using Compiler:

 

Note: If your Linux distribution is not RPM-based, has a custom kernel, or is unsupported, use the steps below to compile VMware Tools, otherwise, see Installing VMware Tools in a Linux virtual machine using RPM (1018392).

To install VMware Tools in a Linux guest operating system using Compiler:

  1. Ensure that your Linux virtual machine is powered on.
  2. If you are running a GUI interface, open a command shell.
    Note: Log in as a root user, or use the sudo command to complete each of these steps.
  3. Click VM in the virtual machine menu, then click Guest > Install/Upgrade VMware Tools.
  4. Click OK.
    Note: In some cases, verify that the CDROM device is Connected from within the Edit Settings option of the virtual machine.
  5. To create a mount point, run:
    mkdir /mnt/cdrom
  6. To mount the CDROM, run:
    mount /dev/cdrom /mnt/cdrom
  7. To copy the Compiler gzip tar file to a temporary local directory, run:
    cp /mnt/cdrom/VMwareTools-version.tar.gz /tmp/
    Where version is the VMware Tools package version.
  8. To determine the version of VMware tools, run:
    ls /mnt/cdrom
    You see output similar to:
    # VMwareTools-5.0.0-12124.tar.gz
  9. To change to the tmp directory and extract the contents of the tar file into a new directory called vmware-tools-distrib, run:
    cd /tmp
    tar -zxvf VMwareTools-version.tar.gz
  10. To change directory to vmware-tools-distrib and run the vmware-install.pl PERL script to install VMware Tools, run:
    cd vmware-tools-distrib
    ./vmware-install.pl
    Notes:

    • Complete the screen prompts to install the VMware Tools. Options in square brackets are default choices and can be selected by pressing Enter.
    • To compile VMware Tools successfully, you need gcc Compiler and Linux Kernel sources provided by your Linux distribution. Consult your Linux distribution documentation for details on methods to install these packages.
    • It is normal for the console screen to go blank for a short time during the installation when the display size changes.
    • Some warnings or errors are normal, like when a files does not exist.
    • Depending on the Linux distribution, your network service might restart after installation. VMware recommends that you invoke this command from the console and not remotely.
  11. If you are running a GUI interface, restart your X Window session for any mouse or graphics changes to take effect.
  12. To start VMware Tools running in the background during an X Window session, run:
    /usr/bin/vmware-toolbox &
  13. Depending on your environment, you may need to unmount the CD-ROM. To unmount the CD-ROM, run:
    umount /mnt/cdrom
  14. Depending on your environment, you may need to manually end the VMware Tools installation. To end the VMware Tools install, click VM in the virtual machine menu, then click Guest > End VMware Tools Install.
  15. To remove VMware Tools installation packages, run:
    cd
    rm /tmp/VMwareTools-version.tar.gz
    rm -rf /tmp/vmware-tools-distrib

Original Article by VMware KB >Here<

Inviare una Email in formato HTML con Powershell Formattate HTML e con Immagini nel corpo dell'email

[code language="powershell"]
function sendMail
{
Write-Host “Sending Email”

$Image = “Path1”
$Image1 = “Path2”

#Embed Image
$att1 = new-object Net.Mail.Attachment($Image)
$att1.ContentType.MediaType = “image/png”
$att1.ContentId = “Attachment”
$att2 = new-object Net.Mail.Attachment($Image1)
$att2.ContentType.MediaType = “image/png”
$att2.ContentId = “Attachment1”

#Mail body
$body = “<table style='width:100%'>
<tr>
<td align=left valign=top><img src='cid:Attachment' /></td>
</tr>
<tr>
<td align=left valign=top>My Test<br>
Directory: <a href='url'>Link</a><br><br></td>
</tr>
<tr>
<td align=left valign=top>Email inviata $(Get-Date -format F) <br><br></td> 
</tr>
<tr>
<td align=left valign=top>Do-Not Reply<br></td> 
</tr>
<tr>
<td align=left valign=top><img src='cid:Attachment1' /></td> 
</tr>
</table>”

#SMTP server name
$smtpServer = “server.smtp...”

#Creating a Mail object
$msg = new-object Net.Mail.MailMessage

#Add attachment to the mail
$msg.Attachments.Add($att1)
$msg.Attachments.Add($att2)

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure 
$msg.From = “email@sender.ext“
$msg.ReplyTo = “reply@sender.ext“
$msg.To.Add(“emailto@sender.ext“)
$msg.subject = “Subject Email”
$msg.body = $body
$msg.IsBodyHTML = $true

#Sending email 
$smtp.Send($msg)
}

#Calling function
sendMail

exit
[/code]

Lo script in Poweshell appena mostrato genera una email con queste caratteristiche:

  • Testo Formattato in HTML, e tabella all’interno (risulta più ‘responsive’, anche se non lo è);
  • 2 immagini allegate ed inserite nel corpo della email (si possono inserire N immagini, bisogna associare l’attributo ‘attX’ ‘ImageX’ e AttachmentX)
    #Embed Image
    $attx = new-object Net.Mail.Attachment($ImageX)
    $attx.ContentType.MediaType = “image/png”
    $attx.ContentId = “Attachment”;
  • Un link nel corpo dell’email (può essere una URL si un sito, o un link locale;
  • La data cui è stata generata l’email (formattata giorno-mese-anno-ora-minuti-secondi);
  • Attributi email: indirizzo del mittente, indirizzo per reply (può essere diverso dal mittente), indirizzo/i dei destinatari;
  • Server smtp non autenticato, su porta 25 e sena cifratura.

Lo script può essere schedulato normalmente con lo scheduler di Windows, funziona con tutte le versioni di powershell (consigliata comunque sempre l’ultima).

Il consiglio è di non inserire ne’ troppe immagini e ne’ troppo grandi. Quindi rimanere con un numero inferiore a 5, con formati png e con una grandezza di non più di 10kB.