Keeping Time on Linux using ntpdate and hwclock

If you want a quick way to keep your linux system up to current time then just pop in our little script and your stay on time.

You can also use the following script to run every hour from your cronjob or create a file and copy the following to it. Place file in /etc/cron.hourly
#!/bin/sh
#Quick script to update time and push time to hardware clock
#Created

If you want a quick way to keep your linux system up to current time then just pop in our little script and your stay on time.


You can also use the following script to run every hour from your cronjob or create a file and copy the following to it. Place file in /etc/cron.hourly
#!/bin/sh
#Quick script to update time and push time to hardware clock
#Created by Cubert for squidworks.net
/usr/sbin/ntpdate -s
/sbin/hwclock --adjust
/sbin/hwclock --systohc

ELGG Plugin:AdBrite -> BritePics patch for TidyPics

As part of Squidworks community involvement in Open source software we have added another code enhancement to the ELGG community.

This patch adds the BritePics Advertising feature to TidyPics plugin for ELGG.
Now when your images are viewed in full size your Adbrite account will post a quick ad over image. It also helps protect your images as the images is now wrapped in a flash player

As part of Squidworks community involvement in Open source software we have added another code enhancement to the ELGG community.

This patch adds the BritePics Advertising feature to TidyPics plugin for ELGG.
Now when your images are viewed in full size your Adbrite account will post a quick ad over image. It also helps protect your images as the images is now wrapped in a flash player

Just copy the image.php file to /mod/tidypics/view/default/object/

remember to backup old file before you over write it.

ELGG->BritePicPlugin

Hobbit / XYMON undefined reference to `clock_gettime’

Hobbit / XYMON does not compile on CentOS 5 and complains about clock_gettime issues.

Here is how to fix this issue.
Download Hobbit-4.2.3.tar.gz
#1 make sure pcre-devel is installed (#~yum install pcre-devel)
#2 add xymon user (#~useradd xymon)
#3 set varible for “ltr” (#~LIBRTDEF=-lrt)
#4 export varible (#~export LIBRTDEF)
#5 Configure Hobbit inside hobbit src directory (#~./configure –client)
#6 Compile program (#~make)
#7 Install program (#~make install)
#8 Start

Hobbit / XYMON does not compile on CentOS 5 and complains about clock_gettime issues.

Error: timefunc.c:55: undefined reference to `clock_gettime’

Here is how to fix this issue.
Download Hobbit-4.2.3.tar.gz
#1 make sure pcre-devel is installed (#~yum install pcre-devel)
#2 add xymon user (#useradd xymon)
#3 set varible for “ltr” (#LIBRTDEF=-lrt)
#4 export varible (#export LIBRTDEF)
#5 Configure Hobbit inside hobbit src directory (#./configure –client)
#6 Compile program (#make)
#7 Install program (#make install)
#8 Start hobbit client (#/home/xymon/client/runclient.sh start)

Afterwards your hobbit / xymon client should be running on your CentOS or Fedora core systems.


cc -o ../client/hobbitd_client -Wl,--rpath=/usr/lib64
hobbitd_client.o
hobbitd_worker.o hobbitd_buffer.o client_config.o
../lib/hobbitclient.a
-L/usr/lib64 -lpcre
../lib/hobbitclient.a(timefunc-client.o): In function `gettimer':
/usr/src/xymon-4.2.3/lib/timefunc.c:55: undefined reference to
`clock_gettime'
../lib/hobbitclient.a(timefunc-client.o): In function `getntimer':
/usr/src/xymon-4.2.3/lib/timefunc.c:67: undefined reference to
`clock_gettime'
collect2: ld returned 1 exit status
make[1]: *** [../client/hobbitd_client] Error 1

If You get the Following Errors:

gcc -o ../client/xymond_client -Wl,--rpath,/usr/lib64 xymond_client.o    xymond_worker.o xymond_buffer.o client_config.o ../lib/xymonclient.a -L/usr/lib64 -lpcre
xymond_worker.o: In function `net_worker_run':
/root/xymon-4.3.0/xymond/xymond_worker.c:292: undefined reference to `locator_init'
/root/xymon-4.3.0/xymond/xymond_worker.c:298: undefined reference to `locator_register_server'
/root/xymon-4.3.0/xymond/xymond_worker.c:312: undefined reference to `locator_serverdown'
xymond_worker.o: In function `net_worker_heartbeat':
/root/xymon-4.3.0/xymond/xymond_worker.c:80: undefined reference to `locator_serverup'
xymond_worker.o: In function `net_worker_run':
/root/xymon-4.3.0/xymond/xymond_worker.c:317: undefined reference to `locator_serverdown'

 

The just Add "locator.o" to CLIENTLIBOBJS in lib/Makefile inside of the XYMON build directory. Then re-run "make" and you should be able to build the client.

Enjoy….

Get EPOCH using DATE function on linux

If you need epoch from a shell cmd line on a linux system the date cmd is a great way to do it.
date +%s -d “$a”
This code by will print epoch out at the cmd line in a ssh window or terminal window

If you need epoch from a shell cmd line on a linux system the date cmd is a great way to do it.
date +%s -d "$a"
This code by will print epoch out at the cmd line in a ssh window or terminal window

Howto: MySQL Full Text Search in PHP

This tutorial is intended for Text Searching using MySQL (http://www.MySQL.com/) and PHP (http://www.php.net) and will focus on the Full-text capabilities presented by MySQL.

Synopsis

We run a website that hosts web blogs, we have a database that contains blog posts. We might create a table in our database using a statement like this:

CREATE TABLE blogs (body TEXT, title VARCHAR(250), id INT NOT NULL auto_increment, PRIMARY KEY(id);
 

This tutorial is intended for Text Searching using MySQL (http://www.MySQL.com/) and PHP (http://www.php.net) and will focus on the Full-text capabilities presented by MySQL.

Synopsis

We run a website that hosts web blogs, we have a database that contains blog posts. We might create a table in our database using a statement like this:

CREATE TABLE blogs (body TEXT, title VARCHAR(250), id INT NOT NULL auto_increment, PRIMARY KEY(id);
 
 
 
 
 

 

How to modify your current database to accommodate Full-text searching.

Now we want to provide a simple search form and the ability to search keywords from the body field in the table “blog” of your database. First you will need to turn on Full Text Search for the table “blog” in your MySql database. Here is how to do that in MySql.

ALTER TABLE blog ADD FULLTEXT(body, title);

How to use a simple Full-text search to quickly gather relevant responses.

Lets create our PHP form and database query to support our search. I normally create a single php file called “search.php” then I “include(“search.php”)” where ever I want my search form and returning search data go but I can see where you may want to split this up and have the form and returning data in different areas so change as you see fit.

search.php
<?php
$keyword = $_POST[‘keyword’];
//we will assume your including this search in your index.php
//if not replace index wiht search.php or any page your going to do the sql query and display
//from.
?>
<h2>Search Our Archives</h2>
<form action=”index.php” enctype=”application/x-www-form-urlencoded” method=”post”>
<input name=”keyword” type=”text” />
<input type=”submit” value=”Search” />
</form>
<br>
<?php
if ($keyword != ”) {

        mysql_connect(“localhost”, “username”, “password”);

        mysql_select_db(“database_name”);

        $sql = ”
            SELECT body,
                MATCH(body) AGAINST(‘$keyword’) AS score
                FROM blog
            WHERE MATCH(body) AGAINST(‘$keyword’)
            ORDER BY score DESC
        “;
        $myresult = mysql_query($sql);
            while($row = mysql_fetch_array($myresult)) {
                echo “<table border=”0″><tbody><tr>”;
                echo “<td>Search – SCORE</td><td>Content</td></tr>”;
                echo “<tr><td><strong>” . $row[‘score’] . “</strong></td>”;
                echo “<td>” . $row[‘body’] . “</td></tr>”;
                echo “</tbody></table>”;
            }
    }
?>

This search.php makes a quick and easy Full Test Search form and display for the data. It checks $keywords to validate data before displaying the data in a table. It includes the MySQL score returned by the Full Text Search. I hope this helps someone out there get a search up and running fast.

Enjoy..

Remove CRLF from windows PHP files.

I have had a few guys ask me, Shannon I have a Windows guy developing web aps in PHP but I run them on a Linux (LAMP) system. Some times the code seems to fail and I find the files populated with Carrage Return Line Feed or better seen while looking at a windows file on a linux system in a text editor ( ^M ). This has been know

I have had a few guys ask me, Shannon I have a Windows guy developing web aps in PHP but I run them on a Linux (LAMP) system. Some times the code seems to fail and I find the files populated with Carrage Return Line Feed or better seen while looking at a windows file on a linux system in a text editor ( ^M ). This has been know to have adverse effects on LAMP systems at times and could cause web errors.

Great we now know the why.. How do we fix it?

Simple, Linux provides the program to review a file and make the mods and we can the loop it through a directory to do all files. Here is the cmd you want to use.
find (path to top level folder) -type f -exec dos2unix {} \;

We use the program “find” to get and pipe our files to the cmd dos2unix which is the program that is actually doing the repairs. We use both programs together to produce the desired effect of removing all CRLF from a directory of windows files like a php website.

Remember always backup your files first, be safe.

How-to : Installing RRDTool on centos 5 using yum

Yes, I know CentOS 5 does not come with a repository that holds valid redhat style rpm’s for rrdtool. So here is how we fix that. We are going to echo to a new file the repo information you will need to allow yum to install rrdtool.

We create a file called dag.repo in /etc/yum.repos.d/ by running the echo cmd below. Just copy and past it in to your putty

Yes, I know CentOS 5 does not come with a repository that holds valid redhat style rpm’s for rrdtool. So here is how we fix that. We are going to echo to a new file the repo information you will need to allow yum to install rrdtool.

We create a file called dag.repo in /etc/yum.repos.d/ by running the echo cmd below. Just copy and past it in to your putty window and hit [enter] once. Then let’s cat the file to make sure it has saved correctly.


echo "[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el\$releasever/en/\$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1" > /etc/yum.repos.d/dag.repo

Now run

[root@localhosts]#cat /etc/yum.repos.d/dag.repo
And you will see this

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1

Now run
[root@localhosts]# yum install rrdtool

This is also good for

awstats
cacti
bandwidth
cfengine
ClamAV
Claws Mail
darkstat
dante
devilspie
dnstop
dvd95
dvdrip
etherape
flash-plugin
fuse
gkrellm
iperf

Another good place to get rrdtool for cent if you just want to download the RPM’s and go..
RRDTOOL