Wednesday, July 29, 2009

loop through dates, skip days

Had an issue where I needed to loop from a start date to an end date but for certain weekdays, (like fridays or mondays, information coming from a series of checkboxes; 1 for each weekday) I needed to skip whichever the user checked off....

Solution:

For dt = StartDate To EndDate
If InStr( shiftdays, CStr(Weekday(dt)) ) > 0 Then
... process this dt ...
End If
Next

Tuesday, July 28, 2009

COALESCE

This function was hard for me to first understand, but I have found it very useful:
COALESCE(expression1,expression2)
means if expression1 is null, then expression2

This was useful when a column originally contains null values and I needed to concatenate a value to it, not knowing if the value was still null

COALESCE(column1,'') means if column1 is null, then blank, otherwise column1

Friday, July 24, 2009

Taking on Nagios

OK,
I have been searching for an easy way to try out Nagios, even going to VMWare for a virtual machine, there is only 1 link worthwhile and it is dead, it is the same link that everyone in Google refers to as well, so I am convinced there is no easy way.

Maybe when I finish, I'll post the virtual machine at VMware or keep it at my site for visitors...

I am going to start from scratch; download Fedora 11, then the Nagios tarball. Then configure....

1. Downloaded Fedora 11 and installed to 15G hard drive
2. Download Nagios: nagios-3.0.6.tar.gz
3. un-tar Nagios: tar xzf nagios-version.tar.gz
4. add user nagios: adduser nagios
5. make installation directory: mkdir /usr/local/nagios
6. chown the directory: chown nagios.nagios /usr/local/nagios
7. creat a new group: /usr/sbin/groupadd nagcmd
8. add the web and nagios user to that group:
/usr/sbin/usermod -G nagcmd apache
/usr/sbin/usermod -G nagcmd nagios
9. run configure (include command group nagcmd):
./configure --with-command-group=nagcmd
10. now compile: make all
11. post init file to /etc/rc.d/initd:make install-init
12. now edit httpd.conf with the following 2 aliases so that the web pages get diverted to correct directories:

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Alias /nagios /usr/local/nagios/share


Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


13. restart the web server: /etc/rc.d/init.d/httpd restart
14. OK - now trying to log into nagios via website, I get AVC denials all over the place, after searching, I find my best answer for now is to just disable SELinux - kind of like disabling the junk I don't like in Vista - this is not a recommendation, just something I do to move forward, I can enable SELinux later when I get everything running
15. Great, now a "Whoops" error, After fruitless "googling" I get nowhere so as a last resort, I actually read the error carefully, first, I run a nagios -v {config-file] command like they say: ./nagios -v /usr/local/nagios/etc/nagios.cfg
everything shows fine, so now I run it without the -v and I see that I get a weird error about not finding the nagios.cmd in the usr/local/nagios/var/rw directory. Understood, cause I don't even have an rw directory. So I go ahead and create it and set ownership and group to "nagios". Run the command again and yes, nagios now starts..... Log into the webpage and can now see everything. Next step will be to learn everything it can do and try the plugins...

OK - update 2 weeks later, I have configured nagios to monitor LAN servers as well as a few off-site servers. Had to work with windows.cfg, commands.cfg in the /usr/local/nagios/etc/objects directory and the nagios.cfg, cgi.cfg in the /usr/local/nagios/etc directory. Needed to download nsclient++ and install on all windows servers, configure the .ini file and poke holes for the listening port of choice in the .ini file.

Next was fighting with the horrible email notification documentation. Finally had to yum install ssmtp and configure the conf file to my email server and fight with the command line to get the correct user from, to and subject. Funny how important the alerting is, yet the documentation is a joke for this issue and don't try to go on the forums, all you get is some pompous advice to RTFM - hmmm I did read the manual and it was written horribly, that is what the forum is for; to help interpret the poorly written stuff that techies write and think is incredibly clear....

Well, after getting it all running, have to say it is pretty cool, and I even tracked back to re-enable all the security that I removed to get this up and runing.

Monday, July 20, 2009

Installing New Open-Source SSL VPN

Here I will document the complete installation of a new SSL VPN - Completely OpenSource and Free as in beer.

Download Adito
Download latest Java Development Kit
Download Apache ANT

Decompress ANT to c:\ANT
Change Environment Path to add c:\ant\bin

