Anwendungsvirtualisierung, Internet der Dinge und Cloud Computing, Blog von Sacha Thomet

Uncategorized

Opfer des guten Rufes – zu wenig freie pooled Desktops frühzeitig erkennen

Der Citrix Director ist wirklich kein schlechtes Werkzeug und mit der Version 7.7 wurde es sogar noch um einiges besser da nun auch Emails versendet werden können. Aber ein Problem haben wir zurzeit in der Firma trotzdem, die unpersönlichen virtuellen Desktops welche für den Fernzugang genutzt werden, sind auf Grund guter Mund-zu-Mund Propaganda immer populärer. Und nun möchten wir gerne wissen wann es knapp wird bevor keine Desktops mehr zur Verfügung stehen. Natürlich kann ich mir täglich die Zahlen im Director anschauen, aber ich würde eigentlich gerne vom System informiert wenns eng wird.

Dazu habe ich nun ein ganz kurzes Script gemacht, welches sobald die Anzahl freier Desktops einen definierten Schwellwert unterschreitet eine Email auslöst:

low-free-desktop

Das Script ist auf GitHub:

https://github.com/sacha81/Citrix-XD-Alert-low-free-desktops

Leerzeichen und Punkte in StoreFront 3.5 Farmnamen vermeiden!

In den vergangenen Tagen habe ich meine bestehende StoreFront 3.01 nach StoreFront 3.5 aktualisiert, in einigen Umgebungen hatte ich dann eine böse Überraschung. Es sah eigentlich so aus als wäre alles gut und würde alles laufen, aber dann bekam ich die Meldung dass die Benutzer keine Anwendungen oder Desktops mehr starten könnten.

Auf dem StoreFront Server sah ich einen Warning Event von Citrix Store Service “ Failed to launch the resource “Farm Name.ApplicationName” as it was not found.

SF35_blanks_error-event28

Die Ursache für den Fehler war ein Leerzeichen und ein Punkt in meinem Farmnamen, sieht aus als wäre das ein Bug in StoreFront 3.5, man kann etwas konfigurieren dass dann nicht funktioniert!

SF35_blanks_error-config

Nachdem ich den Namen auf xa65farm geändert hatte, lief alles wieder glatt.

Etwas grossartiges ist passiert – Ich bin CTP !

Vor 2 Tagen habe ich dieses sehr erfreuliche email erhalten:

„Hello Sacha,
Congratulations! You have been selected to receive the Citrix Technology Professional (CTP) award! We’re thrilled to welcome you to this elite family group of technology experts!“

In den vergangenen Monaten und Jahre habe ich einige für die Citrix Gemeinde getan, einerseits mit dem teilen meines Wissens auf meinem Blog, aber ich war auch aktiv auf Twitter, im Citrix Forum und weiteren sozialen Medien.An der Citrix Synergy 2015 konnte ich bei der GeekOvation auftreten und habe dort auch den ersten Preis gewonnen. Weiter leite ich zusammen mit Stefan Beckmann ehrenamtlich die Schweizer Citrix User Group. Auch habe ich mich zur Verfügung gestellt, bei der Entwicklung des Citrix Expert Examen  1Y1-401 mitzuhelfen.

Ich liebe es etwas in der Community zu bewegen und mein Wissen zu teilen und zu erweitern. Vieles davon kostet mich natürlich Zeit und ich verdiene dabei nichts, für mich stimmt das aber so, es ist meine Passion. Nun habe ich doch eine grosse Belohnung erhalten, dieser Award ist für mich eine sehr grosse Ehre und Anerkennung.

Was ist denn dieser CTP Award?

Dieses Program ist die höchste This program is the highest Anerkennung welche ein Citrix Experte erhalten kann und definitiv einen Meilenstein in meiner beruflichen Karriere.

ctpMehr Informationen zum CTP Program sind hier zu finden: https://www.citrix.com/community/ctp.html

Mehr über die CTP 2016 class hier:
https://www.citrix.com/blogs/2016/02/04/welcome-ctp-class-of-2016 

