コード例 #1
0
 def test_defaults(self):
     ''' Should have sane defaults if config file is not present '''
     config = zabbix_smartmontools.parseConfig("/does_not_exist!!!")
     self.assertEqual(config['mode'], 'device')
     self.assertTrue(config['skipDuplicates'])
     self.assertEqual(config['ctlPath'], 'smartctl')
     self.assertFalse('Disks' in config)
コード例 #2
0
 def runtest(self, filename, expected, patchCheckOutput):
     f = open("test/example/%s" % filename)
     output = f.read()
     f.close()
     patchCheckOutput.side_effect = mock_smartctl(
         {'-a /dev/da0 -d auto': output})
     config = zabbix_smartmontools.parseConfig("test/example/empty")
     r = zabbix_smartmontools.getSmart(config, "myhost", "getverb",
                                       "/dev/da0 -d scsi ")
     self.assertEqual(r, expected)
コード例 #3
0
 def test_no_disk_list(self):
     config = zabbix_smartmontools.parseConfig(
         'test/example/no_disk_list.conf')
     self.assertEqual(config['mode'], 'device')
     self.assertTrue(config['skipDuplicates'])
     self.assertEqual(config['ctlPath'], 'smartctl')
     self.assertEqual(config['senderPyPath'],
                      '/etc/zabbix/scripts/sender_wrapper.py')
     self.assertEqual(config['agentConf'], '/etc/zabbix/zabbix_agentd.conf')
     self.assertEqual(config['senderPath'], 'zabbix_sender')
     self.assertFalse('Disks' in config)
コード例 #4
0
 def test_duplicates(self, patchCheckOutput):
     f = open("test/example/%s" % "ST4000NM0023.txt")
     da0_output = f.read()
     da1_output = da0_output
     f.close()
     patchCheckOutput.side_effect = mock_smartctl({
         '-a /dev/da0 -d auto':
         da0_output,
         '-a /dev/da1 -d auto':
         da1_output,
     })
     config = zabbix_smartmontools.parseConfig("test/example/empty")
     config['skipDuplicates'] = True
     r = zabbix_smartmontools.getAllDisks(config, "myhost", "getverb", [
         "/dev/da0 -d scsi",
         "/dev/da1 -d scsi",
     ])
     self.assertEqual(r, ([{
         '{#DDRIVESTATUS}': 'da0'
     }, {
         '{#DISKID}': 'da0'
     }, {
         '{#DISKIDSAS}': 'da0'
     }, {
         '{#DDRIVESTATUS}': 'da1'
     }], [
         'myhost smartctl.info[da0,serial] "Z1Z3SGMD00009437061J"',
         'myhost smartctl.info[da0,DriveStatus] "PROCESSED"',
         'myhost smartctl.info[da0,device] "da0"',
         'myhost smartctl.info[da0,model] "ST4000NM0023"',
         'myhost smartctl.info[da0,capacity] "4000787030016"',
         'myhost smartctl.info[da0,selftest] "OK"',
         'myhost smartctl.info[da0,rpm] "7200"',
         'myhost smartctl.info[da0,formFactor] "3.5 inches"',
         'myhost smartctl.info[da0,vendor] "SEAGATE"',
         'myhost smartctl.info[da0,SmartStatus] "PRESENT_SAS"',
         'myhost smartctl.info[da0,revision] "0004"',
         'myhost smartctl.info[da0,compliance] "SPC-4"',
         'myhost smartctl.info[da0,manufacturedYear] "2014"',
         'myhost smartctl.value[da0,loadUnload] "2108"',
         'myhost smartctl.value[da0,loadUnloadMax] "300000"',
         'myhost smartctl.value[da0,startStop] "119"',
         'myhost smartctl.value[da0,startStopMax] "10000"',
         'myhost smartctl.value[da0,defects] "15"',
         'myhost smartctl.value[da0,nonMediumErrors] "181"',
         'myhost smartctl.info[da1,DriveStatus] "DUPLICATE"'
     ]))
コード例 #5
0
 def runtest(self, output, expected_disks, patchCheckOutput):
     patchCheckOutput.side_effect = mock_smartctl({'--scan': output})
     config = zabbix_smartmontools.parseConfig("test/example/empty")
     (error, disks) = zabbix_smartmontools.scanDisks(config, "getverb")
     self.assertEqual(error, "")
     self.assertEqual(disks, expected_disks)
コード例 #6
0
 def test_disk_list(self):
     config = zabbix_smartmontools.parseConfig(
         'test/example/with_disk_list.conf')
     self.assertEqual(config['Disks'],
                      ["/dev/sda -d sat+megaraid,4", "/dev/da0 -d scsi"])