ubuntusnmpnagioscacti

Cacti Thresholds to Send SNMP Trap


I recently started working with Cacti and Nagios on Ubuntu and I have limited knowledge of them. Currently Cacti sends an email when a threshold is changed. I would like to also have this threshold send an SNMP alert, in addition to the current email.

I googled this but could not find an exact answer. Is there any easy way to archive this? Am I missing any settings or something?


Solution

  • There is no easy way. You can send a syslog message to an Element Management System and read the syslog on the element management system. Change /etc/syslog.conf to forward alerts t EMS system by doing the following.

    1. Go to Settings -> Thresholds.
    2. Change Syslog Facility to Local 5
    3. Open /etc/syslog.conf
    4. Add remote ip address like so Local5.* @@192.1.3.1:514 You can change 514 based on your remote port.
    5. Restart syslog. service syslog restart
    6. Voila! Check that you are receiving syslog on remote server.

    The Hard Way. 1. Open thold_function.php in the thold plugin folder 2. Write a php function to send an alert. 3. Add the function in the logger function.

    function logger($desc, $breach_up, $threshld, $currentval, $trigger, $triggerct, $urlbreach)

    Here is code you can adapt.

       <?php
    
    // send a trap
    $sourcehost = '123.45.12.3';
    $destinationhost = '1.1.4.6';
    $community = 'public';
    $version = '2c';
    $enterprise = '.1.3.6.1.4.1.99999.11.1';
    $sourcehostname = 'SourceHostName';
    $severity = 4;
    $detail = 'All information about alarm.';
    $message = 'Text to display in alarm summary.';
    
    $uptime = '1001';
    
    
    $billingid              =             76197;
    $period                =             '2014/05/25 22:31:11 -> 2014/05/25 23:01:11';
    $siteid      =             '123456';
    $customer          =             'University of Maryland';
    $cc                         =             380;
    $country             =             'Ukraine';
    $amount             =             '67.05  Euro';
    $minutes            =             '119.73';
    $nrofcalls            =             12;
    
    $command ="snmptrap -v ".$version. " -c ".$community." ".$destinationhost." ".$uptime." ".$enterprise." .1.3.6.1.4.1.99999.222.11.1 s '".$sourcehost."' .1.3.6.1.4.1.99999.222.11.2 s '".$sourcehostname."' .1.3.6.1.4.1.99999.222.11.3 i '".$severity."' .1.3.6.1.4.1.99999.222.11.4 s '".$detail."' .1.3.6.1.4.1.99999.222.11.5 s '".$message."' .1.3.6.1.4.1.99999.222.11.6 s '".$clarifysiteid."' .1.3.6.1.4.1.99999.222.11.7 i '".$billingid."' .1.3.6.1.4.1.99999.222.11.8 s '".$period."' .1.3.6.1.4.1.99999.222.11.9 s '".$customer."' .1.3.6.1.4.1.99999.222.11.10 i '".$cc."' .1.3.6.1.4.1.99999.222.11.11 s '".$country."' .1.3.6.1.4.1.99999.222.11.12 s '".$amount."' .1.3.6.1.4.1.99999.222.11.13 s '".$minutes."' .1.3.6.1.4.1.99999.222.11.14 i ".$nrofcalls;
    
    
    print($command);
    
    system($command);
    
    ?>