Net-Snmp perl scripts failed to open file
Hi,
I am trying to monitor my software RAID1 using snmpd exten command below is my snmpd.conf file extend raid-md0 /usr/local/bin/nagios-linux-swraid.pl --device=md0 ================ root@localhost]snmpwalk -v2c -c public 127.0.0.1 NET-SNMP-EXTEND-MIB::nsExtendOutputFull NET-SNMP-EXTEND-MIB::nsExtendOutputFull."raid-md0" = STRING: Can't open /proc/mdstat : Permission denied at /usr/local/bin/nagios-linux-swraid.pl line 56. ======================= IT gives me permission denied opening file. File permission is r--r--r. Attached sample scripts: #!/usr/bin/env perl # Get status of Linux software RAID for SNMP / Nagios # Author: Michal Ludvig <michal@logix.cz> # http://www.logix.cz/michal/devel/nagios # # Simple parser for /proc/mdstat that outputs status of all # or some RAID devices. Possible results are OK and CRITICAL. # It could eventually be extended to output WARNING result in # case the array is being rebuilt or if there are still some # spares remaining, but for now leave it as it is. # # To run the script remotely via SNMP daemon (net-snmp) add the # following line to /etc/snmpd.conf: # # extend raid-md0 /root/parse-mdstat.pl --device=md0 # # The script result will be available e.g. with command: # # snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2 use strict; use Getopt::Long; # Sample /proc/mdstat output: # # Personalities : [raid1] [raid5] # md0 : active (read-only) raid1 sdc1[1] # 2096384 blocks [2/1] [_U] # # md1 : active raid5 sdb3[2] sdb4[3] sdb2[4](F) sdb1[0] sdb5[5](S) # 995712 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] # [=================>...] recovery = 86.0% (429796/497856) finish=0.0min speed=23877K/sec # # unused devices: <none> my $file = "/proc/mdstat"; my $device = "all"; # Get command line options. GetOptions ('file=s' => \$file, 'device=s' => \$device, 'help' => sub { &usage() } ); ## Strip leading "/dev/" from --device in case it has been given $device =~ s/^\/dev\///; ## Return codes for Nagios my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); ## This is a global return value - set to the worst result we get overall my $retval = 0; my (%active_devs, %failed_devs, %spare_devs); open FILE, "< $file" or die "Can't open $file : $!"; while (<FILE>) { next if ! /^(md\d+)+\s*:/; next if $device ne "all" and $device ne $1; my $dev = $1; ====================REST is scraped================ |
What is the perms on /proc?
|
This is permission of proc
dr-xr-xr-x 97 root root 0 Aug 12 14:37 proc |
All times are GMT -5. The time now is 03:31 AM. |