Skip to content

Commit

Permalink
refactor: small fixes for cisco-voice code (#4719)
Browse files Browse the repository at this point in the history
  • Loading branch information
laf committed Oct 13, 2016
1 parent 5669dce commit 1868945
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 48 deletions.
2 changes: 1 addition & 1 deletion includes/polling/cisco-voice.inc.php
Expand Up @@ -34,5 +34,5 @@
* Cisco XCode
* This module graphs the used and total Transcoder resources on a Cisco Voice Gateway
*/
include "cisco-voice/cisco-xcode.inc.php";
include "cisco-voice/cisco-iosxcode.inc.php";
}
47 changes: 25 additions & 22 deletions includes/polling/cisco-voice/cisco-iosdsp.inc.php
Expand Up @@ -14,32 +14,35 @@
if ($device['os_group'] == "cisco") {
// Total
$total = 0;
foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.2.1.1.6", null) as $key => $value) {
$total += $value[''];
}

if (isset($total) && ($total != "") && ($total != 0)) {
// Active
$active = 0;
foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.2.1.1.7", null) as $key => $value) {
$active += $value[''];
$output = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.2.1.1.6", null);
if (is_array($output)) {
foreach ($output as $key => $value) {
$total += $value[''];
}

$rrd_def = array(
'DS:total:GAUGE:600:0:U',
'DS:active:GAUGE:600:0:U'
);
if (isset($total) && $total > 0) {
// Active
$active = 0;
foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.2.1.1.7", null) as $key => $value) {
$active += $value[''];
}

$fields = array(
'total' => $total,
'active' => $active,
);
$rrd_def = array(
'DS:total:GAUGE:600:0:U',
'DS:active:GAUGE:600:0:U'
);

$tags = compact('rrd_def');
data_update($device, 'cisco-iosdsp', $tags, $fields);
$fields = array(
'total' => $total,
'active' => $active,
);

$graphs['cisco-iosdsp'] = true;
echo (" Cisco IOS DSP ");
$tags = compact('rrd_def');
data_update($device, 'cisco-iosdsp', $tags, $fields);

$graphs['cisco-iosdsp'] = true;
echo(" Cisco IOS DSP ");
}
unset($rrd_def, $total, $active, $tags, $fields);
}
unset($rrd_def, $total, $active, $tags, $fields);
}
2 changes: 1 addition & 1 deletion includes/polling/cisco-voice/cisco-iosmtp.inc.php
Expand Up @@ -16,7 +16,7 @@
$total = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.6.4.1.3", null);
$total = $total['1.3.6.1.4.1.9.9.86.1.6.4.1.3'][''];

if (isset($total) && ($total != "") && ($total != 0)) {
if (isset($total) && $total > 0) {
// Available
$available = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.6.4.1.4", null);
$available = $available['1.3.6.1.4.1.9.9.86.1.6.4.1.4'][''];
Expand Down
47 changes: 25 additions & 22 deletions includes/polling/cisco-voice/cisco-iospri.inc.php
Expand Up @@ -16,33 +16,36 @@

// Total
$total = 0;
foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.2.1.2.2.1.3", null) as $key => $value) {
// 81 is the ifType for DS0's
if ($value[''] == "81") {
$total++;
$output = snmpwalk_cache_oid_num($device, "1.3.6.1.2.1.2.2.1.3", null);
if (is_array($output)) {
foreach ($output as $key => $value) {
// 81 is the ifType for DS0's
if ($value[''] == "81") {
$total++;
}
}
}

// Active
$active = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.10.19.1.1.4.0", null);
$active = $active['1.3.6.1.4.1.9.10.19.1.1.4.0'][''];
// Active
$active = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.10.19.1.1.4.0", null);
$active = $active['1.3.6.1.4.1.9.10.19.1.1.4.0'];

if (isset($active) && ($active != "") && ($total != 0)) {
$rrd_def = array(
'DS:total:GAUGE:600:0:U',
'DS:active:GAUGE:600:0:U'
);
if (isset($active) && $active > 0) {
$rrd_def = array(
'DS:total:GAUGE:600:0:U',
'DS:active:GAUGE:600:0:U'
);

$fields = array(
'total' => $total,
'active' => $active,
);
$fields = array(
'total' => $total,
'active' => $active,
);

$tags = compact('rrd_def');
data_update($device, 'cisco-iospri', $tags, $fields);
$tags = compact('rrd_def');
data_update($device, 'cisco-iospri', $tags, $fields);

$graphs['cisco-iospri'] = true;
echo (" Cisco IOS PRI ");
$graphs['cisco-iospri'] = true;
echo(" Cisco IOS PRI ");
}
unset($rrd_def, $total, $active, $fields, $tags);
}
unset($rrd_def, $total, $active, $fields, $tags);
}
4 changes: 2 additions & 2 deletions includes/polling/cisco-voice/cisco-iosxcode.inc.php
Expand Up @@ -16,7 +16,7 @@
$total = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.7.1.0", null);
$total = $total['1.3.6.1.4.1.9.9.86.1.7.1.0'][''];

if (isset($total) && ($total != "") && ($total != 0)) {
if (isset($total) && $total > 0) {
// Available
$available = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.9.86.1.7.2.0", null);
$available = $available['1.3.6.1.4.1.9.9.86.1.7.2.0'][''];
Expand All @@ -35,7 +35,7 @@
);

$tags = compact('rrd_def');
dat_update($device, 'cisco-iosxcode', $tags, $fields);
data_update($device, 'cisco-iosxcode', $tags, $fields);

$graphs['cisco-iosxcode'] = true;
echo (" Cisco IOS Transcoder ");
Expand Down

0 comments on commit 1868945

Please sign in to comment.