~ubuntu-branches/debian/stretch/jffnms/stretch

« back to all changes in this revision

Viewing changes to engine/pollers/cisco_saagent_fwpacketloss.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2012-05-27 17:25:29 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120527172529-w0bkk0qo3jz8vkhx
Tags: 0.9.3-1
* New upstream release
* Adjusted configurations for new apache standard Closes: #669853
* Removed orphan files Closes: #672385
* Generate valid DB config
* Fixup default config files Closes: #655654

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/* This file is part of JFFNMS
3
3
 * Copyright (C) <2002-2005> Javier Szyszlican <javier@szysz.com>
 
4
 * Copyright (C) 2012 Craig Small <csmall@enc.com.au>
4
5
 * This program is licensed under the GNU GPL, full terms in the LICENSE file
5
6
 */
6
 
function poller_cisco_saagent_fwpacketloss($options) {
 
7
function poller_cisco_saagent_fwpacketloss($options)
 
8
{
 
9
    if (empty($options['ro_community']) or !is_numeric($options['index']))
 
10
        return FALSE;
 
11
 
 
12
    $sa_oid = '1.3.6.1.4.1.9.9.42.1.5.2.1';
 
13
    $ip = $options['host_ip'];
 
14
    $comm = $options['ro_community'];
 
15
    $inst = $options['index'];
7
16
        
8
 
    if (!is_array($GLOBALS["cisco_saagent_fwpacketloss"][$options["host_id"]]) && $options["ro_community"]) {
9
 
        $i=0;
10
 
        while ( !is_array($fwpacketloss) and $i++ <=2 ) {
11
 
            $fwpacketloss_sd=snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.26",1);
12
 
            $rtlnum=snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.1",1);
13
 
        }
14
 
 
15
 
        if ( is_array($fwpacketloss_sd) ) 
16
 
        foreach ($fwpacketloss_sd as $key=>$entry) {
17
 
            $key=explode(".",$key);
18
 
            $key=$key[count($key)-1];
19
 
 
20
 
            $fwpacketloss_sd[$key]=$entry;
21
 
        }
22
 
 
23
 
        if ( is_array($rtlnum) ) 
24
 
        foreach ($rtlnum as $key=>$entry) {
25
 
            $key=explode(".",$key);
26
 
            $key=$key[count($key)-1];
27
 
 
28
 
            $rtlnum[$key]=$entry;
29
 
        }
30
 
 
31
 
        if ( is_array($fwpacketloss_sd) )
32
 
        foreach ( $fwpacketloss_sd as $key=>$entry ) {
33
 
            $fwpacketloss[$key]=0;
34
 
            $nr=$rtlnum[$key];
35
 
            if ( $nr > 0 )
36
 
                $fwpacketloss[$key]=$fwpacketloss_sd[$key]/($fwpacketloss_sd[$key] + $rtlnum[$key])*100; 
37
 
 
38
 
            $GLOBALS["cisco_saagent_fwpacketloss"][$options["host_id"]][$key]=$fwpacketloss[$key]; 
39
 
        }
40
 
    }
41
 
 
42
 
    $value=0;
43
 
    if ( isset($GLOBALS["cisco_saagent_fwpacketloss"][$options["host_id"]][$options["index"]]) )
44
 
        $value=$GLOBALS["cisco_saagent_fwpacketloss"][$options["host_id"]][$options["index"]];
45
 
 
46
 
    return $value;
 
17
    if ( ($fwpacketloss = snmp_get($ip, $comm, "$sa_oid.26.$inst")) === FALSE)
 
18
        return FALSE;
 
19
    if ( ($nr = snmp_get($ip, $comm, "$sa_oid.1.$inst")) === FALSE)
 
20
        return FALSE;
 
21
 
 
22
    $pktloss=0;
 
23
    if ($nr > 0)
 
24
        $pktloss = $fwpacketloss/($fwpacketloss+$nr)*100;
 
25
    return $pktloss;
47
26
}
48
27
?>