[nagiosplug] check_dhcp: fix mac address and interface number ...
"Nagios Plugin Development" <[email protected]> Tue, 17 Sep 2013 21:40:26 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug
Branch: master
Commit: 6e9d16809ec15a628920c0a3d7b6221aaf6aa895
Author: Sven Nierlein <[email protected]>
Committer: Sven Nierlein <[email protected]>
Date: Tue Sep 17 19:56:55 2013 +0200
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=6e9d168
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.
---
plugins-root/check_dhcp.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index b02ee49..42eedec 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){
char *p;
int unit;
- for(p = interface_name; *p && isalpha(*p); p++)
- /* no-op */ ;
- if( p != '\0' ){
+ /* get last number from interfacename, eg lnc0, e1000g0*/
+ int i;
+ p = interface_name + strlen(interface_name) -1;
+ for(i = strlen(interface_name) -1; i > 0; p--) {
+ if(isalpha(*p))
+ break;
+ }
+ p++;
+ if( p != interface_name ){
unit = atoi(p) ;
- *p = '\0' ;
strncat(dev, interface_name, 6) ;
}
else{
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk