Ad blocker detected: Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker on our website.
Post general support questions here that do not specifically fall into the Linux or Windows categories.
Moderators: Developers , Moderators
criuz
Posts: 1 Joined: Sun Nov 09, 2008 9:32 am
Post
by criuz » Sun Nov 09, 2008 9:46 am
I have this perl script at /tmp/shtest:
Code: Select all
#!/bin/sh
echo hello world
echo hi there
exit 35
Which outputs:
Code: Select all
$ /bin/sh /tmp/shtest
hello world
hi there
When I want to execute this script with SNMP exec I add this to my /usr/share/snmp/snmpd.conf:
And call snmpwalk with following command:
Code: Select all
$ snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.8
which gives:
Code: Select all
$ snmpwalk -On -v 2c -c public localhost .1.3.6.1.4.1.2021.8
.1.3.6.1.4.1.2021.8.1.1.1 = INTEGER: 1
.1.3.6.1.4.1.2021.8.1.2.1 = STRING: shtest
.1.3.6.1.4.1.2021.8.1.3.1 = STRING: /bin/sh
.1.3.6.1.4.1.2021.8.1.100.1 = INTEGER: 35
.1.3.6.1.4.1.2021.8.1.101.1 = STRING: hello world
.1.3.6.1.4.1.2021.8.1.102.1 = INTEGER: noError(0)
.1.3.6.1.4.1.2021.8.1.103.1 = STRING:
As you can see the second line of the output is missing. Hm,.. this way I can not use SNMP for graphing purposes. Anyone has a clue?
TIA, criuz
Linegod
Developer
Posts: 1626 Joined: Thu Feb 20, 2003 10:16 am
Location: Canada
Contact:
Post
by Linegod » Fri Nov 14, 2008 2:32 am
exec and sh commands, on their own, can only have a single line of output.
You either have to create a separate script for each output, or use assign the script to a MIB.
Note: That is a shell script, not a perl script.
--
Live fast, die young
You're sucking up my bandwidth.
J.P. Pasnak,CD
CCNA, LPIC-1
http://www.warpedsystems.sk.ca
Users browsing this forum: No registered users and 5 guests