Archive for the ‘kludges’ Category

A sort of diff implementation in the MS-DOS world

Thursday, July 7th, 2011

The MS-DOS FC.EXE programs is useful to compare two files. Differences between files are shown introduced by the string “*****” otherwise, if the files are equal, no asterisks will are displayed.
Redirecting the output on a temporary file, using SET /P it’s possible to define a variable in order to handle both the cases (the files are different or the files are equals).

A sort of *nix diff implementation made by a batch script may be the following:

@echo off
fc %1 %2|find /c “*****” > tempfile.out
SET /P TestVar=<tempfile.out
del tempfile.out
echo TestVar=%TestVar%
if %TestVar% == 0 GOTO:FEQUALS
echo %1 and %2 are different
GOTO:EOF
:FEQUALS
echo %1 and %2 are equals

Off corse if You need something better of this silly diff version, You may find useful djcpp, cygwin or other unix-like platforms

compiling clam-av 0.96.3 in an old linux system

Wednesday, September 22nd, 2010

If for some reason You are trying to compile clamav-0.96.3 in an old linux system (e.g. a Debian sarge with a 3.3.5 gcc version) You will get a “compiler too old” error.
I know it is a kludge, but it’s possible to ent the compilation process in two steps.
first, opet the ./clamav-0.96.3/libclamav/c++/configure file and disable the line

as_fn_error “C++ compiler too old (${gxx_version})” “$LINENO” 5

e.g. writing [02].*) instead of [023].*) in the previous line.
second, run the main ./configure script disabling llvm.

./configure –disable-llvm

Then run make and make install as usual.

No such directory error calling lynx in a shell script

Monday, June 14th, 2010

Some time ago I was testing a shell script nagios plugin. Running this script from command line was ok, but once called from nagios scheduling, the plugin standard error was

/root/: No such directory

Due to some little problem (is this a lynx problem?)  I needed to set the HOME environment variable before calling lynx.

MYSTR=`export HOME=/tmp && /usr/bin/lynx -dump “http://$MYHOST/$MYURL?MYFILTER=$MYPARAM”`

turn off wordpress php error reporting

Tuesday, June 1st, 2010

If, due to your provider php configuration, Your wordpress pages are writing some error messages like

Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 520
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 535
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 542
Deprecated: Assigning the return value of new by reference is deprecated in /home/j/jose/public_html/wp-settings.php on line 578
Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/j/jose/public_html/wp-settings.php on line 18

php warning message

In lost-in-code website You can find the solution: just add theese two lines

error_reporting(0);
@ini_set(‘display_errors’, 0);

at the bebinning og wp-config.php file.

NFS mount from an AIX client (reprise)

Thursday, April 22nd, 2010

Today I needed to mount a linux nfs exported directory from a very old AIX server:

AIX prompt> uname -a
AIX matusalem 3 4 00202856E800

This time, I had to do an additional operation to my previous notes about nfs and AIX.
The mount command issued on the AIX matusalem client failed with the error

vmount: Not owner

and the linux server reported

Apr 22 12:21:03 linuxbox kernel: nfsd: request from insecure port (192.168.5.5:34506)!

in /var/log/messages file, where 192.168.5.5 is the old AIX IP address.
After adding the word “insecure” in the nfs option of my /etc/exports file in the linux server I was able to mount the nfs share.

/opt/share/dir 192.168.5.5(rw,sync,insecure)

not – integer number comparison

Monday, March 8th, 2010

Some day ago I needed a shell script to compare some decimal values, but it’s not possible to compare as usual

MAX=33.33
if [ $MYVALUE -gt $MAX ]; then ….

Running something like this will bring the error message “integer expression expected!”.

With a little help from bc, it’s possible to compare non decimal values. Here follows a simple unuseful nagios plugin to compare decimal values:

#!/bin/bash

MYVALUE=$1
MAXWARN=”82.5″
MAXCRIT=”91.3″
MYDESCR=”Value description”
RET_OK=”0″
RET_WARN=”1″
RET_CRIT=”2″
RET_UNKN=”3″

