AW: SNMP AgentX Problem <LONG MAIL>

"Stefan Mikuszeit" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <F3901AB02822B34A97EDB74B8FEF9E06029736A0@hom02ex.hom-de.SYZYGY.INTERN>
Hello Dave,

	i have changed the code of logging from the perlscript, but i become not more entries:

		mysql_agent.pl: started us as a subagent (NetSNMP::agent=HASH(0x83ee44c))
	
		mysql_agent.pl: refs:
		mysql_agent.pl:  - finished processing
	
		mysql_agent.pl: shutting down
	
		mysql_agent.pl: shutting down

		mysql_agent.pl: Refreshed at 1183466657



	If i use -x localhost:705 i see that the SubAgent search an filepath !
	Then i have changed the -x localhost:705 to -x tcp:localhost:705 and now the connection from SubAgent to the MasterAgent seams to work.


	I have now make a check:

		Start the SNMPD
			/usr/sbin/snmpd -Ls DAEMON -Lf /var/log/snmpd.log -u root -p /var/run/snmpd.pid -x tcp:localhost:705 -c /etc/snmp/snmpd.conf -Dperl -Dread_config -Dagentx/master -Dagentx/subagent

		Then I have make a new agent like the example from `perldoc NetSNMP::agent`
			root@HOM21DB:~# /usr/lib/net-snmp/agents/mysql_agent.pl
			NET-SNMP version 5.4 AgentX subagent connected
			registering pdu failed: 263!

		As you can see, the SubAgent will find the MasterAgent but then come this errormessage.


		In an strace i can see many timeouts:

