"Fossies" - the Fresh Open Source Software Archive 
Member "dstat-0.7.4/plugins/dstat_snmp_net_err.py" (17 Jan 2019, 1204 Bytes) of package /linux/privat/dstat-0.7.4.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "dstat_snmp_net_err.py" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
0.7.3_vs_0.7.4.
1 ### Author: Dag Wieers <dag$wieers,com>
2
3 class dstat_plugin(dstat):
4 def __init__(self):
5 self.nick = ('error', )
6 self.type = 'b'
7 self.cols = 1
8 self.server = os.getenv('DSTAT_SNMPSERVER') or '192.168.1.1'
9 self.community = os.getenv('DSTAT_SNMPCOMMUNITY') or 'public'
10
11 def check(self):
12 try:
13 global cmdgen
14 from pysnmp.entity.rfc3413.oneliner import cmdgen
15 except:
16 raise Exception('Needs pysnmp and pyasn1 modules')
17
18 def name(self):
19 return self.vars
20
21 def vars(self):
22 return [ str(x) for x in snmpwalk(self.server, self.community, (1,3,6,1,2,1,2,2,1,2)) ]
23
24 def extract(self):
25 list(map(lambda x, y: self.set2.update({x: (int(y), )}), self.vars, snmpwalk(self.server, self.community, (1,3,6,1,2,1,2,2,1,20))))
26
27 if update:
28 for name in self.set2:
29 # self.val[name] = list(map(lambda x, y: (y - x) * 1.0 / elapsed, self.set1[name], self.set2[name]))
30 self.val[name] = list(map(lambda x, y: (y - x) * 1.0, self.set1[name], self.set2[name]))
31
32 if step == op.delay:
33 self.set1.update(self.set2)
34
35 # vim:ts=4:sw=4:et