The Temple of Fu

code, systems and games

VMWare Server – Failed to lock the file

leave a comment »

Almost every time when the power goes out at my house I receive the following error when starting up an image that was already running when the lights went out.
‘Cannot open the disk ‘/path/to/machine.vmdk’ or one of the snapshot disks it depends on.
Reason: Failed to lock the file.’

This is due to a lock being held on the memory files within the directory listed in the error message.

#cd /path/tovm
#ls *lck
#rm -Rf *lck

Be careful with the rm -Rf command above please ;) hope this helps someone sometime.

Written by lordfu

March 23, 2011 at 10:09 pm

Posted in Linux, Other, RedHats, Slackware

Linux – Checking Memory Usage / Getting Memory Information

leave a comment »

Memory is one of the most critical resource components on a server to ensure that the smooth and fast operation. Thus, the availability of adequate and abundant physical memory size is vital especially for any server, especially high load web host that are also running database servers such as Oracle or MySQL, which are famous for being memory intensive. Linux, including CentOS, come with several commands and tools to check memory usage on server.

free

The free command displays the amount of total, free and used physical memory (RAM) in the system, as well as, shows information on shared memory, buffers, cached memory and swap space used by the Linux kernel.

free -[options]

Example usage of free; This command will display information about physical memory in MB.

free -m

The following command will activate a continuous polling delay of 5 seconds apart and then display memory status in megabytes on the terminal. Any floating point number for delay can be specified.

free -m -s 5

Same with “free -m”, but -t switch will display a line containing the totals of physical memory and swap space.

free -t -m

vmstat

The command vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With the vmstat command, administrators can have instantaneous reports on memory usage.

vmstat -[options] [delay count]

Example usage of vmstat

vmstat

The following command will display report based on averages since last reboot. The command will pool average system resources usage level for a sampling period of 5 seconds at interval of 5 seconds, except for the first result that is averages since the last reboot.

vmstat 5

top

The top command displays dynamic real-time view of the running tasks managed by kernel and system information in Linux system. The memory usage stats by top command include real-time live total, used and free physical memory and swap memory with their buffers and cached memory size respectively.

top

Using top is simple, simply type top at command shell, and constantly update stats page will be shown.

ps aux

The ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used. ps will show the percentage of memory resource that is used by each process or task running in the system. With this command, top memory hogging processes can be identified.

Syntax and example of ps aux

aux is actually already the options for ps command to see every process on the system. So the typical command to type the following in the command shell:

ps aux

To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:

ps aux | awk ‘{print $4″\t”$11}’ | sort | uniq -c | awk ‘{print $2″ “$1″ “$3}’ | sort -nr

dmidecode

You can also use the DMIDECODE command line utility to check the ram speed and type:

Written by lordfu

January 27, 2011 at 9:39 am

yum command: Update / Install Packages Under Redhat Enterprise / CentOS Linux Version 5.x

with one comment

Rather than r-epost what already is an excellent post I will just link you to it.

http://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/

I will however add the following.

If problems occur while performing an update (for example broken packages) just tell yum to skip them
yum install updates --skip-broken

Written by lordfu

December 9, 2010 at 9:35 am

Posted in Linux, RedHats

SSIS – File mapping object ‘Global\DTSQLIMPORT’ could not be opened. Operating system error code 2(The system cannot find the file specified.). Make sure you are accessing a local server via Windows security.

leave a comment »

Man one of these days MS will make this easy. I am one of the ones that came from DTS land where after a few years things were comfortable. So in an effort to make things easier MS gave us SSIS to overcome DTS shortcomings. Well they made my life a living hell in trying to learn this /rant.

The latest in my struggles is trying to deduce from the garbage that is SSIS messages what I need to do. The latest being:
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Could not bulk load because SSIS file mapping object 'Global\DTSQLIMPORT ' could not be opened. Operating system error code 2(The system cannot find the file specified.). Make sure you are accessing a local server via Windows security.".

What was I trying to do I will represent in this complicated flowchart.
Excel document –> SQL Server

Confused yet? Me neither, this in DTS land would have taken an hour tops! I am going on 4 hours! Not only am I battling Excel and it’s ‘here let me make this easier for you and guess what types or lengths your columns can hold’ productivity enhancements. I am also needing to deduce these bs error messages that are given at freaking runtime from SSIS designer!
/rant #2

Ok so the actual fix now is, is instead of using a SQL Destination (even though you are inserting into SQL wtf) use an OLE DB Destination. The reason being to use a SQL destination you need to run the package on the machine that hosts SQL Server (destination). If you want to use a remote SQL Server, use OLEDB destination.

Hope that helps.

Written by lordfu

November 5, 2010 at 4:33 pm

Posted in Development, MSSQL, SSIS

CentOS 5* VSFTPD Install and Setup + OpenSSL

leave a comment »

Install VSFTPD
# yum install vsftpd

Turn on the VSFTPD service so it starts at boot
# chkconfig vsftpd on

Start, stop or restart VSFTPD
# service vsftpd [start,stop,restart]

Generate an OpenSSL certificate

You use OpenSSL to generate a certificate for vsftpd. The certificate is stored on your server, in a location of your choice. Here I choose to put it in the /etc/vsftpd directory. As well, you specify a ‘lifetime’ for the certificate; here it is set for 5 years (“-days 1825″).Note that the backslashes only signify line breaks. You should be able to copy/paste & run it as it is, or remove the backslashes and the line breaks.
If /etc/vsftpd does not exist create it (it existed on my system after install).
#mkdir /etc/vsftpd

#openssl req -x509 -nodes -days 1825 -newkey rsa:1024 \
-keyout /etc/vsftpd/vsftpd.pem \
-out /etc/vsftpd/vsftpd.pem