Ich bin äussert dankbar das ich als CTP gewählt wurde und ich bin sicher das die Leute die mich umgeben eine Mitverantwortung tragen für meinen Erfolg.

Ich möchte somit hier DANKE sagen!

  • An meine Famile, welche mich in meinen Vorhaben immer unterstützt, auch wenn nicht jeder weiss was ich da genau tue 🙂
  • An meine Arbeitskollegen und meinem Arbeitgeber Die Mobiliar
  • An Citrix, im speziellen Perrine Crampton – Sie hat mir das erfreuliche Email gesendet
  • An die CTPs welche ich das letzte Jahr an der Citrix Synergy beim GeekSpeak-Tonight mit der GeekOvation kennenlernen durfte,
    dabei speziell bei Aaron Parker welcher mein GeekOvation Mentor war und mich für die Präsentation unterstützt hat.
    Aber auch an Carl Webster welcher mich später mit PoSh Zeugs geholfen hat. Natürlich aber auch bei Jo Harder, GeekOvation MC (Mistress of Ceremonies), welche mich gekrönt hat:-)
  • An meine derzeitigen und aber auch früheren Arbeitskollegen welche mich jeweils unterstützt haben.
  • An alle anderen die mich Unterstützt haben und ich hier vergessen habe. (Sorry!)

Und natürlich möchte ich nicht vergessen hier auch den anderen neuen CTPs zu gratulieren:

CTP2016

Und nun? 

Tja, nun wird der druck was an die Community abzuliefern noch grösser, schliesslich muss ich nun was zurück geben. Ich werde mich natürlich weiterhin in den Forum beteiligen und auch hier mein wissen in Blog Artikeln teilen. Ich fühle mich auch verpflichtet technische Präsentationen zu halten, eine gute Gelegenheit meine Englischkenntnisse etwas auf die Prüfung zu stellen.

Happy New Script – PVS 7.7 HealthCheck

Bald ist Neujahr und ich möchte euch fürs 2016 nur das Beste wünschen! Etwas ganz gutes habe ich euch schon vor dem neuen Jahr, nur einige Stunden nach dem Release vom Citrix Provisioning Server 7.7 kann ich euch auch das neue Health Check Script dazu übergeben. 

Heute hat Citrix die Produkte XenApp/XenDesktop 7.7 und Citrix Provisioning Services 7.7 herausgegeben, mit dabei sind eine Menge von neuen Features aber das wichtigste dabei neben dem Support für Windows 10 ist … Trommelwirbel …. die neue Power Shell APO für Citrix Provisioning Services. PVS mit PoSh bei 7.6 und früher war ein Sch….
Was sonst noch neu ist im PVS 7.7 hier: PVS 7.7 New in this release

Jetzt kommt PVS endlich mit einer echte PoSh API welche mehr zurück gibt als nur einen Haufen Strings. Ich konnte mit dem PVS 7.7 Tech Preview rumspielen und bin desshalb auch bereits ready mit dem komplett neuen Script. Achtung, für Versionen 7.6 und tiefer muss immer noch das alter Script verwendet werden. Diese Neue Version ist gültig ab 7.7 und wir dann für die Nachfolgenden Versionen gepflegt.

pvs77

Wenn ihr neue Funktionen möchtet oder einen Fehler melden wollt, so tut dies bitte direkt auf GitHub.

Wie bereits geschrieben, diese Version geht nicht mit 7.6 und früheren Versionen, wenn ihr dazu ein HealthCheck braucht, gibt es hier das alte Script:  Citrix PVS HealthCheck 

Das Script findet ihr hier auf GitHub:

https://github.com/sacha81/citrix-pvs-healthcheck

Steure ein MyStrom Wifi Switch mit einem Schalter (und ifttt oder octoblu)

mystromSome weeks ago I bought my first smart plug from MyStrom. If you are living  in Switzerland you have only a limited choice of smart plugs because of the non EU standard plug (T13).

MyStrom is pretty cool because it mets almost all my requirement, there is a possibility to measure to power consumption within two rates (day and night), it’s controllable with the mobile phone app and there is a nice web interface.

