Add Scroogle to your search area in Firefox 2.0 Install the 'Scroogle Scraper' search plugin.

February 2011


maybe you have a bunch of daily rsnapshot cronjob backups and you’d like to know when they last ran. you can check the directory for the daily directory’s last modification time like this:

#!/bin/bash
BACKUPLIST=("/mnt/backup1/site1.example.com" "/mnt/backup1/site2.example.com")
for BACKUP in ${BACKUPLIST[@]}
do
        echo -ne "Checking $BACKUP: "
        cd $BACKUP
        CHECKCOMMAND=`find . -maxdepth 1 -mtime -2 -printf "%TY-%Tm-%Td %TT\n"`
        if [[ "$CHECKCOMMAND" == "" ]]; then
                echo -ne "\t ERROR: NO BACKUP found for yesterday! "
                MOSTRECENT=`ls -alht $BACKUP|head -n 3|tail -1|awk '{print $6 " " $7 " " $8}'`
                echo "most recent: $MOSTRECENT"
        else
                echo -e "\t okay"
        fi
done

normally nagios uses /bin/mail to send notifications. if you’d prefer it used another smtp server, you could download this perl file: http://caspian.dotconf.net/menu/Software/SendEmail/

and then change your commands file, a-like-a this:

define command{
        command_name    notify-host-by-email
        command_line    /home/nagios/sendEmail -s SMTPIPADDRESS -f nagios@example.com -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" -xu nagios@example.com -t $CONTACTEMAIL$ -xp MYSMTPPASSWORD -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
        }
 
# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /home/nagios/sendEmail -s SMTPIPADDRESS -f nagios@example.com -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" -xu nagios@example.com -t $CONTACTEMAIL$ -xp MYSMTPPASSWORD -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"
        }

You want to include some javascript on someone else’s page so you can track their hits.
you whip up some ajaxy code to do that

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  }
xmlhttp.open("POST","http://example.com/pixel.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var url=escape(location.href);
var uid=1234;
var referrer=escape(document.referrer);
xmlhttp.send("url="+currenturl+"&referrer="+referrer+"&userid="+uid);

but it doesn’t work because you’re trying to do a cross-site ajax post.

what to do? pass info to a script posing as an image!

var url=escape(location.href);
var referrer=escape(document.referrer);
var pixel = new Image();
pixel.src = 'http://example.com/pixel.php'+ '?' + "url="+currenturl+"&referrer="+referrer+"&userid="+uid;

to call it, simply include these two lines on the page

<script type="text/javascript">var uid=4321;</script>
<script type="text/javascript" src="http://example.com/pixel.js"></script>

Here are my notes for setting up NRPE with two MySQL checks on a server so Nagios can monitor it:

(in mysql) GRANT usage,REPLICATION CLIENT ON *.* TO 'nagios'@'localhost' IDENTIFIED BY 'somepasswd'
yum install make
yum install openssl-devel
wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure
make
make install
cd ..
wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
useradd nagios
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
yum install xinetd
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
vi /etc/services, add:
	nrpe            5666/tcp                        # NRPE
service xinetd restart
(test with:) /usr/local/nagios/libexec/check_nrpe -H localhost	
vi /etc/xinetd.d/nrpe
	only_from = 127.0.0.1 (replace with nagios_ip_address)
service xinetd restart
vi /usr/local/nagios/etc/nrpe.cfg (add these two checks)
	command[check_mysql]=/usr/local/nagios/libexec/check_mysql_health --hostname localhost --username nagios --password somepasswd --mode connection-time
	command[check_mysql_replication]=/usr/local/nagios/libexec/check_mysql_replication.pl -sl nagios -spd somepasswd -sa localhost
wget http://labs.consol.de/wp-content/uploads/2010/12/check_mysql_health-2.1.5.tar.gz
tar zxvf check_mysql_health-2.1.5.tar.gz
cd check_mysql_health-2.1.5
./configure
make
make install
cd /usr/local/nagios/libexec/
vi check_mysql_replication.pl
	paste in content from https://www.monitoringexchange.org/attachment/download/Check-Plugins/Database/MySQL/check_mysql-replication-pl/10-03-26_06-55-00_check_mysql-replication.pl
chown nagios.nagios check_mysql_replication.pl
chmod +x check_mysql_replication.pl
service xinetd restart
(on nagios box): /usr/local/nagios/libexec/check_nrpe -H targetipaddress -c check_mysql

Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2013, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah