Friday, January 25, 2013

Java Class Path Error–invalid flag

I’m brand new to Java and by no means a professional coder but due to the nature of my job I have to be able to write a little bit of code in different languages. Yesterday I found out that I needed to be able to write a bit of Java for a project I’m working on so you may see Java related stuff on my blog the next couple days. Here’s the first thing I noticed:
I tried to include a folder of .jar files when I complied my code using the following syntax
javac –cp lib/* test.java
This promptly fails with the error “invalid flag: lib/commons-codec-1.4.jar”
The fix is that apparently you have to put the path inside double quotes like:
javac –cp “lib/*” test.java

On a side note just download a Java IDE like Spring Tool Suite and make your life much easier :)

Tuesday, January 22, 2013

Pushing New Plugin to Hyperic Agents

If you ever update a plugin on your Hyperic Server you may need to push it out to your Hyperic Agents. To do this find you Hyperic Agent under the Servers group. It should look like <Server Name> HQ Agent 5.0.0. Select this and go to the Views tab. From here select Agent Commands and Push Plugin. After pushing your plugin you will need to restart the agent using the same Agent Commands section.

Thursday, January 17, 2013

Apt-Get Proxy Settings

I needed to tell apt-get to use a specific proxy and here is what I found after some googling…

1. Go to /etc/apt/apt.conf.d/

2. Create a new file called “80proxy”

3. Put your proxy information in said file in the following format:

Acquire::http::proxy “http://proxy.domain.com:port/”;

Acquire::https::proxy “http://proxy.domain.com:port/”;

Acquire::ftp::proxy “http://proxy.domain.com:port/”;

Multiple Monitors on Linux Mint XFCE

If you want to run multiple monitors with Linux Mint I found a great way to do it thanks to http://forums.linuxmint.com/viewtopic.php?f=57&t=122367.

sudo apt-get install arandr

Then go to Menu > Settings > ARandR and align the monitors correctly. It’s as easy as it should be.

Tuesday, January 15, 2013

Writing PowerCLI for Performance

I was building a piece of PowerCLU code to check on my vCD Deployed vAPPs for certain errors and because it’s me I was curious what performance difference there was between using array based operations verses piped operations in powershell. Here’s what I found out.

Here is the array based operation – time to completion 2 minutes 30 seconds.

$myVAPP = @(Get-CIVApp | Select-Object Org, Name, Status)
        foreach ($myVAPP.Name in $myVAPP)
            {
                IF ($myVAPP.Status -eq "FailedCreation")
                    {
                        Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
                    }
                ELSE
                    {
                            IF ($myVAPP.Status -eq "Unresolved")
                            {
                                Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
                            }
                            else
                            {
                                IF ($myVAPP.Status -eq "Unknown")
                                {
                                    Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
                                }
                                else
                                {
                                }
                            }                           
                    }
            }
           

Here is the pipe based operation which is recommended for reasons that I now can testify for first hand.

Get-CIVApp -Status "Unresolved", "FailedCreation", "Unknown", "Unrecognized" | Select-Object Org, Name, Status

This operation returned the same results as the array based operation in 14 seconds, that’s 9% of the original time of using an array…

Friday, January 11, 2013

vFabric Hyperic Server Heartbeat

I wrote a quick safety feature for my Hyperic server that monitors the Hyperic Server process every minute and if the Server stops or dies the script will attempt to restart it. Nothing fancy but it’s a nice little feature… plus you can change a couple lines and make one to monitor your Hyperic Agents as well…

#!/usr/bin/perl
# ---------- Hyperic 5.0.0 Server Heartbeat Check ------------
# This script is used to verify that the Hyperic 5.0.0 Server is running and
#    restarts it upon failure. To schedule it to run automatically every
#    minute on linux run the following:
#         crontab -e */1 * * * * <Path to this script>

# NOT SUPPORTED OR PROVIDED BY VMWARE AND HAS NO GUARENTEES

$cmd = "/opt/hyperic/server-5.0.0-EE/bin/hq-server.sh status";
$out = `$cmd`;
# print "Output $cmd\n";
# print "Output Check 1 - $out\n";
if (index($out, "HQ Server is not running") != -1)
        {
                # print "\nHQ Server is dead\n";
# Restart the HQ Service
                $cmd = "/opt/hyperic/server-5.0.0-EE/bin/hq-server.sh start" ;
                $out = `$cmd`;
                # print "Restarting the Service\n $out \n ";
        }
        else
        {
                # print "\nServer is running\n";
        }

Getting Started with vFabric Hyperic Monitoring and Alerting

