nfs ping cleanup
This commit is contained in:
parent
9cc156a739
commit
9cbc2d0e75
|
@ -506,6 +506,8 @@ SIGAR_DECLARE(int) sigar_inet_ntoa(sigar_t *sigar,
|
||||||
|
|
||||||
SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
|
SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
|
||||||
|
|
||||||
|
SIGAR_DECLARE(int) sigar_nfs_ping(char *hostname);
|
||||||
|
|
||||||
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
|
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -425,27 +425,26 @@ static int get_sockaddr(struct sockaddr_in *addr, char *host)
|
||||||
|
|
||||||
if ((addr->sin_addr.s_addr = inet_addr(host)) == -1) {
|
if ((addr->sin_addr.s_addr = inet_addr(host)) == -1) {
|
||||||
if (!(hp = gethostbyname(host))) {
|
if (!(hp = gethostbyname(host))) {
|
||||||
fprintf(stderr, "%s: unknown host\n", host);
|
return -1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
memcpy(&addr->sin_addr, hp->h_addr, hp->h_length);
|
memcpy(&addr->sin_addr, hp->h_addr, hp->h_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sigar_nfsping(char *host)
|
SIGAR_DECLARE(int) sigar_nfs_ping(char *host)
|
||||||
{
|
{
|
||||||
CLIENT *client;
|
CLIENT *client;
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int sock, retval=1;
|
int sock, retval=SIGAR_OK;
|
||||||
struct timeval timeout, interval;
|
struct timeval timeout, interval;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
enum clnt_stat rpc_stat;
|
enum clnt_stat rpc_stat;
|
||||||
|
|
||||||
if (get_sockaddr(&addr, host) == 0) {
|
if (get_sockaddr(&addr, host) != SIGAR_OK) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
interval.tv_sec = 2;
|
interval.tv_sec = 2;
|
||||||
|
@ -456,7 +455,7 @@ int sigar_nfsping(char *host)
|
||||||
interval, &sock);
|
interval, &sock);
|
||||||
if (!client) {
|
if (!client) {
|
||||||
clnt_pcreateerror(buffer);
|
clnt_pcreateerror(buffer);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout.tv_sec = 10;
|
timeout.tv_sec = 10;
|
||||||
|
@ -466,7 +465,7 @@ int sigar_nfsping(char *host)
|
||||||
|
|
||||||
if (rpc_stat != RPC_SUCCESS) {
|
if (rpc_stat != RPC_SUCCESS) {
|
||||||
clnt_perror(client, buffer);
|
clnt_perror(client, buffer);
|
||||||
retval = 0;
|
retval = -1;
|
||||||
}
|
}
|
||||||
clnt_destroy(client);
|
clnt_destroy(client);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue