Codelinguist's Blog

Manage bandwidth for application using Trickle in Ubuntu

Posted by c0del1ngu1st on August 17, 2013

Trickle lighweight bandwidth shaper commandline tool. Trickle can be limit application bandwidth, upload or download speed, and prioritizing daemons. You can prticular amount of bandwidth to a particular application.

Trickle works by taking advantage of the unix loader preloading. Basically it provides, to the application, the new version of the functionality required to send and receive data through sockets. Then limit traffic based on delaying to send and receive data throughsockets. trickle runs entirely in userspace and does not need root privileges.

Install Trickle
Sudo apt-get install tricle

Usage
Let us take a example here. You want to assign firefox 100KB/s doenloading and 70KB/s uploading limit.
trickle -d 100 -u 70 firefox

Limit the download bandwidth at 100Kbps for wget
trickle -d 100 wget http://cdimage.ubuntu.com/daily/current/precise-alternate-i386.iso

Daemon mode
In daemon mode, trickle can limit a group of programs to a fixed limit of bandwidth. To start the daemon, run the trickled command:

sudo trickled -d 20 -u 20

This will start the trickle daemon that will limit the total bandwidth available to all programs run via trickle to 20 K/s both up and down. So if you run a single program via trickle, it can consume 20 K/s. Two programs can each consume 10 K/s, etc.

Posted in Linux, Ubuntu | Leave a Comment »

Citrix Farm matrix server

Posted by c0del1ngu1st on May 9, 2013

The Farm Metric Server is a MetaFrame CPS server that is selected to correlate all farm metrics and server events as it relates to the entire farm. Currently, the only farm metric that is available is the application count for applications. Valid server events that are identified by the Farm Metric Server are server down, server up, metric green, metric red and metric yellow. Every time a server goes down or comes up, the Farm Metric Server is notified. The Farm Metric Server is notified anytime that a server metric changes thresholds.

By default, the first server on which you install Resource Manager becomes the Farm Metric Server. The Farm Metric Server interprets metrics that apply to the entire server farm (for example, application counts) and sends alerts when required. Citrix recommends that the Farm Metric Server be lightly loaded and, preferably, be a data collector. If necessary, you can change the Farm Metric Server to a different machine after installation.

The Farm Metric Server is also considered a CPS member server. It has the same responsibilities to the summary database functionality as other member servers. The only difference is that it also has the responsibility of the tasks associated with a Farm Metric Server.

Posted in Citrix, Farm, Farm Matrix server, Presentation Server, Server, Xenapp | Leave a Comment »

Script to stop Citrix Xenapp 4.5 services on your server.

Posted by c0del1ngu1st on August 19, 2012

We are facing a problem whenever the weekly reboot of servers occur the server then go into hung state. Its because some of Citrix services are not stopped properly. Here is a small VB script which will stop all Citrix services on your server. You can schedule this 15 minutes prior to your reboot.

The script attempts to stop each services with interval of 15 sec. So it will take few minutes to stop the services.

‘ VBScript Restart Service.vbs
‘ ——————————————————-‘
Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService, intSleep
strComputer = “.”
intSleep = 15000

‘On Error Resume Next
‘ NB strService is case sensitive.
strService = ” ‘Citrix ActiveSync Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Client Network’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix CPU Utilization Mgmt/Resource Mgmt’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Diagnostic Facility COM Server’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Encryption Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Health Monitoring and Recovery’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Independent Management Architecture’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix MFCOM Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Print Manager Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Services Manager’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix SMA Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix Streaming Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix WMI Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WSCript.Sleep intSleep
strService = ” ‘Citrix XML Service’ ”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colListOfServices = objWMIService.ExecQuery _
(“Select * from Win32_Service Where DisplayName =”_
& strService & ” “)
For Each objService in colListOfServices
objService.StopService()
Next

WScript.Echo “All Citrix services has stopped”
WScript.Quit
‘ End of Example WMI script to Start / Stop services

Posted in Application Virtualization, Application virtulization, Citrix, Script, Server | Leave a Comment »

Corruption is just a trending topic in India

Posted by c0del1ngu1st on August 14, 2012

