Monthly Archives: January 2012

Flume DFO local storage usage check

It might be useful when flume driver failed.

#!/usr/bin/perl
#Check flume DFO directory size

sub trim($);
use strict;
use warnings;

my $exit=0;
my $backlog_size = `du -s flume | awk {‘print \$1’}`;
$backlog_size = trim($backlog_size);

if ( !$ARGV[0] || !$ARGV[1])
{
########################### Usage of the plugin
print “check_flume_backlog critical_size warning_size   \n”;
exit 0;
}

######################### Case 1 if State is Critical
if ($backlog_size > $ARGV[0])
{
print “Critical: “.$backlog_size.”b\n”;
exit 2;
}

######################## Case 2 if State is Warning
if($backlog_size > $ARGV[1] || $backlog_size == 0)
{
print “Warning: “.$backlog_size.”b\n”;
exit 1;
}

######################## Case 3 if State is OK
if($backlog_size < $ARGV[0] && $backlog_size < $ARGV[1])
{
print “OK: “.$backlog_size.”b\n”;
exit 0;
}

sub trim($)
{
        my $string = shift;
        $string =~ s/^\s+//;
        $string =~ s/\s+$//;
        return $string;
}

And for centralised monitoring..
 

#!/usr/bin/php
<?php
//Check flume DFO directory size from all collection servers

// default warning 500MB
if(!isset($argv[1])) $warning = “5000000000”;
else $warning = $argv[1];
// default critical 1GB
if(!isset($argv[2])) $critical = “10000000000”;
else $critical = $argv[2];

$servers = array();
$results = “”;
$total = 0;
$ok = 0;
$warning_list = “”;
$critical_list = “”;

//-snip-  get server lists from nagios

foreach($servers as $server)
{
        //echo $server.”\n”;
        $cmd = “check_nrpe -H $server -c check_flume_backlog -a ‘$critical $warning'”;
        $result = “[“.$server.”] “.exec($cmd).”\n”;

        $total++;
        if(preg_match(“/OK/”,$result)) $ok++;
        else if(preg_match(“/Warning/”,$result)) $warning_list.=$server.”,”;
        else if(preg_match(“/Critical/”,$result)) $critical_list.=$server.”,”;

        $results.=$result;
}

if(!empty($critical_list)) $notification = “CRITICAL: “.$critical_list;
else if(!empty($warning_list))  $notification = “WARNING: “.$warning_list;
else $notification = “OK: “.$ok.”/”.$total;

echo $notification.”\n”.$results;

?>

Default fixed version value when creating an issue in JIRA

You can try to add some JavaScript code to the field that will perform required operation for you, in this case it should be ‘Fix Version’ field. You can refer to this documentation as a guideline:
http://confluence.atlassian.com/display/JIRACOM/Using+JavaScript+to+Set+Custom+Field+Values

In order to get the ID for the specific version, you need to check the ID from the database. For example, you can run the following SQL query in the database:

SELECT ID, PROJECT, vname FROM projectversion;

Once you found the ID for the specific version (i.e. ‘Backlog’), you need to access to the ‘Administration’ > ‘Fields’ > ‘Field Configuration’ and click on the Edit link for the Fix Version field. Then, add the following code into the description field on that page:

<script type="text/javascript">
if (document.getElementById("fixVersions").value == "")
{ document.getElementById("fixVersions").value = "10005"; }

</script>

Please change the value ‘10005’ to the ID value that you found from the database.