connect(7, {sa_family=AF_INET, sin_port=htons(705), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockopt(7, SOL_SOCKET, SO_SNDBUF, [50592], [4]) = 0
getsockopt(7, SOL_SOCKET, SO_RCVBUF, [87888], [4]) = 0
send(7, "\1\1\0\0\0\0\0\0\0\0\0\0\354b\6J<\0\0\0\0\0\0\0\5\4\0\0"..., 80, 0) = 80
gettimeofday({1183469846, 171336}, NULL) = 0
gettimeofday({1183469846, 171373}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {0, 999963}) = 1 (in [7], left {1, 0})
brk(0x8382000)                          = 0x8382000
recv(7, "\1\22\0\0\27\0\0\0\0\0\0\0\354b\6JD\0\0\0\7\25\1\0\0\0"..., 65536, 0) = 88
gettimeofday({1183469846, 172485}, NULL) = 0
brk(0x8372000)                          = 0x8372000
write(2, "NET-SNMP version 5.4 AgentX suba"..., 47NET-SNMP version 5.4 AgentX subagent connected
) = 47
send(7, "\1\3\0\0\27\0\0\0\0\0\0\0\355b\6J\34\0\0\0\0\177\0\0\5"..., 48, 0) = 48
gettimeofday({1183469846, 176211}, NULL) = 0
gettimeofday({1183469846, 176294}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {0, 999917}) = 1 (in [7], left {1, 0})
recv(7, "\1\22\0\0\27\0\0\0\0\0\0\0\355b\6J$\0\0\0\7\25\1\0\7\1"..., 65536, 0) = 56
gettimeofday({1183469846, 176590}, NULL) = 0
write(2, "registering pdu failed: 263!\n", 29registering pdu failed: 263!
) = 29
gettimeofday({1183469846, 176819}, NULL) = 0
times({tms_utime=11, tms_stime=2, tms_cutime=0, tms_cstime=0}) = 1572397666
times({tms_utime=11, tms_stime=2, tms_cutime=0, tms_cstime=0}) = 1572397666
gettimeofday({1183469846, 177108}, NULL) = 0
gettimeofday({1183469846, 177175}, NULL) = 0
gettimeofday({1183469846, 177200}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {14, 999644}) = 0 (Timeout)
gettimeofday({1183469861, 174977}, NULL) = 0
gettimeofday({1183469861, 175063}, NULL) = 0
gettimeofday({1183469861, 175148}, NULL) = 0
gettimeofday({1183469861, 175234}, NULL) = 0
gettimeofday({1183469861, 175359}, NULL) = 0
gettimeofday({1183469861, 175448}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {0, 1460}) = 0 (Timeout)
gettimeofday({1183469861, 176888}, NULL) = 0
gettimeofday({1183469861, 176972}, NULL) = 0
gettimeofday({1183469861, 177056}, NULL) = 0
gettimeofday({1183469861, 177133}, NULL) = 0
send(7, "\1\r\0\0\27\0\0\0\0\0\0\0\356b\6J\0\0\0\0", 20, 0) = 20
gettimeofday({1183469861, 177945}, NULL) = 0
gettimeofday({1183469861, 178030}, NULL) = 0
gettimeofday({1183469861, 178108}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {0, 1})  = 1 (in [7], left {0, 1000})
recv(7, "\1\22\0\0\27\0\0\0\0\0\0\0\356b\6J\10\0\0\0\344\32\1\0"..., 65536, 0) = 28
gettimeofday({1183469861, 178414}, NULL) = 0
gettimeofday({1183469861, 178501}, NULL) = 0
gettimeofday({1183469861, 178591}, NULL) = 0
gettimeofday({1183469861, 178670}, NULL) = 0
select(8, [3 5 7], NULL, NULL, {14, 998542} <unfinished ...>


	I hope this will help :-)


Regards
Stefan

-----Ursprüngliche Nachricht-----
Von: Stefan Mikuszeit 
Gesendet: Dienstag, 3. Juli 2007 13:34
An: Stefan Mikuszeit; 'Dave Shield'
Cc: '[email protected]'
Betreff: AW: SNMP AgentX Problem <LONG MAIL>


Hello Dave

Log Output from the subagent:

	root@HOM21DB:~# /usr/lib/net-snmp/agents/mysql_agent.pl
	started us as a subagent (NetSNMP::agent=HASH(0x82cb94c))
	refs: , , ,
	- finished processing
	shutting down
	shutting down
	Refreshed at 1183462255 0


Log Output from tcpdump at starting the subagent:

	root@HOM21DB:~# tcpdump -i lo -v
	tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes
	13:32:53.888535 IP (tos 0x0, ttl  64, id 21438, offset 0, flags [DF], proto: TCP (6), length: 60) localhost.localdomain.43798 > localhost.localdomain.mysql: S, cksum 0xb45d (correct), 	245440441:245440441(0) win 32767 <mss 16396,sackOK,timestamp 2833992711 0,nop,wscale 2>
	13:32:53.888863 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) localhost.localdomain.mysql > localhost.localdomain.43798: S, cksum 0x9595 (correct), 	246094617:246094617(0) ack 245440442 win 32767 <mss 16396,sackOK,timestamp 2833992711 2833992711,nop,wscale 2>
	13:32:53.888623 IP (tos 0x0, ttl  64, id 21440, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.43798 > localhost.localdomain.mysql: ., cksum 0x5eb4 (correct), ack 1 	win 8192 <nop,nop,timestamp 2833992711 2833992711>
	13:32:53.888938 IP (tos 0x8, ttl  64, id 22301, offset 0, flags [DF], proto: TCP (6), length: 95) localhost.localdomain.mysql > localhost.localdomain.43798: P 1:44(43) ack 1 win 8192 	<nop,nop,timestamp 2833992711 2833992711>
	13:32:53.889104 IP (tos 0x0, ttl  64, id 21442, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.43798 > localhost.localdomain.mysql: ., cksum 0x5e89 (correct), ack 44 	win 8192 <nop,nop,timestamp 2833992711 2833992711>
	13:32:53.889348 IP (tos 0x8, ttl  64, id 21444, offset 0, flags [DF], proto: TCP (6), length: 74) localhost.localdomain.43798 > localhost.localdomain.mysql: P, cksum 0xfe3e (incorrect (-> 	0x462c), 1:23(22) ack 44 win 8192 <nop,nop,timestamp 2833992711 2833992711>
	13:32:53.889381 IP (tos 0x8, ttl  64, id 22303, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.mysql > localhost.localdomain.43798: ., cksum 0x5e73 (correct), ack 23 	win 8192 <nop,nop,timestamp 2833992711 2833992711>
	13:32:53.889424 IP (tos 0x8, ttl  64, id 22305, offset 0, flags [DF], proto: TCP (6), length: 61) localhost.localdomain.mysql > localhost.localdomain.43798: P, cksum 0xfe31 (incorrect (-> 	0x595d), 44:53(9) ack 23 win 8192 <nop,nop,timestamp 2833992712 2833992711>
	13:32:53.889660 IP (tos 0x8, ttl  64, id 21446, offset 0, flags [DF], proto: TCP (6), length: 73) localhost.localdomain.43798 > localhost.localdomain.mysql: P, cksum 0xfe3d (incorrect (-> 	0x1df7), 23:44(21) ack 53 win 8192 <nop,nop,timestamp 2833992712 2833992712>
	13:32:53.889761 IP (tos 0x8, ttl  64, id 22307, offset 0, flags [DF], proto: TCP (6), length: 61) localhost.localdomain.mysql > localhost.localdomain.43798: P, cksum 0xfe31 (incorrect (-> 	0x593f), 53:62(9) ack 44 win 8192 <nop,nop,timestamp 2833992712 2833992712>
	13:32:53.890074 IP (tos 0x8, ttl  64, id 21448, offset 0, flags [DF], proto: TCP (6), length: 87) localhost.localdomain.43798 > localhost.localdomain.mysql: P 44:79(35) ack 62 win 8192 	<nop,nop,timestamp 2833992712 2833992712>
	13:32:53.890205 IP (tos 0x8, ttl  64, id 22309, offset 0, flags [DF], proto: TCP (6), length: 3330) localhost.localdomain.mysql > localhost.localdomain.43798: P 62:3340(3278) ack 79 win 8192 	<nop,nop,timestamp 2833992712 2833992712>
	13:32:53.895815 IP (tos 0x8, ttl  64, id 21450, offset 0, flags [DF], proto: TCP (6), length: 57) localhost.localdomain.43798 > localhost.localdomain.mysql: P, cksum 0xfe2d (incorrect (-> 	0x3ee7), 79:84(5) ack 3340 win 12383 <nop,nop,timestamp 2833992718 2833992712>
	13:32:53.895865 IP (tos 0x8, ttl  64, id 22311, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.mysql > localhost.localdomain.43798: F, cksum 0x5147 (correct), 	3340:3340(0) ack 84 win 8192 <nop,nop,timestamp 2833992718 2833992718>
	13:32:53.896018 IP (tos 0x8, ttl  64, id 21452, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.43798 > localhost.localdomain.mysql: F, cksum 0x40e7 (correct), 84:84	(0) ack 3341 win 12383 <nop,nop,timestamp 2833992718 2833992718>
	13:32:53.896028 IP (tos 0x8, ttl  64, id 22313, offset 0, flags [DF], proto: TCP (6), length: 52) localhost.localdomain.mysql > localhost.localdomain.43798: ., cksum 0x5146 (correct), ack 85 	win 8192 <nop,nop,timestamp 2833992718 2833992718>


Regards
Stefan


-----Ursprüngliche Nachricht-----
Von: Stefan Mikuszeit 
Gesendet: Dienstag, 3. Juli 2007 13:10
An: Stefan Mikuszeit; Dave Shield
Cc: [email protected]
Betreff: AW: SNMP AgentX Problem <LONG MAIL>


Hello Dave,

	i have found following:

		if i put this line to snmpd.conf the snmpd dosn't work anymore (snmpwalk / snmpget becomes timeout):

			perl do '/usr/lib/net-snmp/agents/mysql_agent.pl';

		Wenn i start the agent (snmpd) via the '-X' argument i have the same problem as above.


		The next i have found is with the /tmp/shtest that is configured in the snmpd.conf via this line:

			exec enterprises.ucdavis.50.100.1 /bin/sh /tmp/shtest

		as you can see the OID is running at enterprises.ucdavis.50.100.1, but if i make an snmpwalk i become an errormessage:

			root@HOM21DB:/etc/snmp# snmpwalk localhost -c public -v2c enterprises.ucdavis.50.100.1
			UCD-SNMP-MIB::ucdavis.50.100.1 = No Such Object available on this agent at this OID


			root@HOM21DB:/etc/snmp# cat /tmp/shtest
			#!/bin/sh
			echo hello world
			echo hi there
			exit 35


		with an snmpwalk at enterprises.ucdavis i find following entries in the table:

			UCD-SNMP-MIB::extIndex.1 = INTEGER: 1
			UCD-SNMP-MIB::extIndex.2 = INTEGER: 2
			UCD-SNMP-MIB::extNames.1 = STRING: enterprises.ucdavis.50.100.1
			UCD-SNMP-MIB::extNames.2 = STRING: enterprises.ucdavis.50.100.1
			UCD-SNMP-MIB::extCommand.1 = STRING: /bin/sh /tmp/shtest
			UCD-SNMP-MIB::extCommand.2 = STRING: /bin/sh /tmp/shtest
			UCD-SNMP-MIB::extResult.1 = INTEGER: 35
			UCD-SNMP-MIB::extResult.2 = INTEGER: 35
			UCD-SNMP-MIB::extOutput.1 = STRING: hello world
			hi there
			UCD-SNMP-MIB::extOutput.2 = STRING: hello world
			hi there
			UCD-SNMP-MIB::extErrFix.1 = INTEGER: noError(0)
			UCD-SNMP-MIB::extErrFix.2 = INTEGER: noError(0)
			UCD-SNMP-MIB::extErrFixCmd.1 = STRING:
			UCD-SNMP-MIB::extErrFixCmd.2 = STRING:

		It's seams that no extension is make to the table :-(

	Is this right, that the subagent must start before the agent is startet ?

		Like this:
			/usr/lib/net-snmp/agents/mysql_agent.pl &
			`which snmpd` -Ls DAEMON -Lf /var/log/snmpd.log -u root -p /var/run/snmpd.pid -X -x localhost:705 -c /etc/snmp/snmpd.conf


	

	Sorry i have forgotten to tell you that i work on an Linux Ubuntu 6.06 Server :-)

	I have attached the actual snmpd.conf.

Regards 
Stefan


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]]Im Auftrag von
Stefan Mikuszeit
Gesendet: Dienstag, 3. Juli 2007 12:38
An: Dave Shield
Cc: [email protected]
Betreff: AW: SNMP AgentX Problem <LONG MAIL>


Hello Dave,

	thx for your help :-)


	This is the code for set the new Value to the OID, it's included in the Script ;-)

      if ($next ne "") {
        $value = $global_status{$next}{'value'};

        $request->setOID($next);
        $request->setValue(ASN_OCTET_STR, "$value");


	The Debugging Info you will find at the attachment.

Regards
Stefan

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]]Im
Auftrag von Dave Shield
Gesendet: Dienstag, 3. Juli 2007 10:40
An: Stefan Mikuszeit
Cc: [email protected]
Betreff: Re: SNMP AgentX Problem <LONG MAIL>


On 02/07/07, Stefan Mikuszeit <[email protected]> wrote:
> The problem is that the subagent dos not submit the collected data's
> to the snmp agent, but i don't no why :(

Try activating the debugging code in your subagent.
What does that show?

What are the exact commands you are trying?


I haven't looked through the whole of your code, but:


> My Subagent Perlscript
>
> <-- SNIP -->
>
> #!/usr/bin/perl --

> sub mysql_snmp_handler {

>     if ($mode == MODE_GET) {
            [snip]
>     }
>
>     if ($mode == MODE_GETNEXT) {
            [snip]
>     }
>   }
>   #print STDERR "- finished processing\n" if ($debugging);
> }

This handler doesn't seem to include and code to support SET
requests - just GET and GETNEXT.   So it's not too surprising
that SET requests aren't working :-)


Dave

PS:  Please don't include so much in-line information.
If you've got various additional code, MIB and config files,
it's probably better to include them as attachments.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.