We have been talking about corruption a lot these days, especially in this great country “India”. The basic question we need to ask is what exactly is corruption? What is causing corruption? We all want to bring drastic changes. That is why we are seeing Anna Hazare undergoing fast again and again. We haven’t achieved anything with that yet. What we are seeing is that another political party being formed.

Former President of India APJ Abdul kalam said if lokpal bill is passed it will only lead to filling of jails with such people. The corruption will still be there. To fight corruption, we should prevent people from becoming corrupt. Every youth should take oath that they will stop their father from indulging in any act of corruption. One should stand for knowledge which comes from creativity, righteousness and courage. In school we all are taught a subject moral science in which we are taught about values we should have in our life. But, as we grow up and becoming more and more wiser, the moral values starts evaporating. Some of us are lucky to have parents who have values and they taught their children the same. The corruption can only be eradicated if we work on ground level. We stop bribing in our day to day life.

Another person who is in limelight is Baba Ramdev. He is talking about black money a lot these days. The money by which his trust is formed is mostly black money donated by rich folks. Tehlka did a report on Baba ramdev in which they disclosed how he made his trust. How he betrayed local people there for a cause. 40% of our monitory transactions go unrecorded in any official revenue or tax records and we people talk about black money. We steal from government by not paying tax. We are worried about black money in Swiss, what about the money which is made black daily by us. We people are scared. It is very easy to point fingers on others. If we talk about administration, people work over there are one of us. Society is not formed by single person. Individual can’t change the rules. It’s we together who forms society. If we want to bring change in society we need to change ourselves and start following rules.

Posted in Uncategorized | Tagged: , , | Leave a Comment »

Citrix MFCOM script to get list of servers and their IP addresses on a farm

Posted by c0del1ngu1st on September 20, 2011

By using the following script you can get the list of servers along with their IP addresses published on a farm. The result would be generated in MS Excel. So you must have MS Excel installed on your system in order to execute it.

Code:

<package>

<job id=” FarmApplications”>

<runtime>

<description>

List Servers and their IP address for all apps in the farm.

</description>

</runtime>

<reference object=”MetaFrameCOM.MetaFrameFarm”/>

<script language=”VBScript”>

Dim wkbNew

Set objExcel = CreateObject(“Excel.Application”)

Set wkbNew = objExcel.Workbooks.Add

set wksNew = wkbNew.Worksheets(1)

wksNew.Activate

wksNew.Application.Visible = True

Dim theFarm,AppName ,anApp,aServer, Array()

Set oShell = WScript.CreateObject(“WScript.Shell”)

Set theFarm = CreateObject(“MetaFrameCOM.MetaFrameFarm”)

if Err.Number <> 0 Then

WScript.Echo “Can’t create MetaFrameFarm object”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

theFarm.Initialize(MetaFrameWinFarmObject)

if Err.Number <> 0 Then

WScript.Echo “Can’t Initialize MetaFrameFarm object”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

‘WScript.Echo “MetaFrame Farm Name: ” & theFarm.FarmName

‘WScript.Echo “”

Row = 1

Col = 1

maxServer = 0

wksNew.Cells(Row, Col).Value = “Server”

wksNew.Cells(Row, Col + 1).Value = “IP address”

For Each anApp In theFarm.Servers

Row = Row + 1

Col = 1

if Err.Number <> 0 Then

WScript.Echo “Can’t enumerate applications”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

wksNew.Cells(Row, Col).Value = aServer.ServerName

wksNew.Cells(Row, Col + 1).Value = aServer.IPAddress

numServers = anApp.Servers.Count

If numServers > maxServers Then

maxServers = numServers

End If

Next

For sCount = 1 To maxServers

wksNew.Cells(1, scount + 5).Value = “Server” & scount

Next

wksNew.Range(wksNew.Cells(2, 1), wksNew.Cells(Row, maxServers + 5)).Sort wksNew.Range(“A2”),,,,,,,xlNo

wksNew.Range(“B2”).Select

objExcel.ActiveWindow.FreezePanes = True

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).Select

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).Interior.ColorIndex = 16

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).Font.ColorIndex = 2

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).Font.Bold = True

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).HorizontalAlignment = 7

wksNew.Range(wksNew.Cells(1, 1), wksNew.Cells(1, maxServers + 5)).AutoFilter