Issue 1. After issuing "ant install" in command prompt it could not find the tools.jar file because it was looking in the jre directory and not the jdk directory - I issued "set JAVA_HOME=c:\program files\java\jdk1.6.0_14" in command prompt. This allowed ant to find the tools.jar file and copy it back to the Adito home directory. Has to do this for legal reasons - Adito cannot package tools.jar into their install.

Great, everything starts to install and brings me first to a certificate creation or install - I create new cert with passphrase and company info.

Fill in info, decide whether to use Active Directory or built-in database, creae super user, decide port/protocols/ip addreses outside names, etc

Configure proxy

Finished install - now to keep it running between re-boots: go back to adito directory and issue "ant install-service" in command prompt

Now start the service and login at https://localhost

Adito doesn't seem to have any ready-made extensions so I copied RDP from old SSL-Explorer application - has to be a zipped file, complete with application.xml file. Went to extension store and uploaded it, failed twice before actually uploading, now it is there and I can choose it when I go to "create application".

Now I can't connect through the firewall - seems NAT is working fine however the windows firewall even though is set to allow https traffic, still blocks it. Added a rule to allow port 443 and now it allows Adito to work - can't understand why that is....

Well, now I have a complete functioning SSL VPN, available from anywhere.

I will experiment with Adito agent and maybe creating web folders, etc. - maybe a little later

Checklist for re-installing operating system on user's computer

Reinstalling Operating system:

Copy over folders:
• C-Drive
• My Documents
• Desktop

Get IP address and all network information

Get computer name, and user log-in and password (any other profiles?)

Get LAN card driver info
Get Video card driver info
Get mapped drives info

Get printer info
• IPaddress
• Driver

Get email info complete:
• PST file
• .nk2 file
• Signature
• Print out mail settings
• Get email password
• Contacts / address book

Get experience
• Display setting
• Default home page
• Favorites

Java download needed – most likely
AVG Free

What versions of software – office, etc.

MS Access - filter email addresses by domain name

The following will give me the information to the right of the "@" sign so that I can filter by domain name

Mid([address],InStr([address],'@')+1)

Thursday, July 16, 2009

check my open ports

netstat -o

Then to see what the PID is doing:

TaskList /FI "PID eq 4072" /FO LIST /V

SQL Server error converting nvarchar to float

Had numbers in my column like "1,298.05" when I was expecting 1298.05 So to get around this, whenever I refer to the column for calculations I use:
convert(money,REPLACE(t1.[TOTAL_AMOUNT_PAID],'"', ''))

Tuesday, July 14, 2009

Disable DEP for good

Don't bother posting the question on a forum, 90% of the time you will get answers like "why do you want to do that - here is a better way...." or " right-click on my computer, properties, advanced, performance,settings then Data Execution Protection tab.."

To shut it off completely from bothering you, which it eventually will (especially if you use legacy programs), edit your boot.ini file and add /noexecute=AlwaysOff at the end. Reboot, problem solved.

New ThinkMate Quad Core Xeon Server

Just took delivery on Server, now to install operating system, and configure:

Step 1 - Thank you ThinkMate, upon plugging it in and installing the CD, the machine found the 15K SAS drive and began to install.

Step 2 - Turn off Internet Explorer Enhanced Security Configuration: Go to server manager and click on Configure IE ESC. Turn it off there

Step 3 - disable hibernate - are you kidding me? hibernation on by default?
powercfg.exe /hibernate off

Wednesday, July 8, 2009

Gradient Background

This is only for microsoft IE browsers - good tip for captured audience intranets.

body style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"


For other browsers, best to create a 5 pixel wide by 800 height file using PhotoShop then the gradient tool - save as a gif or jpeg and use in css like this:

{
background-image:url(images/jjgradient.gif);
background-repeat:repeat-x;
background-position: top;

}

Wednesday, July 1, 2009

Open Source Changes

Just found out that Adito has merged with OpenVPN to create OpenVPN ALS. Adito has been a fantastic Open Source SSL VPN; totally replacing my Cisco PIX solutions I used to pitch (more on that later) Open VPN was also a great solution when I needed access to a whole network. The fact that these 2 have converged is fantastic news and I will be deploying this solution immediately to clients wishing for secure, opensource, inexpensive VPN's