Monday, October 25, 2010

Autocad network license manager error

I was having a tough time with the following error in many systems on a trusted domain within our network. The Autocad licensing server was on our domain and could be accessed without issues from the client desktop which was on the trusted domain, but AutoCAD wouldn't start. It just kept popping up this error

The network license manager was not able to get a valid license. If this problem continues, please contact your system administrator. Error [1.5.-18]


Turned out that, in the AutoCAD server license file, the server name provided was not accessible from the client desktop since it was not in a FQDN format. When the hosts file was modified to do the name mapping, it worked fine. I then created a host record in the trusted domain with the same name to point to the licensing server and it worked.

Wednesday, September 01, 2010

Anonymous users in proxy logs

Ever since we installed a new Microsoft TMG server for proxy authentication and web filtering, we've seen random users being denied access for no good reason. The rules have been set to allow access to these users and it works for most of the other users.

The logs seem to show that the users, who are logged in as domain users still show up as anonymous accounts at the TMG server.

In one such instance, this step fixed it.
In IE-> tools-> Internet Options-> Advanced-> Security
Toggle the "Enable integrated windows authentication."

Thursday, August 05, 2010

Kernel versions to RHEL versions mapping

2.6.18-53.el5 (RHEL5.1)
2.6.18-92.el5 (RHEL5.2)
2.6.18-128.el5 (RHEL5.3)
2.6.18-164.el5 (RHEL5.4)
2.6.18-194.el5 (RHEL 5.5)

2.6.9-11.EL (RHEL4.1)
2.6.9-42.EL (RHEL4.4)
2.6.9-55.EL (RHEL4.5)
2.6.9-67.EL (RHEL4.6)
2.6.9-78-0.1.EL (RHEL4.7)
2.6.9-89.EL(RHEL4.8)

Sunday, May 16, 2010

Update error on Websphere

I was trying to update a WAS 6.0 server on linux with
6.0-WS-WAS-LinuxX32-RP0000002.pak

It completed successfully.

Then with the same IBM Update Installer for WebSphere package(6.0.2.0) I tried to apply the fix pack 6.0.2-WS-WAS-LinuxX32-FP00000013.pak to the server but it kept popping up the message

"Unable to find IBM WebSphere Application Server at a version that is greater than or equal to 6.0.0.0 and less than or equal to 6.0.2.0.".

The issue was that it had to be done with IBM Update Installer for WebSphere 6.0.2.7. So I moved the earlier updateinstaller directory to updateinstaller.old and then untarred the new version, moved the fixpack to the maintenance directory and ran updateInstaller and it worked.

Monday, May 10, 2010

Websphere uninstallation error

Often when we remove the /opt/IBM folder manually to remove a Websphere installation (for reinstalling) this error pops up during the second attempt

Specify a different directory or perform a manual uninstall to remove all packages before reinstalling to the same directory

This happens because the WAS installation is stored in more locations than just the /opt folder. To clean up the system after you accidentally remove the /opt folder,(kill all java processes first)

1) rpm -qa |grep WS
and remove the rpms

2)remove the ~/.WASRegistry file.

3) remove vpd.properties.

Wednesday, February 24, 2010

Oracle Tablespace Check

Here's a script that checks the tablespace utilization on a database, and sends a mail if it crosses a threshold

#!/bin/bash
# Tablespace check script 
# Author: Nabeel Moidu
# Website: nmkuttiady.blogspot.com
# Set threshold here
THRESHOLD=70
# Set the Oracle user here
ORACLE_USER=ora10g
# Set the mail id of the DBA
DBA="dba@organization.tld"

# Get output of tablespace usage on the database
su - $ORACLE_USER -c "sqlplus -s \"/ as sysdba\" < /backup/script/tablespace_usage.sql > /tmp/output.txt "
# Remove blank lines from file 
cat /tmp/output.txt | grep -v ^$ | grep -v "no rows selected" > tablespaces.txt
# If no tablespace crosses threshold, the file will be empty. So send mail only if file not empty
if test -s "tablespaces.txt"