wksNew.Range(wksNew.Cells(2, 1), wksNew.Cells(Row, maxServers + 5)).Columns.AutoFit

</script>

</job>

</package>

Execute on the any server of farm, whose information you want. Hope you enjoy executing this script.

Posted in Application Virtualization, Centralized Computing, Citrix, MFCOM, Script, Server | Leave a Comment »

My first Citrix MFCOM script

Posted by c0del1ngu1st on September 20, 2011

This is my first MFCOM script. MFCOM scripts are scripts for Citrix servers. MFCOM first appeared in 2001 as a hotfix for MetaFrame XP 1.0, which was released about 6 months prior to the hotfix release. This is my first MFCOM scripts.
The following is a simple Windows Scripting Host script. It prints out the name of the farm and some properties. To make reading the script easier, comments and explanations are inserted in between the code.

<package>

<job id=”Farm”>

<comment>

File: Farm.wsf

Description: A simple script displaying farm properties.

</comment>

<runtime>

<description>

A simple script displaying farm properties.

</description>

</runtime>

<reference object=”MetaFrameCOM.MetaFrameFarm”/>

<script language=”VBScript”>

Dim theFarm, theWinFarm

‘ Create MetaFrameFarm object

Set theFarm = CreateObject(“MetaFrameCOM.MetaFrameFarm”)

if Err.Number <> 0 Then

WScript.Echo “Can’t create MetaFrameFarm object”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

‘ Initialize the farm object.

theFarm.Initialize(MetaFrameWinFarmObject)

if Err.Number <> 0 Then

WScript.Echo “Can’t Initialize MetaFrameFarm object”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

‘ Get MetaFrameWinFarm2 object

Set theWinFarm = theFarm.WinFarmObject2

if Err.Number <> 0 Then

WScript.Echo “Can’t receive MetaFrameWinFarm2 object”

WScript.Echo “(” & Err.Number & “) ” & Err.Description

WScript.Echo “”

WScript.Quit Err.Number

End if

‘ Are you a Citrix Administrator?

if theWinFarm.IsCitrixAdministrator = 0 then

WScript.Echo “You must be a Citrix admin to run this script”

WScript.Echo “”

WScript.Quit 0

End If

‘ Print out the farm name.

WScript.Echo “MetaFrame Farm Name: ” & theFarm.FarmName

‘ Print out some of the MetaFrameWinFarm2 object properties.

WScript.Echo “MetaFrame WinFarm object properties”

WScript.Echo “DegradationBias : ” & theWinFarm.DegradationBias

WScript.Echo “UseClientLocalTime: ” &                                                                                                  theWinFarm.UseClientLocalTime

WScript.Echo “Press ENTER to exit…”

WScript.StdIn.Read(1)

</script>

</job>

</package>

Save it as farm .wsf on your server. Script will tell you the name of the server.
Hope you would enjoy running it.

Posted in Application Virtualization, Centralized Computing, Citrix, MFCOM, Script | Tagged: , | Leave a Comment »

Birth of Citrix servers

Posted by c0del1ngu1st on September 15, 2011

Concept of resource sharing has been there from long time. The practice of this computing model dates back to mainframes with green-screen terminals. Computing has changed dramatically since those days but the basic premise of “centralized” computing hasn’t changed a great deal.

The system used was centralized or server-based computing in which many users were able to share same computer resources. The approach was used because computers then cost hundreds of thousands, if not millions, of dollars to acquire and typically cost even more to maintain and operate and computers were at best the size of large cars, so distributing one to each user’s desk would be impossible for any corporation. The time has changed since then. At that time centrally managed end-user devices were the only option because of the reasons mentioned above but today they are optional.

The popularity of centralized computing waned for several years as the advent of the personal computer (PC) allowed end users to have the power of the mainframe on the desktop without the expense of the mainframe. Individual PCs gave rise to the need for networking, so we began to tie PCs together to allow the sharing of files and printers. Over time, our use of computers went from a centralized to a decentralized model as PCs were cheaper to maintain and purchase than mainframes and minicomputers. A host of new applications allowed for a much greater range of computing uses, such as word processing, spreadsheets, and e-mail.