But one thing I miss, I cannot react to triggers and power of the smart plug on a defined event. Like already in an earlier post mentioned there is a REST API which allows to control the plug from the internal network. (See Another LaMetric IoT script – power control)

Last day’s I just found the API documentation which allows to control the MyStrom out of the cloud:
https://mystrom.ch/mobile/ 

So I have now all to connect this Thing to the Internet and react on a trigger.

Possibility 1: The everything imaginable way,
MyStrom and Octoblu

mystromlogo      +      ocoblu

If you are using Octoblu beta, which is currently available for everyone for free you can create very intelligent workflows to control your smart plug. You can react to twitter and power of or on depending what is twittered, you can power off your heater as soon a temperature is reached, you can stop charge as soon your device have a defined state of charge.

The Things you connect use with Octoblu are nearly infinite.

mystrom-octoblu

Octoblu is for advanced use, and to be honest I’m also on the learning phase! I do not describe here more details for this case. There are a lot of sample blueprints on https://www.octoblu.com .  Octoblu was acquired by Citrix in 2015.

Possibility 2: The easy way,
MyStrom and IFTTT

 mystromlogo      +      iftttlogo

This way is suitable for „Home use“ and for people who only want to create a simple workflow where a trigger initiate for example a Power On or Power Of of the smart plug.

All what you need is a Control-Script on a Webserver with PHP on the Internet, and a IFTTT account.

How it works: The script is very simple, it just handle the  authentication process on the API, read the AuthToken out of the JSON answer and Push out the payload with the AuthToken. IFTTT just take the trigger and call the script with the username, passwort and the payload which you can build from the API

Example: I want to control my smart plug by twitter, if I twitter #lightsoff

Step 1:

Take this script and put it on your webserver:


Step 2:

Create a recipe on IFTTT, use Twitter as Trigger and Maker as Action. In maker you create your request:

[yourwebserver]myStromAuthenticator.php?email=[youraccountemail]&password[yourpassword]&payload=[yourpayload]

e.g. the payload to turn of the device with Mac 64002D012325 is: https://mystrom.ch/mobile/device/switch?on=false%id=64002D012325

The result should be that:

mystrom-ifttt-572x1024

You create 2 of those recipies, one to Power On and one to Power Off

Now you can twitter you defined hashtags to control your smart plug.

Ein weiteres LaMetric IoT Script – Stromsteuerung

Da ich momentan Urlaub habe, ist hier ein weiterer Artikel der aber nichts mit Virtualisierung zu tun hat …

I combined my new „gadgets“ the LaMetric time and my new wifi Smart-Plug from MyStrom. The goal was to report the current power consumption of power plug and the possibility to control the plug with the smart ticker.

