Archive for the ‘kludges’ Category

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

redirecting a TCP connection using iptables

Friday, May 8th, 2009

Yesterday I was requested to redirect the traffic to the 80 TCP port of an host to the TCP 8080 port of a second host just for some hours. Thanks to iptables it was been very easy.
First it’s better to enable port forwarding:

# echo 1 >/proc/sys/net/ipv4/ip_forward

Then here comes some iptables commands and rules:

# iptables -F
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -P INPUT ACCEPT
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT

# iptables -t nat -A PREROUTING  -p tcp -m tcp -d HOST1 –dport PORT1 -j DNAT –to-destination HOST2:PORT2
# iptables -t nat -A POSTROUTING -p tcp -d HOST2 –dport PORT2 -j MASQUERADE

If You like, just download this simple shell script.

To display the nat rule:

# iptables -t nat -n -L

many thanks to cyberciti.biz and Chris Siebenmann‘s wiki.