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

« back to all changes in this revision

Viewing changes to engine/pollers/cisco_saagent_forwardjitter.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:
3
3
 * Copyright (C) <2002-2005> Javier Szyszlican <javier@szysz.com>
4
4
 * This program is licensed under the GNU GPL, full terms in the LICENSE file
5
5
 */
6
 
function poller_cisco_saagent_forwardjitter($options) {
7
 
 
8
 
    if ( !is_array($GLOBALS["cisco_saagent_forwardjitter"][$options["host_id"]])) {
9
 
        $i=0;
10
 
        while ( !is_array($sumpossd) and $i++ <= 2 ) {
11
 
            $sumpossd=snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.9",1);
12
 
            $sumnegsd=snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.14",1);
13
 
            $nrpossd =snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.8",1);
14
 
            $nrnegsd =snmp_walk($options["host_ip"],$options["ro_community"],".1.3.6.1.4.1.9.9.42.1.5.2.1.13",1);
15
 
        }
16
 
 
17
 
        if ( is_array($sumpossd) )
18
 
        foreach ( $sumpossd as $key=>$entry ) { 
19
 
            $key=explode(".",$key);
20
 
            $key=$key[count($key)-1];
21
 
            
22
 
            $sum_pos_sd[$key]=$entry;
23
 
        }
24
 
 
25
 
        if ( is_array($sumnegsd) )
26
 
        foreach ( $sumnegsd as $key=>$entry ) {
27
 
            $key=explode(".",$key);
28
 
            $key=$key[count($key)-1];
29
 
 
30
 
            $sum_neg_sd[$key]=$entry;
31
 
        }
32
 
 
33
 
        if ( is_array($nrpossd) )
34
 
        foreach ( $nrpossd as $key=>$entry ) { 
35
 
            $key=explode(".",$key);
36
 
            $key=$key[count($key)-1];
37
 
 
38
 
            $nr_pos_sd[$key]=$entry;
39
 
        }
40
 
 
41
 
        if ( is_array($nrnegsd) ) 
42
 
        foreach ( $nrnegsd as $key=>$entry ) {
43
 
            $key=explode(".",$key);
44
 
            $key=$key[count($key)-1];
45
 
 
46
 
            $nr_neg_sd[$key]=$entry;
47
 
        }
48
 
 
49
 
        if ( is_array($sum_pos_sd) )
50
 
        foreach ( $sum_pos_sd as $key=>$entry ) {
51
 
            $sum=$sum_pos_sd[$key]+$sum_neg_sd[$key];
52
 
            $nr=$nr_pos_sd[$key]+$nr_neg_sd[$key];
53
 
        
54
 
            $forward_jitter[$key]=0;
55
 
            if ( $nr > 0 )
56
 
                $forward_jitter[$key]=($sum/$nr);
57
 
            
58
 
            $GLOBALS["cisco_saagent_forwardjitter"][$options["host_id"]][$key]=$forward_jitter[$key]; 
59
 
        }
60
 
    }
61
 
 
62
 
    $value=0;
63
 
    if ( isset($GLOBALS["cisco_saagent_forwardjitter"][$options["host_id"]][$options["index"]]) )
64
 
        $value=$GLOBALS["cisco_saagent_forwardjitter"][$options["host_id"]][$options["index"]];
65
 
 
66
 
    return round($value,2);
 
6
function poller_cisco_saagent_forwardjitter($options)
 
7
{
 
8
    if (empty($options['ro_community']) or !is_numeric($options['index']))
 
9
        return FALSE;
 
10
    $sa_oid = '1.3.6.1.4.1.9.9.42.1.5.2.1';
 
11
    $ip = $options['host_ip'];
 
12
    $comm = $options['ro_community'];
 
13
    $inst = $options['index'];
 
14
 
 
15
    if ( ($sumpossd = snmp_get($ip, $comm, "$sa_oid.9.$inst")) === FALSE)
 
16
        return FALSE;
 
17
    if ( ($sumnegsd = snmp_get($ip, $comm, "$sa_oid.14.$inst")) === FALSE)
 
18
        return FALSE;
 
19
    if ( ($nrpossd = snmp_get($ip, $comm, "$sa_oid.8.$inst")) === FALSE)
 
20
        return FALSE;
 
21
    if ( ($nrnegsd = snmp_get($ip, $comm, "$sa_oid.13.$inst")) === FALSE)
 
22
        return FALSE;
 
23
 
 
24
    $sum = $sumpossd + $sumnegsd;
 
25
    $nr = $nrpostsd + $nrnegsd;
 
26
 
 
27
    $jitter=0;
 
28
    if ($nr > 0)
 
29
        $jitter = round($sum / $nr,2);
 
30
    return $jitter;
67
31
}
68
32
?>