then

        # Prepare the mail
        echo "The following tablespaces have exceeded the 60 percent threshold" > mail.txt

        #Send the mail with the hostname in subject
        HOST=`hostname`
        SUBJECT="Daily Tablespace Check - "$HOST
        echo $SUBJECT
        mail -s "$SUBJECT" $DBA < mail.txt

fi


This is the SQL query to get the tablespace output
set pages 700
set linesize 1000
select t.tablespace_name,total_MB,round((total_MB-free_MB),2) used_MB, round(free_MB,2) free_MB,round(((total_MB-free_MB)/total_MB)*100,2) per_used,round((free_MB/total_MB)*100,2) per_free from (select tablespace_name,sum(bytes/1024/1024) free_MB from dba_free_space group by tablespace_name) f,(select tablespace_name,sum(bytes/1024/1024) total_MB from dba_data_files group by tablespace_name) t where f.tablespace_name(+)=t.tablespace_name order by 5;

Tuesday, January 26, 2010

VBScript for Telephone Extension verification by users

This VBScript application identifies a logged on User, retrieves their login name, checks up their telephone number and asks them for a confirmation if its the correct number. If its wrong, it mails the corrected name and number to a particular user and also uploads it to a particular php script. I used this to migrate our users from Cisco Call Manager phone directory to an integrated Active Directory Address book.



Dim objADSysInfo,strUser,objUser,inputPhone,strEngInfo,strEngMsg,strAraInfo,strAraMsg,Result
Dim xmlhttp,httpURL,strDate,strMsg

' Function to display the retrieved information to a user and accept his modification
Function EnterExtension
'Collect AD information from system where the application is executed
Set objADSysInfo = CreateObject("ADSystemInfo")
'Retrieve username of the logged in user
strUser = objADSysInfo.UserName
'Lookup LDAP for other properties of the user
Set objUser = GetObject("LDAP://" & strUser)
'Display the retrieved information to the user
strEngInfo = "Your Name is " & objUser.CN & VbCrLf & VbCrLf & "Telephone Extension is " & objUser.ipPhone & "." & VbCrLf
strEngMsg = " If this is incorrect, enter your extension (only the last four digits Eg. 5159) and click OK. Otherwise click Cancel"
'Accept User's modified extension number
inputPhone=InputBox( strEngInfo & VbCrLf & strEngMsg & VbCrLf & VbCrLf )

End Function

'Function to Process the extension number entered by the user
Function ProcessExtension

'Upload the modified number and useraccount to a php application which can process it
httpURL = "http://servername.domain/TelExtension.php?UName=" + objUser.sAMAccountName + "&UExt=" + inputPhone
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "GET", httpURL, false
xmlhttp.Send
strDate = formatDateTime(Now(), vbLongDate)
strMsg = "Your request will be processed by end of " & strDate
MsgBox strMsg,64,"Information Systems Department"

End Function

'Function to trigger an email
Function SendMail

'Launch Outlook
Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0) 'olMailItem
With MyItem
.To = "admin@domain.tld"
' Properly set subject so as to filter out mail at the mail client
.Subject = "Request for Extension change :" + objUser.sAMAccountName + "," + inputPhone
.ReadReceiptRequested = False
' Compose body of the Email
.HTMLBody = objUser.sAMAccountName + " was previously " + objUser.ipPhone + " and needs to be modified to " + inputPhone
' Send the mail
.Send
End With


End Function

'Function to Check the validity of extension entered
Function CheckExtension

If IsEmpty(inputPhone) Then
MsgBox strEngInfo & VbCrLf & "Thank You for your cooperation",64,"Information Systems Department"
'This is expected if the user clicks Cancel, i.e. his extension in our records is correct. So Set Flag to 1
Result=1
If (inputPhone > 4000 And inputPhone < 4199) OR (inputPhone > 5000 And inputPhone < 5999) Then
ProcessExtension()
Result=1
Else
strMsg = "Please enter your extension again. Enter only the last four digits.For Eg. 5678 "
MsgBox strMsg,48,"UPDA Information Systems Department"
Result=0
End If

