Comments

Nagios Customization: Alerting via SMS, or Anything You Like!

So I find myself needing to tweak my Nagios installation a little bit, in this case I found the need for “out of hours” SMS alerts.

Nagios doesn’t cater for this natively, rather it does however allow you to create your own custom commands, this allows you to specify a script to be executed.

Now I am going to assume you are already quite familiar with Nagios , so here is the command definition from my installation.

# ‘alert-by-sms’ command definition define command{ command_name alert-by-sms command_line /etc/nagios/alert-by-sms.php “** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” } As you can see all this command definition realy does is execute a php script, bear in mind that “/path/to/php /path/to/script ” as the command_line does not seem to work, so just add “#!/path/to/php -q” to the top of the php script (before the opening <?PHP tag). and CHMOD +X the file. The php script used here takes $argv[1] and passes it into a function specific to the SMS api I use, the phone number and API definitions are hard coded ito the script. You don’t really need me to upload my script, and if you do then you shouldn’t be attempting this … Basically Nagios will execute the script, as defined at command_line, the script can do anything you choose. Now to implement the command so it is actually used, I am pretty sure this entry in “timeperiods.cfg” is the default but just incase here it is. # ‘nonworkhours’ timeperiod definition define timeperiod{ timeperiod_name nonworkhours alias Non-Work Hours sunday 00:00-24:00 monday 00:00-09:00,17:00-24:00 tuesday 00:00-09:00,17:00-24:00 wednesday 00:00-09:00,17:00-24:00 thursday 00:00-09:00,17:00-24:00 friday 00:00-09:00,17:00-24:00 saturday 00:00-24:00 } This is what I use for the “out of hours” definition, now to implement the SMS alerting, for this I have simply created a new contact definition in “contacts.cfg”, granted this means there are now two contact definitions for myself. define contact{ contact_name out_of_hours alias Out Of Hours Mobile service_notification_period nonworkhours host_notification_period nonworkhours service_notification_options c,u,r,f host_notification_options d,u,r service_notification_commands alert-by-sms host_notification_commands alert-by-sms email [email protected] } This can be further customized depending on your setup, in this case the contact is me and I want to receive alerts for all servers & services, so I just add the contact “out_of_hours” into the admins contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin,out_of_hours } So there you have it, you now have the ground work to potentially make Nagios fire you alerts anyway you like, you could go as far as having it call you via attached modem, if you _realy_ want, but when you want your servers talking to you via phone call is the day you need to switch to decaff, and head out to the pub once in a while. Now just “nagios -v /path/to/nagios.cfg” to do a quick sanity check and make sure there are no errors (if you have any go back and fix them and run nagios -v again!), if all is ok /etc/init.d/nagios restart (or equivalent for your distribution). As always if you run into problems drop me a comment :-)

Comments

Elmo Live, in Your House Scaring Your Kids.

At what point is a toy, no longer a toy …

When you can hold a conversation with it, is my opinion. Check the video out, Elmo dances, sings, reacts to what the tech says and does to Elmo …

The intelligence of this thing is a little … well creepy. [via: Engadget ]

UPDATE video can be found here

Removed embedded video as was causing site template problems.

Comments

Don’t Underestimate the Power of the Air Duster!

As the old adage goes, any security measure is pretty pointless if the attacker has physical access to the machine.

But surely disk encryption should at least slow this down … right?

Well apparently not, as when booted systems like Bitlocker and Filevault store the key in ram, all the attacker need do, is cool the ram stick with an inverted air duster can, take out the DIMM and place it into another machine where the key can be read from.

Scary stuff, there’s even some information as to what data still remains in the RAM once the machine is powered off …

Check the video at this link out:

https://citp.princeton.edu/memory/

[via: engadget ]

Comments

Backup Exec 9.1 A00084ca - the Data Being Read From the Media Is Inconsistent

This error as of late has been driving me nuts!

Whilst I have still to resolve the issue, I can offer advice to those using ntbackup to diagnose this problem on windows 2003 server or SBS (Small Business Server).

First you will need to stop ALL BackupEXEC services, now try to run a backup to the tape device using ntbackup.

More than likely you will get the following error.

When attempting to run a backup with the Backup Utility for Windows, an error: “The device reported an error on a request to MS_UpdateNtmsOmidInfo. Error reported: 11. There may be a hardware or media problem. Please check the system log for relevant failures” (Figure 1) is displayed.

This is because BackupEXEC 9.1 has not copied a dll to the right location.

Typically this is: %systemroot%\System32\mll_BE.dll

Be sure to check your registry to make sure: \HKEY_LOCAL_MACHINE\SYSTEM\Currentcontrolset\control\NTMS\OMID\tape\be

Simply copy the dll from Program Files\VERITAS\Backup Exec\NT\mll_be.dll (or your relevant installation directory), to %systemroot%\System32\mll_BE.dll.

Reboot and ntbackup should run without error, (If of course you remembered to stop the BackupEXEC services again).

UPDATE:

This was eventually resolved by replacing the faulty scsi controller.

Comments

mySQL Full Text Search With Percentage Scoring (Originally Posted on 3dbuzz.com)