We slowly moved from the point of placing computers on engineers’ desktops to placing computers on everyone’s desktop. We moved the majority of our computing power to the edge of the network, along with the majority of support issues. Anyone who has ever managed a network knows that purchasing the computer is the least expensive part of owning a computer. Maintenance, training, upgrades, viruses, and spyware all add up to the bulk of the cost over time for PC ownership. Several studies indicate that the initial capital outlay for the purchase of new computing hardware and software only accounts for about 10 percent of the actual cost over a three-year period (then you get to start all over!).

This process of suburban sprawl inside our networks continued unchecked for several years. With the passage of time, IT professionals started moving toward putting all those applications and tools that users run on their desktops to the central computers to manage the applications centrally on controlled, reliable, enterprise-grade hardware to increase uptime. We started creating highly available server “farms” to allow for reliable user connections instead of single points of failure. Thus the need of Terminal Services and Citrix servers was born.

Posted in Application Virtualization, Centralized Computing, Citrix, PC, Server | Leave a Comment »

Steve Jobs resigns as CEO

Posted by c0del1ngu1st on August 25, 2011

I have always said if there ever came a day when I could no longer meet my duties and expectations as Apple’s CEO, I would be the first to let you know. Unfortunately, that day has come. I hereby resign as CEO of Apple. I would like to serve, if the Board sees fit, as Chairman of the Board, director and Apple employee. As far as my successor goes, I strongly recommend that we execute our succession plan and name Tim Cook as CEO of Apple.
--Steve Jobs

Tech industry legend and one of the finest creative minds of a generaton, Steve Jobs, has resigned as CEO of Apple, arguing he can no longer meet his duties and expectations to the company.

The pancreatic cancer survivor, who co-founded Apple from a garage and brought the company back from the dead when industry figures including Dell founder Michael Dell were arguing it should be broken up and sold off, said he had maintained he would let people know if there ever came a day where he could no longer fulfill his duties as Apple’s CEO.

Jobs has long been the heart of the company, making its most important decisions on product and strategy and being Apple’s public face for new product announcements. Almost always clad in his signature jeans and black turtleneck, Jobs has an unparalleled ability to build buzz and excitement about Apple’s upcoming products.

Most of all, our hearts go out to Jobs and his family. The tech world just lost one hell of a leader.

Posted in Uncategorized | Leave a Comment »

Delete files from trash of different drives via command line

Posted by c0del1ngu1st on August 20, 2011

I have recently updated my Ubuntu OS. I am facing a lot of problems after that. Recently trash icon from my desktop disappeared. I have deleted some files from my drive but space was not freed. It was because the files were going to trash and they were not deleted from there. After playing with command line I got to know that files which we delete are in .Trash folder. Each drive has its own .Trash folder.

My drive’s name is ‘New Volume’ you need to navigate to that drive:

Laptop:~/Desktop$ cd /media/New\ Volume/.Trash-1000/files/

In this files folder you will have the files. you can remove the files by using command:

Laptop:/media/New Volume/.Trash-1000/files$ rm -r *

Hope this helps you troubleshooting your problem.

Posted in Uncategorized | Tagged: , , , , | Leave a Comment »

Shaken Japan, Unshaken hearts

Posted by c0del1ngu1st on March 15, 2011

Last week one of the most powerful earthquake hit Japan causing lot of damage of life and property. The earthquake was very powerful, powerful then we had in last century. Japan has done well to mitigate the loss which could had happen during any natural disaster. It spends more than any country spends on to itself from natural disasters. The trains were stopped immediately by pulling emergency brakes and no one died. There were no derailments. There were no collisions. There was no loss of control. One train was washed away by Tsunami.

The overwhelming response of Japanese engineering to the challenge posed by an earthquake larger than any in the last century was to function exactly as designed. Millions of people are alive right now because the system worked.

Lots of buildings survived due its earthquake resistant structure. Japanese buildings are designed to shake because the alternative is to be designed to fail catastrophically in the event of an earthquake. Far and away the worst thing that happened in the earthquake was that a lot of people drowned. There is currently a lot of panicked reporting about the problems with Tokyo Electric’s nuclear power generation plants in Fukushima. They are causing lot of damage. What we can do now is pray for them and hope that things in Japan would be back to normal soon and Japan will recover from this current loss at a good pace.

Posted in Earthquake, Japan, Tsunami, Uncategorized | Leave a Comment »