Tag Archive: powershell

Couple of days ago I installed SCVMM  in order to test it out, since we are developing our IAAS solution. Everything seemed great until I found out that SVCMM doesnt have any API which can be used to create/turn on/off  new machines.  Yes, I know everything can be scripted thru Powershell, but it sucks that we need to create separate applicatons that will give us that feature. Imagine a solution where PRTG, Nagios or any other tools monitors your server… sees that the CPU load went up ( or any other condition) and starts up a new virtual machine  using API?

Its funny how the guys at MS fails to see the basic requirements for a modern cloud solution; do I have to mention that after years of HyperV being RTM-ed, we still dont have an option to limit a machines uplink speed!? Come on guys…SERIOUSLY!?!?

 

I know that you already have this  little piece of software created, release it…pretty please!? I know that Microsoft sees HyperV in some giant corporation where they dont have a need to limit the uplink of a virtual machine, but IMHO, hosters are having a bigger “market” share  than big corporations, think about us, pretty please with sugar on top :) .

Oh, what about promiscous mode for network cards? You  have no idea how much would I like to use SNORT on my HyperV virtual switch, but…I cant :(

What about the limit on only 4 cores per virtual machine? This is a VERY limiting factor. I’m in a situation where i have a 2x six core, 48 GB ram server which I want to turn into ONE virtual machine ( live migrations, scaling, etc…), but I cant…I can only turn it into a 4 core, 44 GB machine, effectively, wasting other 8 cores!?

I would really love to get in touch with someone from Microsoft Virtualization team and send them a list of must-have changes :D Someone knows some insiders? :D

Let me make one thing clear, I love Microsoft, but lets face it, there is lots of work that needs to be done. Admit it or not, the guys at the “Linux Camp” have much more options and features regarding virtualization. I really, really love HyperV, but some limitations are just plain unlogical/stupid.

Sorry for a bitter post, but I had to throw out my frustrations :)

 

So…today I had a very interesting issue. All of a sudden Nagios went red with the message: CRITICAL : – total: 232.82 Gb – used: 212.67 Gb (91%) – free 20.15 Gb (9%) on one of our SQL server. I was like..”NO! It cannot be. I clearly remember that this machine had over 150 Gb of free space yesterday!”

I log in to the machine, and automatically go to the data folder of SQL server thinking that some customer has a HUGE! log file on his database; so, right click – Select All -> Properties… only 50 Gbs of data…hmm…not here!

At that moment I notice that the server isnt “jumpy” as usual, so I start Performance monitor and see that the Avg. Disk Queue is off the chart!  That definatelly isnt right…

Since that machine is using Windows 2003, theres no too good way to see what application is using so much disk I/O ( beside FileMon ) , I start the FileMon and se that the SQL service is writing HUGE amount of data to its ERRORLOG file.

By navigating to the folder, I see that the ERRORLOG file is over 120 Gb big so opening it in Notepad, Context or some other file was out of the question, since it would kill the machine completely.

So, lets turn to powershell once more. In order to be sure to not kill the machine, since its in production , I have moved the file to an empty machine to opened it there.

Powershell : cat errorlog +ENTER :) after that powershell started to list the entire content of the file, and it took about 15 mins until it reached the end. AMAZING

By examining the log, I notice ( it was hard to NOT notice it ) litterally millions of these entries:

Could not allocate space for object ‘dbo.tblComments’.'tblComments’ in database ‘DATABASEname’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

What happened here?

The site that was using that database is poorly written and was allowing everyone to post comments on the articles without any security check, so it soon reached the size limit set on the database.  By further digging on the issue, I saw that the bots are posting about 4-5 comments each second which comes to about 18000 comments/hour…multiply that by 15-16 hours it took to fill the error log to that size, we roughly come to 280000 comments…that’s A LOT of comments! :)

After disabling the site and sending the email to the customer, situation on the machine looks like this :

The big drop on the green line is the moment where I disabled the problematic web site.

mssql-logoMicrosoft SQL Server 2005/2008 Express is a free edition of SQL Server that is ideal for learning, developing and powering desktop, web and small server applications, and for redistribution by ISVs.

Top Features

  • Supports stored procedures, triggers, functions, and views
  • Store all kinds of business data with native support for relational data, XML, FILESTREAM and spatial data
  • Improved performance, usability, visualization, in addition to integration with the Microsoft 2007 Office System in SQL Server Reporting Services
  • Simplify development efforts by leveraging existing T-SQL skills, ADO.NET Entity Framework and LINQ
  • Closely integrated with Visual Studio and Visual Web Developer

Because there’s no “SQL Agent” in SQL Express Editions, in order to create scheduled backups on SQL server Express edition, we need to user couple of tricks  :)

Surfing all over the net, I found a very handy powershell cheat sheet that was put together by Ben Pearce. Anyways, here’s the download link (just click on the picture).

cheatsheet

Big hello to the guys from www.bug.hr :)

firewalljpg

Tired of old point and click interface? :) Powershell is the new purple in computer world :) haha…Seriously! :)

So, here’s a little script that will add the Ip address you want to the existing firewall rule.

As you can see, it fairly simple, and there’s no need to explain it too much….


Function IP
{
param ($ipadress = $(Read-host "Enter IP address"))
$rule = "YOUR PREVIOUSLY CREATED RULE NAME"
Write-host "Adding address :" $ipadress -foregroundcolor "Red"
Start-sleep -s 5
netsh advfirewall firewall set rule name="$rule" new remoteip="$ipadress" action="allow"
}
IP

Only thing you have to do in the script is to enter your fireall rule name.

When you start the script, it  will ask you to enter desired ip address, and press enter. After that, wait 5 seconds and thats it :)

Cheers!