You will be prompted with a series of question, which you answer as they appear. When done the certificate will be installed in the /etc/vsftpd directory.

To configure vsftpd you need to edit the file /etc/vsftpd/vsftpd.conf and add the following lines:
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=NO
force_local_logins_ssl=NO
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/vsftpd/vsftpd.pem

Restart vsftpd for these settings to take effect:
#/etc/rc.d/init.d/vsftpd restart

Connect using a ftp client that support AUTH TLS / SSL / SFTP I use FileZilla.

Error Messages (below answers are what worked for me YMMV):
Connection attempt failed with “ECONNREFUSED – Connection refused by server”.
Provide correct info for login and port within your client.

Status: Connection established, initializing TLS…
Error: Connection timed out

I indicated the server type in my client as “FTPS – FTP over implicit TLS/SSL” but it must be “FTPES – FTP over explicit TLS/SSL” for it to work

Error: GnuTLS error -8: A record packet with illegal version was received.
Error: Disconnected from server: ECONNABORTED – Connection aborted

Verify vsftpd.conf settings are correct.

Written by lordfu

November 2, 2010 at 10:46 am

Posted in Linux, RedHats

Slackware – udev renamed eth0 to eth1

leave a comment »

So I picked up a new motherboard and decided to go ahead and set it up today. For those interested I bought a Asus P5G41T-M LX. It’s a MATX board to replace my aging Asus P4C800-E. It’s a huge jump from a 3.4 P4 to a 2.8 C2D. I have Slackware 13.1 installed so I just planned on swapping all the components and then booting up, and for the most part all of this has gone extremely well up till now. Upon first boot up I received no network activity.

I configured eth0 within /etc/rc.d/rc.inet1.conf including my gateway to my liking and then tried to bring up the interface.

/etc/rc.d/rc.inet1.conf eth0 start

Ping google and then nothing still. Hmmmmm.

So I checked dmesg to see what the deal was, maybe I missed a message during boot.
dmesg | grep eth

I saw the following.
udev renamed eth0 to eth1

Well after some searching I realized that the MAC address of my old card was still being referenced within /etc/udev/rules.d/70-persistent-net.rules . I commented out the offending line and rebooted (I know for shame) and all was good in the world.

So in summary I COMPLETELY changed all my hardware except for my hard drive that had Slack installed and the only thing I have had to do so far to get back to a complete system was fix one entry in a file.

I won’t even get into the fact this hard drive also dual boots Windows which is completely trashed at this point and will need a reinstall.

Slackware is King!

Written by lordfu

October 21, 2010 at 1:48 pm

Posted in Slackware

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Ajax Toolkit – Update Panel and Datagrid download button

with one comment

So I have a datagrid which is a listing of files in a network share. I have a linkbutton in the grid with its text property set to a filename. This datagrid sits inside an UpdatePanel so it is all ‘Ajaxified’. When testing the command on the link button I received the following error.
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Now I do understand why I received this error, I had modified the output stream back to the client via AddHeader methods etc but I need to in order to get this file back to client!

Well fortunately there is a way to tell the Ajax parser code on the client that content coming back was modified on the server side via script manager and also by registering the datagrid as a postback control.

ScriptManager _scriptManager = ScriptManager.GetCurrent(this.Page); _scriptManager.RegisterPostBackControl(myDataGridID);

Hope this helps!!

Written by lordfu

September 24, 2010 at 2:11 pm

Posted in Ajax, ASP.Net, C#, Development

Internet Explorer cannot display the webpage because of fileupload size

with one comment

So I was adding an input for the file upload control. Upon upload I would check the file size against a known size limit within my application. While testing trying to exceed the maximum upload size limit I was receiving from Internet Explorer a “..cannot display the web page error.” So I tried doing a try catch within the page to see if I could catch an error but the error couldn’t be caught there. Once I figured out that the error was never going to be caught there due to the nature of the request/response cycle I thought about trying to catch the error within Global.asax but that seemed hokey considering all I wanted to do was to display a message to the user that they had exceeded the limit. Well the answer lay in the web.config. What I needed to do was tell the web server (I was using Visual Studio built in) that it’s OK to allow file uploads of ‘X’ size. Where X is larger than the maximum size you want your application to allow for file uploads, in my case 5MB. So I added the following into the
system.web element of the web.config.
httpRuntime executionTimeout="600" maxRequestLength="6000"

I then throw an InvalidOperationException when checking for file upload size and catch that within my interface and display a nice friendly “sorry too large” message.

Hope that helps!

Written by lordfu

September 24, 2010 at 10:31 am

Posted in ASP.Net, Development

Single line if statement C#

leave a comment »

Who doesn’t like doing more in one line of code!

Here is a standard if else statement in C# .

if (Age == 36)
{
isMyAge = true;
}
else
{
isMyAge = false;
}

Here is the same as a single line.

isMyAge = (Age == 36) ? true : false;

Now obviously this is not a great example because the same code above could be shortened to

isMyAge = (Age == 36);

But you get the point :)

Written by lordfu

September 17, 2010 at 2:49 pm

Posted in ASP.Net, C#

Ohio Linux Fest 2010 is near!

with 6 comments

For those that do not know Linux Fest is a Free and Open Software Conference and Expo. I have been the last 4 years and it is awesome! The guys and gals running this really know how to put a great event together!

This year it will be September 10-12, 2010 and I cannot suggest enough that you should attend and show your support for Open Source Software as well as rub elbows with people like John ‘maddog’ Hall. This year they also have a speaker I am looking forward to, Dru Lavigne, I have read a few books and articles by her and they are awesome!

Registration is free although they do have Professional packages available.

Travel on over and register today!
https://www.ohiolinux.org/

Written by lordfu

August 19, 2010 at 10:24 am

Posted in Linux

Follow

Get every new post delivered to your Inbox.