PERFDATAMSG=”|’$MYDESCR’=$MYVALUE;$MAXWARN;$MAXCRIT”

if [ $(echo "$MYVALUE > $MAXCRIT"|bc) -gt 0 ]; then
echo “ERROR – $MYDESCR=$MYVALUE$PERFDATAMSG”
exit $RET_CRIT
fi

if [ $(echo "$MYVALUE > $MAXWARN"|bc) -gt 0 ]; then
echo “WARNING – $MYDESCR=$MYVALUE$PERFDATAMSG”
exit $RET_WARN
else
echo “OK – $MYDESCR=$MYVALUE$PERFDATAMSG”
exit $RET_OK
fi

FH_DATE_PAST_20XX spamassassin false positives

Thursday, January 7th, 2010

Spamassassin is a good way to fight spam but a quite curious bug went out in the beginning of the new year. This bug may produce a great number of valid mail messages tagged as spam.
The reason is all mail messages will match the FH_DATE_PAST_20XX rule since the 1st january 2010.
When the current release (3.2.5) was released, a message date in the year 2010 was reasonable seen as a bad mail, but now we are …in the future.
So, this rule

##{ FH_DATE_PAST_20XX
header FH_DATE_PAST_20XX Date =~ /20[1-9][0-9]/ [if-unset: 2006]
describe FH_DATE_PAST_20XX The date is grossly in the future.
##} FH_DATE_PAST_20XX

have to be disabled, waiting for the new spamassassin release.
The way suggested by spamassassin staff is to add the following line in the local.cf file:

score FH_DATE_PAST_20XX 0.0

NFS mount from an AIX client

Wednesday, August 26th, 2009

Today I had to mount a NFS linux machine (e.g. 192.168.33.33) from an AIX client.
So I noticed the “normal” mount command may not work:

# mount 192.168.33.33:/opt/something /home/guest/tmp
mount: 1831-008 giving up on:
192.168.33.33:/opt/something
vmount: Operation not permitted.

As reported by Doomlands of the Lunatics, apparently, AIX uses high ports to establish the connectivity to NFS Server, but Linux NFS Server requires low ports (below 1024). For this reason We have to tell AIX to use those reserved ports.

# nfso -o nfs_use_reserved_ports=1
Setting nfs_use_reserved_ports to 1

OK, now We can mount the directory on the Linux NFS server:

# mount 192.168.33.33:/opt/something /home/guest/tmp

A “case” history for MySQL select distinct

Tuesday, June 23rd, 2009

on an old linux running mysql4.0.x, I noticed a simple SQL query

select distinct item from tablename

returned a case insensitive results (e.g. “foo”, “FOO, “Foo” was listed on a different rows).

But how to obtain a unique record “foo” from a select distinct?

Reading this post I was able to obtain a case insensitive result from my “select distinct” SQL query.

# mysqldump dbname > dbname.dump
# mysqladmin drop dbname
# mysqladmin create dbname
# vi dbname.dump

using vi the editor I added the “binary” attribute to the record definition, for instance

create table kludges ( shortdesc varchar(100) BINARY, fulldesc text)

and then

# mysql dbname < dbname.dump

Windows monitoring with nagios

Friday, May 22nd, 2009

Nagios is a good monitoring system in the GPL world.

You can be informed in “real time” about the state of your systems, even if You need to know the state of a M$ host. ;-)
Recently I have found a strange error in monitoring a Windows host: NSClient – ERROR: Could not get data for 5 perhaps we don’t collect data this far back? or NSClient – ERROR:Failed to get PDH value.

A strange error from a windows host

A strange error from a windows host

In the NSClient++ logs, I found some strange lines like this:

\PDHCollector.cpp(133) Failed to open performance counters: \?¦ƒ¦(_total)\?¦ƒ¦: PdhAddCounter failed: -1073738824: The specified object is not found on the system.

The solution is in rebuilding the performance counter files. On windows 2003 this could be done with:

C:\> lodctr /R