1 # Copyright 2007, Red Hat, Inc
2 # James Bowes <jbowes@redhat.com>
3 # Seth Vidal modified command.py to be snmp.py
5 # This software may be freely redistributed under the terms of the GNU
6 # general public license.
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13 Abitrary command execution module for func.
18 base_snmp_command
= '/usr/bin/snmpget -v2c -Ov -OQ'
20 class Snmp(func_module
.FuncModule
):
24 description
= "SNMP related calls through func."
26 def get(self
, oid
, rocommunity
, hostname
='localhost'):
28 Runs an snmpget on a specific oid returns the output of the call.
30 command
= '%s -c %s %s %s' % (base_snmp_command
, rocommunity
, hostname
, oid
)
32 cmdref
= sub_process
.Popen(command
.split(),stdout
=sub_process
.PIPE
,stderr
=sub_process
.PIPE
, shell
=False)
33 data
= cmdref
.communicate()
34 return (cmdref
.returncode
, data
[0], data
[1])
36 #def walk(self, oid, rocommunity):
38 #def table(self, oid, rocommunity):