Note I am not the “Buzz” from 3dbuzz.com this is just a coincidence

All right lets begin…

First off you will need to understand how to take advantage of mySQL’s inbuilt fulltext search functionality.

First lets create the table, using the cli or your favorite GUI (i.e. mysql administrator) to run the following SQL statement.

Code:

CREATE DATABASE sion_ft;

USE sion_ft;

CREATE TABLE sion_ft_tutorial (

Id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,

Title VARCHAR (255),

Body LONGTEXT

)

ENGINE=myISAM;

ALTER TABLE sion_ft_tutorial ADD FULLTEXT search (title,body);

Ok we have now created a database, changed to use that database, and created that databases first table, then altered the table to add a fulltext index for both the title and body columns, and called this index “search”.

Notice the “ENGINE=myISAM;”, unfortunately it seems InnoDB does not support full text indexes. At least that’s the problem I ran into using mySQL 4.x.

Now before we go any further we need to put some data into that database so it can be searched.

Code:

INSERT INTO sion_ft_tutorial (title,body) VALUES

('Sion Fulltext tutorial at 3dbuzz', 'Posted originally by sion at the 3dbuzz forums'),

('3DBUZZ.com ', 'Look Listen Learn, forums vtm\'s and more'),

('I am hungry', 'Lets order pizza!!' ),

('hi Ho Hi Ho', 'A forum trolling I will go' ),

('PHP problems?', 'Go to 3dbuzz forums, where some nutter called sion roams.' );

Ok now we have inserted 5 rows of data into the table, we will use this data when testing our fulltext search.

Before we begin with the PHP we need to construct the SQL statement to use the FULL text feature, so keep that CLI OPEN!

Code:

SELECT * FROM sion_ft_tutorial WHERE MATCH(title,body) AGAINST('sion');

+----+----------------------------------+----------------------------------------------------------+

| id | title | body |

+----+----------------------------------+----------------------------------------------------------+

| 1 | Sion Fulltext tutorial at 3dbuzz | Posted originally by sion at the 3dbuzz forum |

| 5 | PHP problems? | Go to 3dbuzz forum, where some nutter called sion roams. |

+----+----------------------------------+----------------------------------------------------------+

Ok so the search is now working no we need to get the relevance score working.

Code:

SELECT *, MATCH(title,body) AGAINST('sion') AS score FROM sion_ft_tutorial WHERE MATCH(title,body) AGAINST('sion');

+----+----------------------------------+----------------------------------------------------------+------------------+

| id | title | body | score |

+----+----------------------------------+----------------------------------------------------------+------------------+

| 1 | Sion Fulltext tutorial at 3dbuzz | Posted originally by sion at the 3dbuzz forum | 0.53033631317832 |

| 5 | PHP problems? | Go to 3dbuzz forum, where some nutter called sion roams. | 0.37130504609119 |

+----+----------------------------------+----------------------------------------------------------+------------------+

As you can see id 1 has the higher score this is because “sion” is found both in the title and the body text.

The “relevance score” is calculated by hard code formulae within mySQL.

Full details on this formulae can be found here : https://dev.mysql.com/doc/internals/en/full-text-search.html

This covers the mySQL side of the system.

PHP

First off we have to make some assumptions for this method to work.

We have to assume that the highest score is equivalent to 100% relevant to the search.

And for this “basic” stage we have to assume that the default mySQL setup is sufficient for our needs, as there is a whole host of things to configure such as minimum word length, and mySQL’s “stop list” to consider.

This will be covered in the “fine tuning” section of this tutorial.

I am also assuming you have read the above section on mySQL and not skipped strait to the PHP code.

First of all as I’m sure you know we need to create a connection to the mySQL server.

Code:

<?PHP

$usr = "mysqlusr";

$pass = "mysqlpass";

$host = "localhost";

$db = "sion_ft";

$connection = mysql_connect($host,$usr,$pass);

mysql_select_db($db,$connection);

?>

Ok so lets now get some data to start playing with.

Code:

<?PHP

$query = "SELECT *, MATCH(title,body) AGAINST('sion') AS score FROM sion_ft_tutorial WHERE MATCH(title,body) AGAINST('sion') ORDER BY SCORE DESC";

$result = mysql_query($query);

$row = mysql_fetch_assoc($result);

??

Now we have the data as mentioned above in the MYSQL section.

Remember I said we have to “assume” the highest score is 100% relevant. well lets do that and start creating relevance percentages.

Code:

$max_score = 0;

$data = array();

do {

if($row['score'] &gt; $max_score){ $max_score = $row['score']; } //because we are ordering by score we can assume on the first run this wil be the max score.

echo $row['title']." ".@number_format(($row['score']/$max_score)*100,0)."%&lt;br&gt;n";

}while($row = mysql_fetch_assoc($result));

Now you should get a list that looks something like the following.

Sion Fulltext tutorial at 3dbuzz 100%

PHP Problems? 70%

Right so lets go over what we have done so far, we have used mySQL’s inbuilt “relevance” calculation and assume the highest “score” to bee 100% as such we have used that score as the “denominator” for the result of the results to calculate their percentage relevance.