Issues (2963)

includes/polling/os/riverbed.inc.php (1 issue)

Labels
Severity
1
<?php
2
/*
3
 * LibreNMS
4
 *
5
 * Copyright (c) 2015 Søren Friis Rosiak <[email protected]>
6
 * Copyright (c) 2017 Cercel Valentin <[email protected]>
7
 * This program is free software: you can redistribute it and/or modify it
8
 * under the terms of the GNU General Public License as published by the
9
 * Free Software Foundation, either version 3 of the License, or (at your
10
 * option) any later version.  Please see LICENSE.txt at the top level of
11
 * the source code distribution for details.
12
 */
13
14
use LibreNMS\RRD\RrdDefinition;
15
16
$hardware = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.1.0', '-OQv'), '"');
0 ignored issues
show
It seems like snmp_get($device, '.1.3....163.1.1.1.1.0', '-OQv') can also be of type false; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
$hardware = trim(/** @scrutinizer ignore-type */ snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.1.0', '-OQv'), '"');
Loading history...
17
$serial = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.2.0', '-OQv'), '"');
18
$version = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.3.0', '-OQv'), '"');
19
20
/* optimisation oids
21
 *
22
 * half-open   .1.3.6.1.4.1.17163.1.1.5.2.3.0
23
 * half-closed .1.3.6.1.4.1.17163.1.1.5.2.4.0
24
 * establised  .1.3.6.1.4.1.17163.1.1.5.2.5.0
25
 * active      .1.3.6.1.4.1.17163.1.1.5.2.6.0
26
 * total       .1.3.6.1.4.1.17163.1.1.5.2.7.0
27
 *
28
 */
29
30
$conn_array = [
31
    '.1.3.6.1.4.1.17163.1.1.5.2.3.0',
32
    '.1.3.6.1.4.1.17163.1.1.5.2.4.0',
33
    '.1.3.6.1.4.1.17163.1.1.5.2.5.0',
34
    '.1.3.6.1.4.1.17163.1.1.5.2.6.0',
35
    '.1.3.6.1.4.1.17163.1.1.5.2.7.0',
36
];
37
$connections = snmp_get_multi_oid($device, $conn_array);
38
39
$conn_half_open = $connections['.1.3.6.1.4.1.17163.1.1.5.2.3.0'];
40
$conn_half_closed = $connections['.1.3.6.1.4.1.17163.1.1.5.2.4.0'];
41
$conn_established = $connections['.1.3.6.1.4.1.17163.1.1.5.2.5.0'];
42
$conn_active = $connections['.1.3.6.1.4.1.17163.1.1.5.2.6.0'];
43
$conn_total = $connections['.1.3.6.1.4.1.17163.1.1.5.2.7.0'];
44
45
if ($conn_half_open >= 0 && $conn_half_closed >= 0 && $conn_established >= 0 && $conn_active >= 0 && $conn_total >= 0) {
46
    $rrd_def = RrdDefinition::make()
47
        ->addDataset('half_open', 'GAUGE', 0)
48
        ->addDataset('half_closed', 'GAUGE', 0)
49
        ->addDataset('established', 'GAUGE', 0)
50
        ->addDataset('active', 'GAUGE', 0)
51
        ->addDataset('total', 'GAUGE', 0);
52
53
    $fields = [
54
        'half_open'   => $conn_half_open,
55
        'half_closed' => $conn_half_closed,
56
        'established' => $conn_established,
57
        'active'      => $conn_active,
58
        'total'       => $conn_total,
59
    ];
60
61
    $tags = compact('rrd_def');
62
63
    data_update($device, 'riverbed_connections', $tags, $fields);
64
    $os->enableGraph('riverbed_connections');
65
}
66
67
/* datastore oids
68
 *
69
 * hits .1.3.6.1.4.1.17163.1.1.5.4.1.0
70
 * miss .1.3.6.1.4.1.17163.1.1.5.4.2.0
71
 *
72
 */
73
$datastore_array = [
74
    '.1.3.6.1.4.1.17163.1.1.5.4.1.0',
75
    '.1.3.6.1.4.1.17163.1.1.5.4.2.0',
76
];
77
$datastore = snmp_get_multi_oid($device, $datastore_array);
78
79
$datastore_hits = $datastore['.1.3.6.1.4.1.17163.1.1.5.4.1.0'];
80
$datastore_miss = $datastore['.1.3.6.1.4.1.17163.1.1.5.4.2.0'];
81
82
if ($datastore_hits >= 0 && $datastore_miss >= 0) {
83
    $rrd_def = RrdDefinition::make()
84
        ->addDataset('datastore_hits', 'GAUGE', 0)
85
        ->addDataset('datastore_miss', 'GAUGE', 0);
86
87
    $fields = [
88
        'datastore_hits' => $datastore_hits,
89
        'datastore_miss' => $datastore_miss,
90
    ];
91
92
    $tags = compact('rrd_def');
93
94
    data_update($device, 'riverbed_datastore', $tags, $fields);
95
    $os->enableGraph('riverbed_datastore');
96
}
97
98
/* optimization oids
99
 *
100
 * optimized   .1.3.6.1.4.1.17163.1.1.5.2.1.0
101
 * passthrough .1.3.6.1.4.1.17163.1.1.5.2.2.0
102
 *
103
 */
104
$optimization_array = [
105
    '.1.3.6.1.4.1.17163.1.1.5.2.1.0',
106
    '.1.3.6.1.4.1.17163.1.1.5.2.2.0',
107
];
108
109
$optimizations = snmp_get_multi_oid($device, $optimization_array);
110
111
$conn_optimized = $optimizations['.1.3.6.1.4.1.17163.1.1.5.2.1.0'];
112
$conn_passthrough = $optimizations['.1.3.6.1.4.1.17163.1.1.5.2.2.0'];
113
114
if ($conn_optimized >= 0 && $conn_passthrough >= 0) {
115
    $rrd_def = RrdDefinition::make()
116
        ->addDataset('conn_optimized', 'GAUGE', 0)
117
        ->addDataset('conn_passthrough', 'GAUGE', 0);
118
119
    $fields = [
120
        'conn_optimized' => $conn_optimized,
121
        'conn_passthrough' => $conn_passthrough,
122
    ];
123
124
    $tags = compact('rrd_def');
125
126
    data_update($device, 'riverbed_optimization', $tags, $fields);
127
    $os->enableGraph('riverbed_optimization');
128
}
129
130
/* bandwidth passthrough
131
 *
132
 * in .1.3.6.1.4.1.17163.1.1.5.3.3.1.0
133
 * out .1.3.6.1.4.1.17163.1.1.5.3.3.2.0
134
 * total .1.3.6.1.4.1.17163.1.1.5.3.3.3.0
135
 *
136
 */
137
138
$bandwidth_array = [
139
    '.1.3.6.1.4.1.17163.1.1.5.3.3.1.0',
140
    '.1.3.6.1.4.1.17163.1.1.5.3.3.2.0',
141
    '.1.3.6.1.4.1.17163.1.1.5.3.3.3.0',
142
];
143
144
$bandwidth = snmp_get_multi_oid($device, $bandwidth_array);
145
146
$bw_in = $bandwidth['.1.3.6.1.4.1.17163.1.1.5.3.3.1.0'];
147
$bw_out = $bandwidth['.1.3.6.1.4.1.17163.1.1.5.3.3.2.0'];
148
$bw_total = $bandwidth['.1.3.6.1.4.1.17163.1.1.5.3.3.3.0'];
149
150
if ($bw_in >= 0 && $bw_out >= 0 && $bw_total >= 0) {
151
    $rrd_def = RrdDefinition::make()
152
        ->addDataset('bw_in', 'COUNTER', 0)
153
        ->addDataset('bw_out', 'COUNTER', 0)
154
        ->addDataset('bw_total', 'COUNTER', 0);
155
156
    $fields = [
157
        'bw_in' => $bw_in,
158
        'bw_out' => $bw_out,
159
        'bw_total' => $bw_total,
160
    ];
161
162
    $tags = compact('rrd_def');
163
164
    data_update($device, 'riverbed_passthrough', $tags, $fields);
165
    $os->enableGraph('riverbed_passthrough');
166
}
167