Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have been trying to understand how to create a MIB : here what I did so far :
I created a MIB, and tried to allocate values to new OID => fail
Here is the MIB :
TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF
OBJECT-TYPE, Integer32,MODULE-IDENTITY FROM SNMPv2-SMI;
test MODULE-IDENTITY
LAST-UPDATED "201112190200Z"
ORGANIZATION "blah"
CONTACT-INFO
"please"
DESCRIPTION
"I am stuck"
REVISION "201112190200Z"
DESCRIPTION
"initial Draft"
::= { iso org(3) dod(6) internet(1) private(4) enterprises(1) 39106 }
testResearch OBJECT IDENTIFIER ::= { test 2 }
testVar OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"just for testing"
::= { testResearch 1}
-- conformance information
testMIBConformance OBJECT IDENTIFIER ::= { test 999 }
testMIBCompliances OBJECT IDENTIFIER ::= { testMIBConformance 1 }
testMIBGroups OBJECT IDENTIFIER ::= { testMIBConformance 2 }
-- compliance statements
testMIBCompliance MODULE-COMPLIANCE
STATUS current
DESCRIPTION
"blah."
MODULE -- this module
MANDATORY-GROUPS { testGroup }
::= { testMIBCompliances 1 }
-- units of conformance
testGroup OBJECT-GROUP
OBJECTS { testVar }
STATUS current
DESCRIPTION
"The draft"
::= { testMIBGroups 1 }
END
I then
validated this MIB against smilint ,
put it in ~/.snmp/mibs/
have the rwcommunity string for all host, with no OID restriction
restarted the snmpd daemon (On Debian)
So far, all good.
I then tried to see if the daemon knows about this new enterprise, and I did :
snmpwalk -v2c -m +ALL localhost .1.3.6.1.4.1.39106
which outputs :
TEST-MIB::test= No Such Object available on this agent at this OID
So I guess That snmpd is telling me he can't find anything under this tree, because nothing has been set yet.
So I try to set this test variable with snmpset on a shell :
snmpset -v2c -m +ALL localhost .1.3.6.1.4.1.39106.2.1 i 111
outputs :
Error in packet.
Reason: notWritable (That object does not support modification)
Failed object: TEST-MIB::testVar
I tried as well with :
snmpset -v2c -m +ALL localhost .1.3.6.1.4.1.39106.2.1.0 i 111
and as root, but with no success
But when I do a snmptranslate, I can see that the MIB is parsed correctly :
snmptranslate -Td 1.3.6.1.4.1.39106.2.1
TEST-MIB::testVar
testVar OBJECT-TYPE
-- FROM TEST-MIB
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION "just for testing"
::= { iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) test(39106) testResearch(2) 1 }
is it a bug? A known issue?
It sounds like you're trying to build your own SNMP Agent.
By the looks of things you've created your own MIB OID's correctly but nothing is responding to the new OID when you query the SNMP host.
Have a read of this: http://docs.oracle.com/cd/E13192_01/manager/mgr20/pguide/buildag.htm and see if it addresses your problem q:)
Related
I am working with MIB browser professional snmpv2c. one of the column parameters of mine in the table is octet string. I want to set octet string in SNMP table. I set OID and when I want to set value I take an error: wrong type.
my octet string is a 7 variable that I must enter them in octet syntax. but I don't know what is the correct type! for example 1111111 or 1.1.1.1.1.1.1 or x1111111 and so on.
I try to set it with command:
snmpset -v2c -c private 127.0.0.1:1161 1.3.6.1.4.1.36353231.4.1.1.1.9.1.2.1.1.2.1.1.1 x 1111111
1.3.6.1.4.1.36353231.4.1.1.1.9.1.2.1.1.2.1.1.1: Bad value notation (1111111)
snmpset -v2c -c private 127.0.0.1:1161 1.3.6.1.4.1.36353231.4.1.1.1.9.1.2.1.1.2.1.1.1 s "1111111"
Error in packet.
Reason: wrongType (The set datatype does not match the data type the agent expects)
Failed object: iso.3.6.1.4.1.36353231.4.1.1.1.9.1.2.1.1.2.1.1.1
snmpset -v2c -c private 127.0.0.1:1161 1.3.6.1.4.1.36353231.4.1.1.1.9.1.2.1.1.2.1.1.1 s "1" "1" "1" "1" "1" "1" "1"
1: Bad object type: 1
I am trying to write a data frame into a parquet format. The data frame is
str(test)
'data.frame': 365 obs. of 4 variables:
$ id : chr "Apple" "Apple" "Apple" "Apple" ...
$ text : chr "譲渡 拡散希望\npsychopass サイコパス トレーディングラバーストラップ 宜野座伸元\n特典円通常円送料にてお譲りします検索からでもお"| truncated "retweet\n\npeachpanther albumin the world right now" "haarlem vacature internet strateeg opzoek naar cto software architectlead developer star applehaarl" "ในอายทเทากน\nผหญงมความเปนผใหญมากกวาผชาย\nไมมผชายคนไหนไปไดสวยกบผหญงอายเทากนไดหรอก\n you are the a""| truncated ...
$ emotion : chr "unknown" "unknown" "unknown" "unknown" ...
$ polarity: chr "positive" "positive" "positive" "positive" ...
When i try to use write.parquet i get the following error
write.parquet(test,"hdfs://xxx.xxx.xxx.xxx:9000/orcladv/intdata/processedtweets")
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘write.parquet’ for signature ‘"data.frame", "character"’
Has anyone faced this issue. Please help me solve this.
Regards
Bala
"data.frame" in the error message indicates you are using an R data.frame. The write.parquet() function you are using operates on Spark DataFrames not R data.frames.
Details of how to convert between the two here: https://spark.apache.org/docs/latest/sparkr.html#creating-dataframes
I am trying to use the mib files supplied by Cisco to make sense the info obtainend by polling my switch via SNMP. It's a SG300-52P, the files can be found here.
After I placed the files in one of netsnmp's default mib directories, there were multiple errors when I tried to decode one of the description to its numeric value to verify that the mib files work. I thought about resolving the issues, but they were too numerous, so I decided to just try and get the simplest of these files to work with netsnmp. I placed only the SNMPv2-SMI file in one of netsnmp's default mib directories (because that came up in the errors and is a short file with no dependencies; I've appended the content for easy reference) and ran the following command:
snmptranslate -m SNMPv2-SMI zeroDotZero
However, this returns the following two erros:
Expected LAST-UPDATED (SMI): At line 35 in /home/buildmanager/.snmp/mibs/SNMPv2-SMI.my
zeroDotZero: Unknown Object Identifier (Sub-id not found: (top) -> zeroDotZero)
After some googling and guessing, I went ahead and checked the file with this online mib file validator here, which objected that
Line 34:
2 `SMI' should start with a lower case letter
1 syntax error, unexpected MODULE_IDENTITY, expecting OBJECT
I have no Idea what to make of these messages, googling them revealed nothing I could make sense of. Does this mean my file actually has errors? It's a file officially supplied by Cisco, and it's very basic - I can't imagine that would be the case.
I've made sure that there is no interfering SNMPv2-SMI anywhere else on my system, so I'm sure that this is the file netsnmp is using. I suspect there is something here that I did not understand about SNMP and these mib files in general, so please point me at the right direction or tell me where and how to look for answers. Thanks!
Contents of SNMPv2-SMI:
-- file: SNMPv2-SMI.my
-- Changes:
-- Converted to SMIC format.
-- dperkins#scruznet.com
SNMPv2-SMI DEFINITIONS ::= BEGIN
org OBJECT IDENTIFIER ::= { iso 3 }
dod OBJECT IDENTIFIER ::= { org 6 }
internet OBJECT IDENTIFIER ::= { dod 1 }
directory OBJECT IDENTIFIER ::= { internet 1 }
mgmt OBJECT IDENTIFIER ::= { internet 2 }
mib-2 OBJECT IDENTIFIER ::= { mgmt 1 }
transmission OBJECT IDENTIFIER ::= { mib-2 10 }
experimental OBJECT IDENTIFIER ::= { internet 3 }
private OBJECT IDENTIFIER ::= { internet 4 }
enterprises OBJECT IDENTIFIER ::= { private 1 }
security OBJECT IDENTIFIER ::= { internet 5 }
snmpV2 OBJECT IDENTIFIER ::= { internet 6 }
-- transport domains
snmpDomains OBJECT IDENTIFIER ::= { snmpV2 1 }
-- transport proxies
snmpProxys OBJECT IDENTIFIER ::= { snmpV2 2 }
-- module identities
snmpModules OBJECT IDENTIFIER ::= { snmpV2 3 }
-- macros
SMI MODULE-IDENTITY
SMI OBJECT-IDENTITY
SMI OBJECT-TYPE
SMI NOTIFICATION-TYPE
-- types
SMI Counter32
SMI Counter64
SMI Gauge32
SMI Integer32
SMI IpAddress
SMI Opaque
SMI TimeTicks
SMI BITS
SMI Unsigned32
zeroDotZero OBJECT-IDENTITY
STATUS current
DESCRIPTION
"A value used for null identifiers."
::= { 0 0 }
END
That SNMPv2-SMI file you quoted has been modified from the original/standard to use special syntax that is specific to the SMIC compiler (those "SMI" keywords like "SMI Counter32"), per the comments at the beginning:
-- Converted to SMIC format.
This is broken syntax (no longer valid SMIv1 or SMIv2) according to any other parser/compiler, hence the errors. You should only add MIBs to net-snmp that you need that are not already provided by it (as SNMPv2-SMI should be), and should use standard syntax, not compiler-specific extensions (unless they are implemented in comments).
Apologize for the long post, majority of it are config files that need to be shown.
I've been creating my own SNMP agent. For creating my MIB and snmpd.conf file I've just searched the web for answers. For actually implementing the handlers I've used the example.c/.h found at http://www.net-snmp.org/dev/agent/example_8c_source.html
I'm using another PC (all Linux) to test my implementation and so far I've only been able to get snmpwalk/snmpget commands to work.
I've setup the WriteMethod function inside my source file for my setable objects. Problem is, I do not think this code is getting executed when trying to set the object.
Below is an example of trying to set the object:
root#jt:/usr/share/snmp/mibs# snmpset -v 2c -c communityNameHere -m MIB-NAME-HERE.txt 10.20.30.40 1.3.6.1.4.1.12345.1 s "0"
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (MIB-NAME-HERE.txt): At line 0 in (none)
Error in packet.
Reason: notWritable (That object does not support modification)
Failed object: iso.3.6.1.4.1.12345.1
I've also tried to use snmpset without the -m option. I've tried using -m +MIB-NAME-HERE.txt as well.
Question - I have snmp.conf commented out. How can it not find the module when the MIB I specify is in /usr/share/snmp/mibs ?
Below is my MIB :
MIB-NAME-HERE DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises,
NOTIFICATION-TYPE FROM SNMPv2-SMI
OBJECT-GROUP, NOTIFICATION-GROUP FROM SNMPv2-CONF
;
testSnmp MODULE-IDENTITY
LAST-UPDATED "201505200000Z"
ORGANIZATION "www.example.com"
CONTACT-INFO
"email: support#example.com"
DESCRIPTION
"MIB Example."
REVISION "201505200000Z"
DESCRIPTION
"version 1.0"
::= { enterprises 12345 }
--
-- top level structure
--
testSnmpValues OBJECT IDENTIFIER ::= { testSnmp 1 }
testSnmpValuesGroup OBJECT-GROUP
OBJECTS { testObject
}
STATUS current
DESCRIPTION
"Group of all test variables."
::= { testSnmp 4 }
--
-- Values
--
testObject OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(1..4096))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Test Example"
::= { testSnmpValues 1 }
Question - What is the purpose of :
testSnmpValues OBJECT IDENTIFIER ::= { testSnmp 1 }
testSnmpValuesGroup OBJECT-GROUP
OBJECTS { testObject
}
STATUS current
DESCRIPTION
"Group of all test variables."
::= { testSnmp 4 }
Now for my snmpd.conf file :
###############################################################################
#
# snmpd.conf:
# Test snmpd configuration file. (See EXAMPLE.conf as a reference)
#
###############################################################################
# By default snmp looks here:
# /etc/snmp/snmpd.conf.
# Use '-C -c <configfile>' to override.
#
###############################################################################
# Access Control
###############################################################################
# sec.name source community
com2sec testall default communityNameHere
#---- Community 'communityNameHere' uses security name 'testall'. 'source' selects which IPs can connect.
####
# Second, map the security names into group names:
# sec.model sec.name
group TestGroup v1 testall
group TestGroup v2c testall
group TestGroup usm testall
####
# Third, create a view for us to let the groups have rights to:
# incl/excl subtree mask
#view all included .1 80
view testview included .1.3.6.1.4.1.12345
#---- testview - A view which only allows access to Test OIDs.
####
# Finally, grant the groups access to the 1 view with different
# write permissions:
# context sec.model sec.level match read write notif
#---- Grant read access to TEST group for all security models.
access TestGroup "" any noauth exact testview testview testview
# -----------------------------------------------------------------------------
# load the testsnmp module
dlmod testsnmp /usr/local/testsnmp.so
Question - Is there something I am missing to make an object writeable? I've seen other snmpd.conf files with different formats but I assume that shouldn't matter?
You generally don't need a MIB for net-snmp to work. It is enough when you have the OID specified in the .c file.
Are you trying the snmpset/get/walk on a remote PC or on the same one.
I had to specifie in my snmpd.conf the
-> agentAddress udp:161
Without it i didn't had access.
Your MIB file missing "END" at the end, you can validate it here: simpleweb mib validation
I named my community "public" and had to add this in /etc/snmp/snmpd.conf
com2sec ConfigUser default public
com2sec AllUser default public
group ConfigGroup v1 ConfigUser
group AllGroup v2c AllUser
Now you shall be able to do your tests with v1.
I had to do export MIBS="MY-MIB", whereas MY-MIB.txt is my MIB file, which I put info /usr/local/share/snmp/mibs/. I don't remember exactly whether it was required for mib2c tool or if you can skip defining MIBS variable.
Then you could start snmpd with -d switch to see debug output, start your agent and can do testing. I had to enable ports used by snmpd in my firewall, which were blocked by default. I can test read/write on my dummy value with:
snmpget -v1 -c public localhost:10161 MY-MIB::test2.0
MY-MIB::test2.0 = INTEGER: 43 tests
snmpset -v1 -c public localhost:10161 MY-MIB::test2.0 = 123
MY-MIB::test2.0 = INTEGER: 123 tests
As long as you have a working agent, this shall work, you can use also mib2c to create simple sub-agent for your test-MIB and test it with it, just to make sure your config+agent is all right.
I have inherited a MIB and example documentation, and need to re-implement the code that generates traps. (For various reason the original code is lost and gone forever, but CM is not my question.)
The MIB says:
alertObjects OBJECT IDENTIFIER ::= { corpAlert 1 }
alertEvents OBJECT IDENTIFIER ::= { corpAlert 2 }
alertDispatchTime OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Time Event Dispatched"
::= { alertObjects 3 }
testFailure OBJECT IDENTIFIER ::= { alertEvents 4 }
testFailureClearTrap NOTIFICATION-TYPE
OBJECTS
{
alertDispatchTime,
[omitted]
}
STATUS current
DESCRIPTION
"Clear prior failure"
::= { testFailure 0 }
Our documentation has the following snippet:
/usr/bin/snmptrap \
-v 1 \
-c public 192.168.0.2:162 [our-base-oid] 127.0.0.1 6 4 '' \
[our-base-oid].2.4.0.4.1.0 s "May 21 2007 10:19PM" \
[etc]
What I can't figure out is the OID used for the alert dispatch time. I would understand it if it were [our-base-oid].1.3.0, or even [our-base-oid].2.4.0.[our-base-oid].1.3. If we were generating a trap at { alertEvents 3 }, what would the suffix be for the individual objects?
It is possible that the MIB was updated after the documentation, so if this looks wrong to an expert then what should the OID be for the alertDispatchTime?
Thanks.
As defined here, alertDispatchTime is a scalar object (only one instance), so its instance subidentifier is always 0 (full OID is [corpAlert].1.3.0). The notification's OID is [corpAlert].2.4.0.
Assuming by "[our-base-oid]" you mean corpAlert, the snmptrap command shown doesn't look to be correct because [our-base-oid].2.4.0.4.1.0 would be testFailureClearTrap.4.1.0, which doesn't make sense: traps don't have instance subidentifiers. But I'm making some assumptions here about the parts of the MIB spec you've not included.
If you have a working system, maybe it'll good if you can generate a trap and see its contents.