End If

End Function

' Main code Begins here

Result=0

'Run till the user enters a valid number or cancels
Do While Result=0
EnterExtension()
CheckExtension()
Loop


Thursday, January 14, 2010

Compare data in two CSV files

[root@nabeelmoidu html]# cat compare.php
 

// Input of the format
// field1 in file1 (eg, 2446)
// field2,field1 in file2 (Nabeel, 2446)

$filename='file1.csv';
$handle = fopen("$filename", "r");
$ctr=0;

while (($read = fgetcsv($handle, 1000, ",")) !== FALSE){
$num[$ctr]= (int)$read[0];
// echo $num[$ctr]."
";
$ctr = $ctr + 1;
}

$filename1='file2.csv';
$handle1 = fopen("$filename1", "r");
$ctr1=0;
while (($rawname = fgetcsv($handle1, 1000, ",")) !== FALSE)
{ $ext[$ctr1]= (int)$rawname[0];
$name[$ctr1]= $rawname[1];
// echo $ext[$ctr1]."
";
$ctr1 = $ctr1 + 1;
}

for ($n=0; $n <= $ctr1; $n++) { $match[$n]=1; }

for ($x=0; $x <= $ctr; $x++)
{
for ($y=0; $y <= $ctr1; $y++) {
if ($num[$x]==$ext[$y]){$match[$y]=0;}
else {};
}
}

for ($y=0; $y <= $ctr1; $y++) {
if ($match[$y])
{ echo $name[$y]." | ".$ext[$y]."
";}
else {};
}

fclose($handle);
fclose($handle1);
?>

PHP scripts for LDAP modifications

[root@nabeelmoidu html]# cat ldap-search.php

 
// Open file handles for input and output file
$ip_handle = fopen('input.csv', 'r');
$op_handle = fopen('output.ldif','w');

$server="xx.xx.xx.xx";//Enter DC ip here
$basedn="DC=domain,DC=tld";

//User to bind to the active directory to search for the users, can be any ordinary user
$bindname="CN=binder,OU=Users,DC=domain,DC=tld";

// Read from csv, with the comma , as the delimiter
while (($rawname = fgetcsv($ip_handle, 1000, ",")) !== FALSE)
{
$searchname=$rawname[1]; // First column is the useraccount
$extension=$rawname[2]; // Second column is the extension number


$filter="sAMAccountName=".$searchname; // search filter set as per the first column

// Attempt to connect to the LDAP server
if (!($connect = ldap_connect($server))) { die ("Could not connect to LDAP server"); }
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);

// Test if the user can be bound to the LDAP
if (!($bind = ldap_bind($connect, $bindname, "passwd"))) { die ("Could not bind to $bindname"); }

// Search for the user
$result = ldap_search($connect, $basedn,$filter);


if ($result) {
$info = ldap_get_entries($connect, $result);
for ($i=0; $i<$info["count"]; $i++)
{
// Retrieve user information from the result
$userdn = $info[$i]["dn"];
$usersamname = $info[$i]["samaccountname"][0];
$usertelno = $info[$i]["telephonenumber"][0];
$useript = $info[$i]["ipphone"][0];

// Echo output to screen and to file. If phone number exists, set changetype to modify, else to add
if ($usertelno) {
echo "
dn: ".$userdn."
changetype: modify
replace: telephonenumber
telephonenumber: ".$extension."
-
";
fwrite($op_handle, "\ndn: ".$userdn."\nchangetype: modify\nreplace: telephonenumber\ntelephonenumber: ".$extension."\n-\n");
}
else {
echo "
dn: ".$userdn."
changetype: modify
add: telephonenumber
telephonenumber: ".$extension."
-
";
fwrite($op_handle, "\ndn: ".$userdn."\nchangetype: modify\nadd: telephonenumber\ntelephonenumber: ".$extension."\n-\n");
}

if ($useript) {
echo "replace: ipPhone
ipPhone: ".$extension ;
fwrite($op_handle, "replace: ipPhone\nipPhone: ".$extension."\n" );
}
else {
fwrite($op_handle, "add: ipPhone\nipPhone: ".$extension."\n" );
echo "add: ipPhone
ipPhone: ".$extension ;
}
}
echo "
";
}
else {}
ldap_unbind($connect);
}
fclose($op_handle);
fclose($ip_handle);