MyStrom has a very straight forward API (https://mystrom.ch/en/mystrom-api), and the possibility to create apps for LaMetric is pretty easy what I’ve already mentioned in an past blog post.

All what is needed to implement this solution is:

  • a web server which can parse PHP
  • two small scripts
  • and a private app for LaMetric

This is the script to see the current power consumption:

{
    "frames": [
        {
            "index": 0,
            "text": "  Watt",
            "icon": "i1692"
        }
    ]
}

I just read the content from the API, which is already in JSON format, but I reformat it that it is in that way which I need to bring it to the LaMetric.
This is the script to control the power outlet:


And the LaMetric private app:

This simple poll app call the script on the webserver (192.168.1.20) with the parameter of the MyStrom plug (192.168.1.59).

On button action the controller script is launched with change the status (off to on or visa verse)

myStromApp-mini

(192.168.1.59 is the ip of my Power outlet. 192.168.1.20 is the address of my web server, this can be a raspberry pi or a Synology.)

Überwache die Profile Verzeichnisse

Bereits vor Jahren als ich als Citrix Admin gearbeitet habe waren die anwachsenden Benutzerprofileverzeichnisse immer wieder ein Thema. Klar ist das Administratorenleben nun mit neueren Technologien wie dem Citrix User Profile Manager oder anderen 3rd Party Lösungen einfacher geworden, Profile Streaming und Exclusions können viel wert sein.

Trotzdem ist es immer noch ein Thema das als Citrix Admin oder Engineer berücksichtigt werden muss. In einer früheren Firma habe ich  Tool’s wie Treesize  (https://www.jam-software.com/treesize/) oder WinDirStat(http://windirstat.info) gearbeitet. Aber es gibt halt firmen die kein Geld für solche Tools ausgeben wollen oder auch OpenSource nicht trauen, bzw. der Softwareintegrationsprozess kompliziert und langwierig ist.

So hatte ich den Ansatz dieses Profilgrössenproblem mit Bordmitteln zu lösen. Ich habe nun ein kleines PoSh-Script erstellt welches mir rekursiv durch meine Profilordner läuft und die Grössen ausgibt.

#==============================================================================================
# Created on: 10.2015 Version: 0.3
# Created by: Sacha Thomet
# Filename: GetSubdirSizes.ps1
#
#
# Description: This script checks some Citrix Provisioning Server, Farm, vDisk & Target device parameters.
#
# Prerequisite: None
#
# Call by : Manual
#
# Change Log:
# V0.1 first version
# V0.2 only 1 recursive subfolder
# V0.3 corrections of calculation
#
#==============================================================================================



$path = "\localhostC$tempprofiles"
$top = "4000"
$outputpath = "C:tempSubdirSize-Report.txt"



Function Get-FolderSize
{
 $Sizes = 0
 ForEach ($Item in (Get-ChildItem $Path))
 {
 If ($Item.PSIsContainer) {$Sizes = (Get-ChildItem $path"$Item" -recurse | Measure-Object -property length -sum).sum}
 Else {Write-Host "No Subfolder"}



 $SizeFormated = "{0:N2}" -f ($Sizes/1MB)
 New-Object PSObject -Property @{'Folder'=$Item;'Size'=$SizeFormated }
 }
}
$outfile = Get-FolderSize $path | sort -property Size –Descending |select -first $top
$outfile | out-file $outputpath
echo $outfile



IoT, LaMetric and mouse issues …

In summer 2014 I became a backer for the Kickstarter project LaMetric. LaMetric was advertised as a smart ticker for life and business. To be honest the Internet of Things (IoT) topic was not so present for me in summer 2014 and I just decided to spend some money for a cool gadget.

Last week I finally received my LaMetric Time and today I need to say it’s one of the coolest gadget I bought in the last months. With the acquisition of Octoblu, what Citrix made early this year and promoted on Citrix Synergy (especially on the GeekSpeak Tonight …) I’m now more aware of IoT an it’s possibilities!

LaMetric is the perfect IoT output device!

First LaMetric app

The creation of apps is pretty easy! On the LaMetric developper portal you can create your push or poll apps. With push you can transmit data to the LaMetric servers in JSON code. W ith pull it’s also easy, you just need a webserver on which you have a file in the correct format.

On this way I created the EuroMillions app which display the current Jackpot. The data are fetched from www.euro-millions.com and formatted with a small and simple PHP script:


{
 "frames": [
 {
 "index": 0,
 "text": "<?php 
$host = "http://www.euro-millions.com"; 
$filestring = file_get_contents($host); 
$startpos = 0; 
// <div class="est-jackpot">€30<span class="amount">Million</span></div>

while($pos = strpos($filestring, ">€", $startpos)) 
{ 
 $string = substr($filestring, $pos, strpos($filestring, "<span class=", $pos + 1) - $pos); 


 //echo $string. " "; 
 echo str_replace(">€","","$string");

 $startpos = $pos + 1; 
} 

?> Millions estimated in next Jackpot",
 "icon": "i616"
 }
 ]
}

Result:

LaMetric-EuroMillions

 

First IoT LaMetric Project

Problem

I’m living in an old farmhouse which is converted with some apartments, but it’s still a old house with a lot of wood. And the old problems … mouses. So I have now since some weeks 4 mouse traps installed, not the killing traps, only those which able me to take the mouse out of my apartment.

Problem: Every morning I need to check all mouse traps, because the traps are hidden positioned an annoying daily work. And with the risk that the mouse need to wait hours until I find them.

Concept

Now the concept of my first IoT project is to get alerted as soon a mouse get in a trap.

I want to solve this with:

  • a modified mouse trap with an attached window/door sensor, something like this http://store.wirelesstag.net/products/reed-kumosensor
  • an Octoblu workflow
  • and LaMetric as Output device.

The result must be this:

LaMetricMouse

Implementation

Need some hours … I have to learn how to handle  octoblu and learn a bit of JSON.

PoSh Script who alert me if I’m running out of pooled Desktops

Just a small one, last days I’ve created a small script who alert me if I’m running out of pooled Desktops.

If you run this script at regular intervals you will receive an email as soon you have less desktops free than you defined as threshold:

LowDesktopFree


#==============================================================================================
# Created on: 08.2015 Version: 0.2
# Created by: Sacha Thomet
# File name: Citrix-XenDesktop-Alert-low-free-desktops.ps1
#
# Description: Check for Free Desktops in DeliveryGroups
#
# Prerequisite: None
#
# Call by : Scheduled Task e.g every 10 minutes
#
# Changelog:
# V0.1 Initial Version, create report file from array FreeDesktopReport and attach this to the email.
# V0.2 Change from txt-file to formatted HTML-Mail
#
#==============================================================================================
if ((Get-PSSnapin "Citrix.Common.Commands" -EA silentlycontinue) -eq $null) {
try { Add-PSSnapin Citrix.* -ErrorAction Stop }
catch { write-error "Error Citrix.* Powershell snapin"; Return }
}
# Change the below variables to suit your environment
#==============================================================================================

# Variables what should be changed according your environment and wishes

$DeliveryGroups = @("Win7-Desktops","Win10-Desktops")
$minDesktops = 10
$directoraddress="http://citrixdirector.mycompany.ch"
$EnvironmentName="Production XenDesktop"

# E-mail report details
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$smtpServer = "mailrelay.mycompany.ch"

#=======DONT CHANGE BELOW HERE =======================================================================================

$mailbody = $mailbody + "<!DOCTYPE html>"
$mailbody = $mailbody + "<html>"

$mailbody = $mailbody + "<head>"
$mailbody = $mailbody + "<style>"
$mailbody = $mailbody + "BODY{background-color:#fbfbfb; font-family: Arial;}"
$mailbody = $mailbody + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse; width:60%; }"
$mailbody = $mailbody + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black; text-align:left;}"
$mailbody = $mailbody + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$mailbody = $mailbody + "</style>"
$mailbody = $mailbody + "</head>"

