Archive

Archive for the ‘Unix’ Category

ldap_add: Invalid syntax (21) – fix

January 21st, 2010 No comments

This error was driving me nuts:

ldap_add: Invalid syntax (21)
additional info: objectClass: value #0 invalid per syntax

despite looking at my ldif a hundred times, until I relized my perl script added white space at the end of the line ….

print "objectClass: top\n";
print "objectClass: person \n";
print "objectClass: organizationalPerson \n";
print "objectClass: inetOrgPerson \n";
print "objectClass: mozillaOrgPerson \n";
print "objectClass: evolutionPerson \n";
print "objectClass: simpleSecurityObject \n";

once changed to :

print "objectClass: top\n";
print "objectClass: person\n";
print "objectClass: organizationalPerson\n";
print "objectClass: inetOrgPerson\n";
print "objectClass: mozillaOrgPerson\n";
print "objectClass: evolutionPerson\n";
print "objectClass: simpleSecurityObject\n";

The ldap gods were smiling again, hope this saves someone some time.

Parse a csv file using perl

January 21st, 2010 No comments

While parsing and converting some CSV files to ldif’s I needed a perl script, the Test::CSV module is helpful :

#!/usr/bin/perl
use strict;
use warnings;
use Text::CSV;

my $file = ‘prospects.csv’;

my $csv = Text::CSV->new();

open (CSV, “< ", $file) or die $!;

while () {
if ($csv->parse($_)) {
my @columns = $csv->fields();
print “@columns\n”;
} else {
my $err = $csv->error_input;
print “Failed to parse line: $err”;
}
}
close CSV;

Centos5: nfs clients get premission denied

February 18th, 2009 No comments

While working on ny NFS cluster project , I could not mount my nfs exports from clients ( FreBSD & Centos ).

on the FreeBSD client I got these responses :
[udp] server:/data/dir1: Permission denied
on the CentOS client I got these responses:
mount: server:/data/dir1 failed, reason given by server: Permission denied

On the Centos NFS server the logs showed :
mountd[12377]: authenticated mount request from client1:984 for /data/dir1 (/data/dir1)

Turns out there’s a bug in CentOS and modprobe does not mount the nfsd procs , you can fix the issue by adding :

none /proc/fs/nfsd nfsd auto 0 0

to /etc/fstab
or manually ( if you want to make sure that is the issue ) :

/bin/mount -t nfsd nfsd /proc/fs/nfsd

find whats causing a busy partition in freebsd

February 13th, 2009 No comments

trying to umount an nfs or external disk partition and got “partition busy” ?
use fstat -f to find out what the hold up …

-f Restrict examination to files open in the same file systems as
the named file arguments, or to the file system containing the
current directory if there are no additional filename arguments.
For example, to find all files open in the file system where the
directory /usr/src resides, type ``fstat -f /usr/src''.

Install check_mysql_perf on FreeBSD

December 18th, 2008 No comments

I recently had to install check_mysql_perf on our nagios server runing FreeBSD.

After a few failed attempts , I contacted the author Gerhard asking for help. Sure enough a few minutes ( !!! ) later he send me a reply back : 

Add the following at the end of the check_mysql_perf.c : 

char* strndup(const char* string, size_t n)
{
char* copy_string = 0;

if(0 == string || 0 == n)
return 0;

copy_string = (char*) malloc(n + 1);
if(0 == copy_string)
return 0;

memcpy(copy_string, string, n);
*(copy_string + n) = ‘\0′;

return copy_string;
}

and find this line ( line number 77 in my file ) :

char *mysql_status_historical (MYSQL *, char *, long *, int);

and add below it :

char *strndup(const char*, size_t);

this worked like a charm and I have a working plugin now.

thanks Gerhard !!!