memstat.c revision 4aac33d31b41cc7e3ac6fb66747ff2cae63d08cf
/*
* Copyright (c) 2005-2007 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#if USESWAPCTL
static long sc_page_size;
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
if (sc_page_size == -1)
return 0;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
char *resource;
long *pvalue;
{
int r;
if (r == -1)
r *= sc_page_size >> 10;
*pvalue = r;
return 0;
}
#include <kstat.h>
static kstat_ctl_t *kc;
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
kc = kstat_open();
if (kst == 0)
return 0;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
int r;
return 0;
r = kstat_close(kc);
if (r != 0)
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
char *resource;
long *pvalue;
{
int r;
return -1;
return 0;
}
/*
total: used: free: shared: buffers: cached:
Mem: 261468160 252149760 9318400 0 3854336 109813760
Swap: 1052794880 62185472 990609408
MemTotal: 255340 kB
MemFree: 9100 kB
MemShared: 0 kB
Buffers: 3764 kB
Cached: 107240 kB
Active: 104340 kB
Inact_dirty: 4220 kB
Inact_clean: 2444 kB
Inact_target: 4092 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 255340 kB
LowFree: 9100 kB
SwapTotal: 1028120 kB
SwapFree: 967392 kB
*/
#include <stdio.h>
#include <string.h>
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
{
}
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
char *resource;
long *pvalue;
{
int r;
size_t l;
char buf[80];
return EINVAL;
return EINVAL;
return -1; /* try to reopen? */
if (l >= sizeof(buf))
return EINVAL;
{
{
return (r > 0) ? 0 : -1;
}
}
return 0;
}
#else /* USEPROCMEMINFO */
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
return -1;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
{
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
char *resource;
long *pvalue;
{
return -1;
}
#endif /* USEKSTAT */