def setup_oids(self): self.csmTable = testagent.Table( oidstr="INRADIOS::csmMonitoringTable", indexes=[testagent.Integer32()], columns=[(1, testagent.DisplayString("")), (2, testagent.DisplayString("")), (3, testagent.DisplayString("")), (4, testagent.DisplayString("")), (5, testagent.Integer32(0)), (6, testagent.DisplayString("")), (7, testagent.DisplayString("")), (8, testagent.DisplayString("")), (9, testagent.DisplayString("")), (10, testagent.DisplayString("")), (11, testagent.DisplayString(""))], )
def test_oids_minimal(): simulation.add_row(3, { 5: testagent.Integer32(2), 7: testagent.DisplayString("NaN"), 8: testagent.DisplayString("NaN"), 9: testagent.DisplayString("1.9"), 10: testagent.DisplayString("1.5"), }) expected = ("OK - Measurement ID 3 = n/a (last update: n/a)\n") p = subprocess.Popen("health_monitoring_plugins/check_snmp_inradios_csm/check_snmp_inradios_csm.py -H localhost:1234 -V 2 -C public -i 3", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=context.testenv) plugin_out = p.stdout.read() assert(plugin_out == expected)
def test_simple_ok(): simulation.add_row( 1, { 1: testagent.DisplayString( "Monitors the SNR by Spectrum Data of the Carrier"), 2: testagent.DisplayString("2.1"), 3: testagent.DisplayString("18.05.2018 08:47:29"), 4: testagent.DisplayString( "Center-Frequency: 1.501 GHz; Bandwidth: 2.048 MHz; Attenuation: 3 dB;" ), 5: testagent.Integer32(2), 6: testagent.DisplayString("dB"), 7: testagent.DisplayString("NaN"), 8: testagent.DisplayString("NaN"), 9: testagent.DisplayString("1.9"), 10: testagent.DisplayString("1.5"), 11: testagent.DisplayString("Test2") }) expected = ( "OK - Test2 = 2.1 dB (last update: 08:47:29) | 'Test2'=2.1dB;~:1.9;~:1.5;;\n" "Center-Frequency: 1.501 GHz\n" "Bandwidth: 2.048 MHz\n" "Attenuation: 3 dB\n" "Last update: 18.05.2018 08:47:29\n") p = subprocess.Popen( "health_monitoring_plugins/check_snmp_inradios_csm/check_snmp_inradios_csm.py -H localhost:1234 -V 2 -C public -i 1", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=context.testenv) plugin_out = p.stdout.read() assert (plugin_out == expected)
def add_row(self, row_idx, columns): csmTableRow1 = self.csmTable.addRow([testagent.Integer32(row_idx)]) for colid in columns: csmTableRow1.setRowCell(colid, columns[colid]),
def setup_oids(): singleIdxTable = testagent.Table( oidstr = "TEST-MIB::singleIdxTable", indexes = [ testagent.DisplayString() ], columns = [ (2, testagent.DisplayString("")), (3, testagent.Integer32(0)) ], ) singleIdxTableRow1 = singleIdxTable.addRow([testagent.DisplayString("ThisIsRow1")]) singleIdxTableRow1.setRowCell(2, testagent.DisplayString("ContentOfRow1_Column1 " + ascii_test_string)) singleIdxTableRow1.setRowCell(3, testagent.Integer32(1)) singleIdxTableRow2 = singleIdxTable.addRow([testagent.DisplayString("ThisIsRow2")]) singleIdxTableRow2.setRowCell(2, testagent.DisplayString("ContentOfRow2_Column1 " + ascii_test_string)) singleIdxTableRow2.setRowCell(3, testagent.Integer32(2)) singleIdxTableRow3 = singleIdxTable.addRow([testagent.DisplayString("ThisIsRow3")]) singleIdxTableRow3.setRowCell(2, testagent.DisplayString("ContentOfRow3_Column1 " + ascii_test_string)) singleIdxTableRow3.setRowCell(3, testagent.Integer32(3)) singleIdxTableRow4 = singleIdxTable.addRow([testagent.DisplayString(ascii_test_string)]) singleIdxTableRow4.setRowCell(2, testagent.DisplayString("ContentOfRow4_Column1 " + ascii_test_string)) singleIdxTableRow4.setRowCell(3, testagent.Integer32(3)) multiIdxTable = testagent.Table( oidstr = "TEST-MIB::multiIdxTable", indexes = [ testagent.DisplayString(), testagent.Integer32(), ], columns = [ (3, testagent.DisplayString("")), (4, testagent.Integer32(0)) ], ) multiIdxTableRow1 = multiIdxTable.addRow([testagent.DisplayString("ThisIsRow1"), testagent.Integer32(1)]) multiIdxTableRow1.setRowCell(3, testagent.DisplayString("ContentOfRow1.1_Column1")) multiIdxTableRow1.setRowCell(4, testagent.Integer32(1)) multiIdxTableRow2 = multiIdxTable.addRow([testagent.DisplayString("ThisIsRow1"), testagent.Integer32(2)]) multiIdxTableRow2.setRowCell(3, testagent.DisplayString("ContentOfRow1.2_Column1")) multiIdxTableRow2.setRowCell(4, testagent.Integer32(2)) multiIdxTableRow3 = multiIdxTable.addRow([testagent.DisplayString("ThisIsRow2"), testagent.Integer32(1)]) multiIdxTableRow3.setRowCell(3, testagent.DisplayString("ContentOfRow2.1_Column1")) multiIdxTableRow3.setRowCell(4, testagent.Integer32(3)) multiIdxTableRow3 = multiIdxTable.addRow([testagent.DisplayString("ThisIsRow2"), testagent.Integer32(2)]) multiIdxTableRow3.setRowCell(3, testagent.DisplayString("ContentOfRow2.2_Column1")) multiIdxTableRow3.setRowCell(4, testagent.Integer32(4)) ipaddrIdxTable = testagent.Table( oidstr = "TEST-MIB::ipaddrIdxTable", indexes = [ testagent.IpAddress() ], columns = [ (2, testagent.DisplayString("Default")), (3, testagent.IpAddress("0.0.0.0")) ], ) ipaddrIdxTableRow1 = ipaddrIdxTable.addRow([testagent.IpAddress("192.168.0.1")]) ipaddrIdxTableRow1.setRowCell(2, testagent.DisplayString("ContentOfRow1_Column1")) ipaddrIdxTableRow1.setRowCell(3, testagent.IpAddress("192.168.0.1")) ipaddrIdxTableRow2 = ipaddrIdxTable.addRow([testagent.IpAddress("192.168.0.2")]) ipaddrIdxTableRow2.setRowCell(2, testagent.DisplayString("ContentOfRow2_Column1")) ipaddrIdxTableRow2.setRowCell(3, testagent.IpAddress("192.168.0.2")) ipaddrIdxTableRow3 = ipaddrIdxTable.addRow([testagent.IpAddress("192.168.0.3")]) ipaddrIdxTableRow3.setRowCell(2, testagent.DisplayString("ContentOfRow3_Column1")) ipaddrIdxTableRow3.setRowCell(3, testagent.IpAddress("192.168.0.3"))