Skip to content

Commit

Permalink
added DisableBulk option to devices with problems in bulk queries lik…
Browse files Browse the repository at this point in the history
…e some IBM devices
  • Loading branch information
toni-moreno committed Dec 6, 2016
1 parent 8c1eec4 commit cb1d50a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
28 changes: 17 additions & 11 deletions pkg/influxmeasurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type InfluxMeasurement struct {
Filter *MeasFilterCfg
log *logrus.Logger
snmpClient *gosnmp.GoSNMP
DisableBulk bool
}

//NewInfluxMeasurement creates object with config , log + goSnmp client
Expand Down Expand Up @@ -132,11 +133,16 @@ func (m *InfluxMeasurement) Init() error {
/********************************
* Initialize Metric Runtime data in one array m-values
* ******************************/
m.log.Debug("Initialize OID measurement per label => map of metric object per field | OID array [ready to send to the snmpBulk device] | OID=>Metric MAP")
m.log.Debug("Initialize OID measurement per label => map of metric object per field | OID array [ready to send to the walk device] | OID=>Metric MAP")
m.InitMetricTable()
return nil
}

func (m *InfluxMeasurement) SetDisableBulk(disable bool) {
m.DisableBulk = disable
m.log.Debugf("Disable Snmp Bulk Queries to measurment %s: %t", m.cfg.ID, disable)
}

