Maintainer | Pavlo Kerestey <pavlo@kerestey.net> |
---|---|
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
This is a binding to Net-SNMP version 5, http://www.net-snmp.org/.
- data ASNValue
- = OctetString ByteString [Word8]
- | OID ByteString ByteString [Word32]
- | Integer32 Int32
- | Integer64 Int64
- | Counter32 Word32
- | Counter64 Word64
- | Unsigned32 Word32
- | Unsigned64 Word64
- | Gauge32 Word32
- | IpAddress ByteString [Word8]
- | Opaque [Word8]
- | TimeTicks ByteString Word32
- | Boolean Bool
- | IEEEFloat Float
- | IEEEDouble Double
- | Null
- | Unsupported Int ByteString
- data SnmpResult = SnmpResult {}
- newtype SnmpVersion = SnmpVersion {}
- type RawOID = [OIDpart]
- type OIDpart = Word64
- type Hostname = ByteString
- type Community = ByteString
- snmp_version_1 :: SnmpVersion
- snmp_version_2c :: SnmpVersion
- snmp_version_3 :: SnmpVersion
- initialize :: IO ()
- snmpGet :: SnmpVersion -> Hostname -> Community -> RawOID -> IO (Either String SnmpResult)
- snmpNext :: SnmpVersion -> Hostname -> Community -> RawOID -> IO (Either String SnmpResult)
- snmpWalk :: SnmpVersion -> Hostname -> Community -> RawOID -> IO (Either String [SnmpResult])
- snmpBulkWalk :: Hostname -> Community -> RawOID -> IO (Either String [SnmpResult])
- showASNValue :: ASNValue -> String
Types
Typed representation of atomic ASN.1 data types. Some types are returned in more than one format for different uses. Some include a descriptive string built by the underlying C library.
OctetString ByteString [Word8] |
|
OID ByteString ByteString [Word32] |
|
Integer32 Int32 |
|
Integer64 Int64 |
|
Counter32 Word32 |
|
Counter64 Word64 |
|
Unsigned32 Word32 |
|
Unsigned64 Word64 |
|
Gauge32 Word32 |
|
IpAddress ByteString [Word8] |
|
Opaque [Word8] |
|
TimeTicks ByteString Word32 |
|
Boolean Bool |
|
IEEEFloat Float |
|
IEEEDouble Double |
|
Null |
|
Unsupported Int ByteString | Unsupported type from an agent. Returns the numeric type and the C library's description of the value. |
data SnmpResult Source
An SNMP value together with its OID. Returned by the query
routines snmpGet
, snmpNext
, and snmpWalk
.
newtype SnmpVersion Source
SNMP Protocol version. It is recommended to use the constants
snmp_version_1
, snmp_version_2c
, and snmp_version_3
.
SnmpVersion | |
|
The net-snmp C library on 64-bit OS X systems still uses 32-bit oid parts in the responses. Please make sure that the library produces sane results on your system by cloning the source code and running `make test`.
type Hostname = ByteString Source
type Community = ByteString Source
Constants
snmp_version_1 :: SnmpVersion Source
SNMPv1. The first SNMP standard, using cleartext passwords ("communities")
snmp_version_2c :: SnmpVersion Source
SNMPv2c. Updated SMI and wire protocol, but still uses communities.
snmp_version_3 :: SnmpVersion Source
SNMPv3. Same SMI and protocol as SNMPv2c; stronger authentication. Unimplemented.
Functions
Library Initialization
initialize :: IO () Source
Initialize the Net-SNMP library. This must be called before any other NetSNMP functions, and before starting extra threads, as the mib compiler is not thread-safe.
Queries
:: SnmpVersion | |
-> Hostname | IP or hostname of the agent to be queried. May have
prefix of |
-> Community | SNMP community (password) |
-> RawOID | OID to be queried |
-> IO (Either String SnmpResult) |
Simple community-authenticated SNMP get. Returns the object queried, or a descriptive error message.
Examples:
- snmpGet "localhost" "public" [1,3,6,1,2,1,1,1,0]
- snmpGet "tcp:localhost:5161" "mypassword" [1,3,6,1,2,1,1,1,0]
:: SnmpVersion | |
-> Hostname | IP or hostname of the agent to be queried. May have
prefix of |
-> Community | SNMP community (password) |
-> RawOID | OID to be queried |
-> IO (Either String SnmpResult) |
Simple community-authenticated SNMP getnext. Returns the first object after the OID queried, or a descriptive error message.
Examples:
- snmpNext "localhost" "public" [1,3,6,1,2,1,1,1,0]
- snmpNext "tcp:localhost:5161" "mypassword" [1,3,6,1,2,1,1,1,0]
:: SnmpVersion | |
-> Hostname | IP or hostname of the agent to be queried. May have
prefix of |
-> Community | SNMP community (password) |
-> RawOID | OID to be queried |
-> IO (Either String [SnmpResult]) |
Simple community-authenticated SNMP walk. Returns a list of objects, starting with the object after the OID queried, and continuing through all objects underneath that OID in the mib tree. On failure, returns a descriptive error message.
This implementation uses a series of next operations and is not very ressource friendly. Consider using snmpBulkWalk for better performance
Examples:
- snmpWalk snmp_version_2c "localhost" "public" [1,3,6,1,2,1,1]
- snmpWalk snmp_version_2c "tcp:localhost:5161" "mypassword" [1,3,6,1,2,1,1]
:: Hostname | IP or hostname of the agent to be queried. May have
prefix of |
-> Community | SNMP community (password) |
-> RawOID | OID to be queried |
-> IO (Either String [SnmpResult]) |
Same as snmpWalk but implemented with bulk requests
Examples:
- snmpBulkWalk "localhost" "public" [1,3,6,1,2,1,1]
- snmpBulkWalk "tcp:localhost:5161" "mypassword" [1,3,6,1,2,1,1]
Miscellany
showASNValue :: ASNValue -> String Source
Show ASNValue contents in a simple string, losing type differentiation. Callers should not rely on the format of the message returned, and this function may disappear in a future version.