summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Nierlein <Sven.Nierlein@consol.de>2013-09-17 19:56:55 +0200
committerSven Nierlein <sven@consol.de>2013-09-17 19:56:55 +0200
commit6e9d16809ec15a628920c0a3d7b6221aaf6aa895 (patch)
treedeecd539b95666adad915a9c5178c97f07db721d
parent08d554ada1d12a0a0bc9c2e6e218789e05287af8 (diff)
downloadmonitoring-plugins-6e9d16809ec15a628920c0a3d7b6221aaf6aa895.tar.gz
check_dhcp: fix mac address and interface number detection on solaris
newer (or x86) solaris implementations have interface names like e1000g0 which includes numbers. So we reverse the interface number detection to get the last number, instead of the first number.
-rw-r--r--plugins-root/check_dhcp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index b02ee49c..42eedec8 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -372,11 +372,16 @@ int get_hardware_address(int sock,char *interface_name){
372 char *p; 372 char *p;
373 int unit; 373 int unit;
374 374
375 for(p = interface_name; *p && isalpha(*p); p++) 375 /* get last number from interfacename, eg lnc0, e1000g0*/
376 /* no-op */ ; 376 int i;
377 if( p != '\0' ){ 377 p = interface_name + strlen(interface_name) -1;
378 for(i = strlen(interface_name) -1; i > 0; p--) {
379 if(isalpha(*p))
380 break;
381 }
382 p++;
383 if( p != interface_name ){
378 unit = atoi(p) ; 384 unit = atoi(p) ;
379 *p = '\0' ;
380 strncat(dev, interface_name, 6) ; 385 strncat(dev, interface_name, 6) ;
381 } 386 }
382 else{ 387 else{