During the past couple days I have been working with Hyperic to setup basic alerting functionality for things like disk space thresholds, Windows Services and memory usage by process. Here is a quick getting started to setup basic disk monitoring as well as an intro to the Hyperic Escalation Schemes which allow tiered alerting.

First off let’s create an Escalation Scheme. To do this go to Administration > Escalation Schemes Configuration.

Hyperic_alert_groups_6

Next Let’s go ahead and build the process of who gets alerted and when.

Hyperic_alert_groups_7

Now that we have setup the notification process let’s actually setup some alerts…For this example I will be setting up test disk space alerts on a subset of my servers. To get here you need to understand a few things:

1. Under the Resources Tab is where you are going to find all your things that can be monitored. Here comes the confusing part:

a. Platforms is the Server that your Hyperic Agent is running on.

b. Servers are things like .net, Apache Tomcat and MSSQL Server.

c. Services are things that you monitor like HTTP, Disks, CPU, RAM and Windows Services.

d. Compatible Groups/Clusters are groups of the same thing (ie, Disks only)/

e. Mixed Groups are groups that contain a mix of things like Disks and RAM.

Once you grasp this it will make your experience with Hyperic much easier.

Ok, so I have navigated to the Services Tab and filtered by “FileServer Mount” aka Disk information. Now I want to select my subset of disks and click on the Group button. Hyperic_alert_groups_1

Next I click on "Add to a New Group”  to create a new group. Because this group contains all like items it will create a new Compatible Group.

Hyperic_alert_groups_2

Now you should see your new group.

Hyperic_alert_groups_3

From there click on the Alerts tab and click on Configure

Hyperic_alert_groups_4

Now I want to create a new alert against this group of servers. My normal if statement is “IF more THAN 0 of the Resources” because I want alerts if any of them go down.

Hyperic_alert_groups_5

Here’s an important note: if you select Total Bytes Avail or several other metrics your alert will NOT work by default, here’s why:

Go to Administration > Monitoring Defaults and find FileServer Mount and click Edit Metric Template.

Hyperic_alert_groups_9

This should bring up a screen like the below. Notice that the Default On is set to No for the Total Bytes Avail… if you build your alert on that setting and don’t check to make sure that valid data is coming in you might be lulled into a false sense of security… Word to the wise, make sure your monitors are green after you create them.

Hyperic_alert_groups_8

Congrats, you are now ready to use vFabric Hyperic to start basic monitoring in your environment.

Thursday, January 3, 2013

Configuring VMware vCSA with Active Directory

I ran into 2 issues while using the vCenter Server Appliance and integrating it with AD and what I found I figured might help some of you in the future. Here goes:

Issue 1: vCSA fails to join the AD domain.

On the initial deployment of my vCSA I got an error while attempting to join my AD Domain that says “Error: Enabling Active Directory failed”. That’s it… nothing useful…

AD Failed

When this happens you can run the process manually and if it fails you will at least get an error code. To do so run /usr/sbin/vpxd_servicecfg with the following syntax:

vpxd_servicecfg ad write <username> <password in 'single’ quotes> <domain name>

like: 

vpxd_servicecfg ad write caleb ‘myTopSecretPa$$’ caleb.com

If it is successful the return code will be “VC_CFG_RESULT=0”. If that is the case you need to reboot your vCSA and you are ready to roll.

Issue 2: Configuring vCSA to use AD for user authentication with LDAPS.

1: Login to the web client (NGC) on your vCSA (https://<vCSA>:9443/vsphere-client.)

2. Go to Administration > Sign-On and Discovery > Configuration and click on the little green plus to add an identity source. Now you should see a screen like the below:

Configure_DC

For the most part it is all pretty simple, the gotcha is the primary server URL and the “Choose Certificate” button.  For additional useful information look at the vmware documentation at http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vsphere.security.doc%2FGUID-B23B1360-8838-4FF2-B074-71643C4CB040.html.

Next I need to get a certificate so I can talk to the DC. This part is pretty easy once you think about it for a minute. From my Windows workstation I open up MMC and add a Certificates snap-in for the Local Computer account. Next expand you certificates and navigate to the “Trusted Root Certification Authorities” folder and find the certificate that was issued by your Domain’s Certificate Authority. That is the certificate that we will use.

Right click on the proper certificate and go to All Tasks > Export. Change the format to Base-64 encoded X.509 .cer and save to your local desktop. Next from the vCSA “Add Identity Source” window click on the “Choose Certificate” and point it at the cert you just exported. Congratulations your domain logins will now work, just don’t forget you still need to assign them permissions.