$mailbody = $mailbody + "<body>"
$mailbody = $mailbody + "This is the Low-Desktop-Alert for $EnvironmentName, if you receive this mail the value of free desktops is below the configured threshold of $minDesktops desktops! <br><br>"

$FreeDesktopReport = @()

foreach($dg in $DeliveryGroups)
{
$desktops = Get-BrokerDesktopGroup | where {$_.Name -eq $dg }
$CurrentDeliveryGroup = "" | Select-Object Name, Alert, DesktopsAvailable

# Write Array Values
$CurrentDeliveryGroup.Name = $dg

$CurrentDeliveryGroup.DesktopsAvailable = $desktops.DesktopsAvailable

if ($desktops.DesktopsAvailable -lt $minDesktops )
{
Write-Host "Number of free desktops to low for DeliveryGroup $dg, sending email"
# Add Line to Report
$CurrentDeliveryGroup.alert = "True"
}

$FreeDesktopReport += $CurrentDeliveryGroup
}

$mailbody += $FreeDesktopReport | ConvertTo-Html
$mailbody += "<br><br>Launch Citrix Studio or browse to <a href=$directoraddress>Citrix Director</a> see more information about the current Desktop usage<br>"

$mailbody = $mailbody + "<body>"
$mailbody = $mailbody + "</html>"

# If any record raises an alert, send an email.
if (($FreeDesktopReport | where {$_.alert -eq "True"}) -ne $null) {Send-MailMessage -to $emailTo -from $emailFrom -subject "********* Low free Desktop Alert for $EnvironmentName *********" -Body $mailbody -BodyAsHtml -SmtpServer $smtpServer }

Or download the Script here