func (m *InfluxMeasurement) PushMetricTable(p map[string]string) error {
if m.cfg.GetMode == "value" {
return fmt.Errorf("Can not push new values in a measurement type value : %s", m.cfg.ID)
Expand Down Expand Up @@ -523,19 +529,19 @@ func (m *InfluxMeasurement) SnmpWalkData() (int64, int64, error) {
}
return nil
}
switch m.snmpClient.Version {
case gosnmp.Version1:
switch {
case m.snmpClient.Version == gosnmp.Version1 || m.DisableBulk:
for _, v := range m.cfg.fieldMetric {
if err := m.snmpClient.Walk(v.BaseOID, setRawData); err != nil {
m.log.Errorf("SNMP (%s) for OID (%s) get error: %s\n", m.snmpClient.Target, v.BaseOID, err)
m.log.Errorf("SNMP WALK (%s) for OID (%s) get error: %s\n", m.snmpClient.Target, v.BaseOID, err)
errs++
}
sent++
}
default:
for _, v := range m.cfg.fieldMetric {
if err := m.snmpClient.BulkWalk(v.BaseOID, setRawData); err != nil {
m.log.Errorf("SNMP (%s) for OID (%s) get error: %s\n", m.snmpClient.Target, v.BaseOID, err)
m.log.Errorf("SNMP BULK WALK (%s) for OID (%s) get error: %s\n", m.snmpClient.Target, v.BaseOID, err)
errs++
}
sent++
Expand Down Expand Up @@ -628,17 +634,17 @@ func (m *InfluxMeasurement) loadIndexedLabels() (map[string]string, error) {
allindex[suffix] = name
return nil
}
switch m.snmpClient.Version {
case gosnmp.Version1:
switch {
case m.snmpClient.Version == gosnmp.Version1 || m.DisableBulk:
err := m.snmpClient.Walk(m.cfg.IndexOID, setRawData)
if err != nil {
m.log.Errorf("SNMP version 1 walk error: %s", err)
m.log.Errorf("SNMP WALK version 1 walk error: %s", err)
return allindex, err
}
default:
err := m.snmpClient.BulkWalk(m.cfg.IndexOID, setRawData)
if err != nil {
m.log.Errorf("SNMP bulkwalk error: %s", err)
m.log.Errorf("SNMP DISABLE WALK bulkwalk error: %s", err)
return allindex, err
}
}
Expand Down Expand Up @@ -753,8 +759,8 @@ func (m *InfluxMeasurement) applyOIDCondFilter(oidCond string, typeCond string,

return nil
}
switch m.snmpClient.Version {
case gosnmp.Version1:
switch {
case m.snmpClient.Version == gosnmp.Version1 || m.DisableBulk:
err := m.snmpClient.Walk(oidCond, setRawData)
if err != nil {
m.log.Errorf("SNMP version-1 walk error : %s", err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type SnmpDeviceCfg struct {
V3AuthProt string `xorm:"v3authprot"`
V3PrivPass string `xorm:"v3privpass"`
V3PrivProt string `xorm:"v3privprot"`
//snmp workarround for some devices
DisableBulk bool `xorm:"'disablebulk' default 0"`
//snmp runtime config
Freq int `xorm:"'freq' default 60"`
UpdateFltFreq int `xorm:"'update_flt_freq' default 60"`
Expand Down
1 change: 1 addition & 0 deletions pkg/snmpdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (d *SnmpDevice) InitDevMeasurements() {
d.log.Errorf("Error on measurement initialization on host %s: Error: %s", d.cfg.ID, err)
continue
}
imeas.SetDisableBulk(d.cfg.DisableBulk)
d.Measurements = append(d.Measurements, imeas)
}
}
Expand Down
4 changes: 3 additions & 1 deletion public/snmpdevice/snmpdevicecfg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ export class SnmpDeviceCfgComponent {
{title: 'Port', name: 'Port'},
{title: 'Active', name: 'Active'},
{title: 'Snmp Version', name: 'SnmpVersion'},
{title: 'Snmp Debug', name: 'SnmpDebug'},
{title: 'Polling Period (sec)', name: 'Freq'},
{title: 'Update Filter (Cicles)', name: 'UpdateFltFreq'},
{title: 'Influx DB', name: 'OutDB'},
{title: 'Log Level', name: 'LogLevel'},
{title: 'Snmp Debug', name: 'SnmpDebug'},
{title: 'Disable Snmp Bulk Queries', name: 'DisableBulk'},
{title: 'Tag Name', name: 'DeviceTagName'},
{title: 'Tag Value', name: 'DeviceTagValue'},
{title: 'Extra Tags', name: 'ExtraTags'},
Expand Down Expand Up @@ -82,6 +83,7 @@ export class SnmpDeviceCfgComponent {
Timeout: [20],
Active: ['true',Validators.required],
SnmpVersion:['2c',Validators.required],
DisableBulk:['false'],
Community: ['public'],
V3SecLevel:[''],
V3AuthUser:[''],
Expand Down
9 changes: 6 additions & 3 deletions public/snmpdevice/snmpdevicecfg.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class SnmpDeviceService {
}

if ( key == 'Active' ||
key == 'SnmpDebug' ) return ( value === "true" || value === true);
key == 'SnmpDebug' ||
key == 'DisableBulk' ) return ( value === "true" || value === true);
if ( key == 'Extratags' ) return String(value).split(',');
if ( key == 'MeasFilters' ||
key == 'MetricGroups') {
Expand All @@ -47,7 +48,8 @@ export class SnmpDeviceService {
return parseInt(value);
}
if ( key == 'Active' ||
key == 'SnmpDebug' ) return ( value === "true" || value === true);
key == 'SnmpDebug' ||
key == 'DisableBulk' ) return ( value === "true" || value === true);
if ( key == 'Extratags' ) return String(value).split(',');
if ( key == 'MeasFilters' ||
key == 'MetricGroups') {
Expand Down Expand Up @@ -132,7 +134,8 @@ export class SnmpDeviceService {
return parseInt(value);
}
if ( key == 'Active' ||
key == 'SnmpDebug' ) return ( value === "true" || value === true);
key == 'SnmpDebug' ||
key == 'DisableBulk' ) return ( value === "true" || value === true);
if ( key == 'Extratags' ) return String(value).split(',');
if ( key == 'MeasFilters' ||
key == 'MetricGroups') {
Expand Down
27 changes: 27 additions & 0 deletions public/snmpdevice/snmpdeviceeditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ <h4 class="info-mode">{{ editmode | uppercase}} </h4>
</div>
</div>

<div class="form-group">
<label class="control-label col-sm-2" for="DisableBulk">DisableBulk</label>
<i tooltipPlacement="top" style="float: left" class="info control-label glyphicon glyphicon-info-sign" tooltipAnimation="true"
tooltip="Active on Collector reboot"></i>
<div class="col-sm-9">
<select formControlName="DisableBulk" id="DisableBulk">
<option value="true">True</option>
<option value="false">False</option>
</select>
<control-messages [control]="snmpdevForm.controls.DisableBulk"></control-messages>
</div>
</div>

<div class="form-group" *ngIf="snmpdevForm.value.SnmpVersion == '2c'" >
<label class="control-label col-sm-2" for="Community">Community</label>
<i tooltipPlacement="top" style="float: left" class="info control-label glyphicon glyphicon-info-sign" tooltipAnimation="true"
Expand Down Expand Up @@ -448,6 +461,20 @@ <h4 class="info-mode">{{ editmode | uppercase}} </h4>
</div>
</div>

<div class="form-group">
<label class="control-label col-sm-2" for="DisableBulk">DisableBulk</label>
<i tooltipPlacement="top" style="float: left" class="info control-label glyphicon glyphicon-info-sign" tooltipAnimation="true"
tooltip="Disable Snmp Bulk request on devices with problems"></i>
<div class="col-sm-9">
<select formControlName="DisableBulk" id="DisableBulk" [ngModel] = "testsnmpdev.DisableBulk">
<option value="true">True</option>
<option value="false">False</option>
</select>
<control-messages [control]="snmpdevForm.controls.DisableBulk"></control-messages>
</div>
</div>


<div class="form-group" *ngIf="snmpdevForm.value.SnmpVersion == '2c'" >

<label class="control-label col-sm-2" for="Community">Community</label>
Expand Down

0 comments on commit cb1d50a

Please sign in to comment.