// Output will be

//dn: CN=Name1,OU=Department,OU=Users,DC=domain,DC=tld
//changetype: modify
//replace: telephonenumber
//telephonenumber: 5266222
//-
//replace: ipPhone
//ipPhone: 5266222
?>


The output file created by this script is then passed to ldapmodify to do the modifications
[root@nabeelmoidu html]# ldapmodify -a -v -h dc.domain.tld -D "CN=Administrator,CN=Users,DC=domain,DC=tld" -W -f /var/www/html/output.ldif

Sunday, January 03, 2010

A system recovery report

A linux server was unable to boot up after someone powered it off during an unresponsive state. The boot process was getting stuck at this error :

REDHAT nash version 5.1.19.6 Starting
Reading all volumes, This make take a while....
Found volume "volgroup01" using metadata type lvm2
VFS: can't find ext3 file system on dev dm-0
Mount: error mounting /dev/root on /sysroot as ext3: invalid argument
Setuproot: moving /DEV failed: no such file or directory
Setuproot: error mounting /proc: no such file or directory
Setuproot: error mounting /sys: no such file or directory
Switchroot: mount failed: no such file or directory
Kernel panic - not syncing attempted to kill init !


So I went into rescue mode by inserting the RHEL original DVD and entering
linux rescue

2) The system booted up on the DVD in rescue mode but failed to discover any existing installations.

3) I then manually scanned and activated logical volumes, but mounting the partitions on the logical volume with the /root partition failed. The other partition on the Logical Volume 2 was cleanly mountable without any errors.

lvm pvscan
lvm vgscan
lvm vgchange -ay
lvm lvscan

mount /dev/mapper/Vol--storage-Vol00

4) This pointed to an instance of corruption of partition information on the root partition of the system, thus rendering it unbootable.

Corrective Actions
1) As no existing backup was available during the time of this recovery, and since the data on the disk was in a totally inaccessible state, the only way ahead was to proceed with data recovery procedures.
2) The partition table on the disk, since it was an ext3 journaling filesystem, was scanned for backup filesystem superblocks.

dumpe2fs /dev/mapper/Vol--storage-Vol00 | grep superblock

3) The listed backup superblocks were then passed on to the mount utility one by one till a noncorrupted superblock was found.

e2fsck -f -b 32768 /dev/mapper/Vol--storage-Vol00

4) The system was then mounted with this superblock and the partition data was corrected. The journaling was automatically converted to ext2 at this point to avoid conflicting superblocks.
5) The system was rebooted at this point but failed when it attempted to read any actual data necessary for booting up on the /root partition .
6) The system was again rebooted with the installation DVD into rescue mode and the partition was then scanned for filesystem errors. All diagnosed errors on the filesystem were fixed.
7) The filesystem scan resulted in the entire existing filesystem to be moved to the 'lost+found' location as the top level file structure was lost though ALL data within it was intact.
8) The data within the partition as available at this stage was then copied to the other empty partition on Logical Volume 2 as a backup before proceeding further.
9) The top level directories had been renamed by the scan utility to '#294942343' like numerical names. Based on the files contained in each of these folders, the actual names of the folders were identified correctly (as later verified) and moved correspondingly.
10) The entire top level file structure was thus recreated and verified with the fstab entries in the system. The permissions of all files were preserved intact throughout the procedures by using the corresponding options provided by the rsync utility.
11) The partition was then re-journaled to return to an ext3 state.

cd /lost+found
tune2fs -j /dev/mapper/Vol--storage-Vol00

12) The system then booted fine into a normal mode and all services configured at boot time started without errors.