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";
        }
Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s