altering check_disk_smb nagios v3 to add performance data.

Open a linux console (putty?)
type the following command;
vim /usr/local/nagios/libexec/check_disk_smb

In the file scroll down to rule “187” it should be located right below ”

my ($mountpt) = "<a>\\\\$host\\$share</a>;"

Add the following bulk of text by using “Shift + I” to enter the insert mode.

Then you need to make sure the data is output on the prompt as soon as nagios executes this command. The returned string is created a bit lower in the file. Search for the following.

if ((($warn_type eq "P") &amp;&amp; (100 - $capper) &lt; $warn) || (($warn_type eq "K") &amp;&amp; ($avail_bytes &gt; $warn))) {
                $answer = "Disk ok - $avail ($capper%) free on $mountpt \n";
        } elsif ((($crit_type eq "P") &amp;&amp; (100 - $capper) &lt; $crit) || (($crit_type eq "K") &amp;&amp; ($avail_bytes &gt; $crit))) {
                $state = "WARNING";
                $answer = "WARNING: Only $avail ($capper%) free on $mountpt\n";
        } else {
                $state = "CRITICAL";
                $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
        }

Replace it with something like this…

if ((($warn_type eq "P") &amp;&amp; (100 - $capper) &lt; $warn) || (($warn_type eq "K") &amp;&amp; ($avail_bytes &gt; $warn))) {
                $answer = "Disk ok - $avail ($capper%) free on $mountpt | total=$total; used=$used; free=$avail;\n";
        } elsif ((($crit_type eq "P") &amp;&amp; (100 - $capper) &lt; $crit) || (($crit_type eq "K") &amp;&amp; ($avail_bytes &gt; $crit))) {
                $state = "WARNING";
                $answer = "WARNING: Only $avail ($capper%) free on $mountpt | total=$total; used=$used; free=$avail;\n";
        } else {
                $state = "CRITICAL";
                $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt | total=$total; used=$used; free=$avail;\n";
        }

effectivly we added this as performance output for nagios or any other iterp. like centreon…
| total=$total; used=$used; free=$avail;

Have fun!

 

my ($total) = ($1*$2)/1024;
 my ($used) = int($total-$avail);
        if (int($total / 1024) &gt; 0){
                $total = int($total / 1024);
                if (int($total /1024) &gt; 0){
                        $total = (int(($total / 1024)*100))/100;
                        $total = $total . "G";
                }else{
                        $total = $total . "M";
                }
        }else{
                $total = $total . "K";
        }
        if (int($used / 1024) &gt; 0){
                $used = int($used / 1024);
                if (int($used /1024) &gt; 0){
                        $used = (int(($used / 1024)*100))/100;
                        $used = $used . "G";
                }else{
                        $used = $used . "M";
                }
        }else{
                $used = $used . "K";
        }

About Chris Gralike

Momenteel ben ik manager van de afdeling business continuity bij de zakelijke IT dienstverlener AMIS Services BV. Sinds 2003 ben ik actief in de ICT branche. Tussen 2003 en nu heb ik verschillende rollen vervuld. In de rollen: systeem- en netwerkbeheer, system engineer, servicemanager en nu practice manager ben ik in contact gekomen met uiteenlopende technologieën, methodologieën, ideeën, oplossingen en innovaties. Een rijke ervaring waarmee ik de klanten van Conclusion en AMIS elke dag probeer te ondersteunen. Mijn credo: 'Altijd opzoek een win-win tussen business en technologie.'

Posted on March 12, 2009, in Linux, Nagios / Centreon and tagged , , , , , , , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: