AFS-Monitor
view release on metacpan or search on metacpan
src/Monitor.xs view on Meta::CPAN
}
}
if (found)
break;
}
if (!found) {
threshP++;
continue;
}
if (pValue > tValue) {
hv_store(VALUE, "overflow", 8, newSViv(1), 0);
hv_store(VALUE, "threshold", 9, newSVnv(tValue), 0);
if (threshP->handler[0] != '\0') {
sprintf(strval, "%g", pValue);
code = my_execute_thresh_handler(threshP->handler,
a_hostEntry->hostName, type,
threshP->itemName,
threshP->threshVal, strval,
VALUE, buffer);
if (code) {
return (code);
}
}
count++;
}
threshP++;
}
return (0);
} /* my_check_thresholds() */
/*
* from src/afsmonitor/afsmonitor.c
* ("$Header: /afs/slac/g/scs/slur/Repository/AFSDebug/Debug/src/Monitor.xs,v 1.2 2006/07/05 22:25:10 alfw Exp $");
*/
int
my_process_config_file(a_config_filename, numFS, numCM, lastHostType,
last_hostEntry, fs_showDefault, cm_showDefault,
fs_showFlags, cm_showFlags, FSnameList, CMnameList)
char *a_config_filename;
int *numFS;
int *numCM;
int *lastHostType;
struct afsmon_hostEntry **last_hostEntry;
int *fs_showDefault;
int *cm_showDefault;
short *fs_showFlags;
short *cm_showFlags;
struct afsmon_hostEntry **FSnameList;
struct afsmon_hostEntry **CMnameList;
{
char buff1[256] = ""; /* for error messages */
char buff2[256] = ""; /* for error messages returned from subroutines */
FILE *configFD = 0; /* config file descriptor */
char line[4 * CFG_STR_LEN]; /* a line of config file */
char opcode[CFG_STR_LEN]; /* specifies type of config entry */
char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */
char arg2[CFG_STR_LEN]; /* threshold variable */
char arg3[CFG_STR_LEN]; /* threshold value */
char arg4[CFG_STR_LEN]; /* user's handler */
struct afsmon_hostEntry *curr_host = 0;
struct hostent *he = 0; /* hostentry to resolve host name */
char *handlerPtr = 0; /* ptr to pass theresh handler string */
int code = 0; /* error code */
int linenum = 0; /* config file line number */
int threshCount = 0; /* count of thresholds for each server */
int error_in_config = 0; /* syntax errors in config file ?? */
int i = 0;
int numBytes = 0;
/* int global_ThreshFlag = 1; */
int global_fsThreshCount = 0;
int global_cmThreshCount = 0;
static char last_fsHost[HOST_NAME_LEN];
static char last_cmHost[HOST_NAME_LEN];
/* open config file */
configFD = fopen(a_config_filename, "r");
if (configFD == (FILE *) NULL) {
sprintf(buff1, "Failed to open config file %s", a_config_filename);
BSETCODE(5, buff1);
return (-1);
}
/* parse config file */
/* First Pass - check syntax and count number of servers and thresholds to monitor */
*numFS = 0;
*numCM = 0;
threshCount = 0;
error_in_config = 0; /* flag to note if config file has syntax errors */
while ((fgets(line, CFG_STR_LEN, configFD)) != NULL) {
opcode[0] = 0;
arg1[0] = 0;
arg2[0] = 0;
arg3[0] = 0;
arg4[0] = 0;
sscanf(line, "%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4);
linenum++;
/* fprintf(STDERR, "Got line %d: \"%s %s %s %s %s\"\n",
* linenum, opcode, arg1, arg2, arg3, arg4); */
/* skip blank lines and comment lines */
if ((strlen(opcode) == 0) || line[0] == '#') {
/* fprintf(STDERR, " - skipping line %d\n", linenum); */
continue;
}
if ((strcasecmp(opcode, "fs") == 0) || (strcasecmp(opcode, "cm")) == 0) {
/* fprintf(STDERR, " - parsing host entry\n"); */
code =
my_parse_hostEntry(line, numFS, numCM, lastHostType,
last_hostEntry, FSnameList, CMnameList, buff2);
/* thresholds are not global anymore */
src/Monitor.xs view on Meta::CPAN
/* sockaddr is always in net-order */
if ( udebug.lastYesHost != 0xffffffff ) {
inhostAddr.s_addr = htonl(udebug.lastYesHost);
hv_store(RETVAL, "lastYesHost", 11, newSVpv(inet_ntoa(inhostAddr), 0), 0);
hv_store(RETVAL, "lastYesTime", 11, newSViv(udebug.lastYesTime), 0);
hv_store(RETVAL, "lastYesState", 12, newSViv(udebug.lastYesState), 0);
hv_store(RETVAL, "lastYesClaim", 12, newSViv(udebug.lastYesClaim), 0);
}
LOCALVERSION = newHV();
hv_store(LOCALVERSION, "epoch", 5, newSViv(udebug.localVersion.epoch), 0);
hv_store(LOCALVERSION, "counter", 7, newSViv(udebug.localVersion.counter), 0);
hv_store(RETVAL, "localVersion", 12, newRV_inc((SV*)LOCALVERSION), 0);
hv_store(RETVAL, "amSyncSite", 10, newSViv(udebug.amSyncSite), 0);
hv_store(RETVAL, "epochTime", 9, newSViv(udebug.epochTime), 0);
if (udebug.amSyncSite) {
hv_store(RETVAL, "syncSiteUntil", 13, newSViv(udebug.syncSiteUntil), 0);
hv_store(RETVAL, "nServers", 8, newSViv(udebug.nServers), 0);
hv_store(RETVAL, "recoveryState", 13, newSViv(udebug.recoveryState), 0);
if (udebug.activeWrite) {
hv_store(RETVAL, "tidCounter", 10, newSViv(udebug.tidCounter), 0);
}
}
else {
hv_store(RETVAL, "isClone", 7, newSViv(isClone), 0);
inhostAddr.s_addr = htonl(udebug.lowestHost);
hv_store(RETVAL, "lowestHost", 10, newSVpv(inet_ntoa(inhostAddr), 0), 0);
hv_store(RETVAL, "lowestTime", 10, newSViv(udebug.lowestTime), 0);
inhostAddr.s_addr = htonl(udebug.syncHost);
hv_store(RETVAL, "syncHost", 8, newSVpv(inet_ntoa(inhostAddr), 0), 0);
hv_store(RETVAL, "syncTime", 8, newSViv(udebug.syncTime), 0);
}
SYNCVERSION = newHV();
hv_store(SYNCVERSION, "epoch", 5, newSViv(udebug.syncVersion.epoch), 0);
hv_store(SYNCVERSION, "counter", 7, newSViv(udebug.syncVersion.counter), 0);
hv_store(RETVAL, "syncVersion", 11, newRV_inc((SV*)SYNCVERSION), 0);
hv_store(RETVAL, "lockedPages", 11, newSViv(udebug.lockedPages), 0);
hv_store(RETVAL, "writeLockedPages", 16, newSViv(udebug.writeLockedPages), 0);
hv_store(RETVAL, "anyReadLocks", 12, newSViv(udebug.anyReadLocks), 0);
hv_store(RETVAL, "anyWriteLocks", 13, newSViv(udebug.anyWriteLocks), 0);
hv_store(RETVAL, "currentTrans", 12, newSViv(udebug.currentTrans), 0);
if (udebug.currentTrans) {
hv_store(RETVAL, "writeTrans", 10, newSViv(udebug.writeTrans), 0);
SYNCTID = newHV();
hv_store(SYNCTID, "epoch", 5, newSViv(udebug.syncTid.epoch), 0);
hv_store(SYNCTID, "counter", 7, newSViv(udebug.syncTid.counter), 0);
hv_store(RETVAL, "syncTid", 7, newRV_inc((SV*)SYNCTID), 0);
}
if (int32p || udebug.amSyncSite) {
/* now do the subcalls */
SERVERS = newAV();
for ( i=0; ; i++ ) {
#ifdef USE_VOTEXDEBUG
isClone = 0;
code = VOTE_XSDebug(tconn, i, &usdebug, &isClone);
if (code < 0) {
if ( oldServer ) { /* pre 3.5 server */
ubik_sdebug * ptr = &usdebug;
memset(&usdebug, 0, sizeof(usdebug));
code = VOTE_SDebugOld(tconn, i, (struct ubik_sdebug_old *) ptr);
}
else
code = VOTE_SDebug(tconn, i, &usdebug);
}
#else
if ( oldServer ) { /* pre 3.5 server */
ubik_sdebug * ptr = &usdebug;
memset(&usdebug, 0, sizeof(usdebug));
code = VOTE_SDebugOld(tconn, i, (struct ubik_sdebug_old *) ptr);
}
else
code = VOTE_SDebug(tconn, i, &usdebug);
#endif
if (code > 0)
break; /* done */
if (code < 0) {
warn("error code %d from VOTE_SDebug\n", code);
break;
}
/* otherwise print the structure */
USDEBUG = newHV();
inhostAddr.s_addr = htonl(usdebug.addr);
hv_store(USDEBUG, "addr", 4, newSVpv(afs_inet_ntoa(htonl(usdebug.addr)), 0), 0);
ALTADDR = newAV();
for ( j=0;((usdebug.altAddr[j]) && (j<UBIK_MAX_INTERFACE_ADDR-1)); j++) {
av_store(ALTADDR, j, newSVpv(afs_inet_ntoa(htonl(usdebug.altAddr[j])), 0));
}
if (j) hv_store(USDEBUG, "altAddr", 7, newRV_inc((SV*)ALTADDR), 0);
REMOTEVERSION = newHV();
hv_store(REMOTEVERSION, "epoch", 5, newSViv(usdebug.remoteVersion.epoch), 0);
hv_store(REMOTEVERSION, "counter", 7, newSViv(usdebug.remoteVersion.counter), 0);
hv_store(USDEBUG, "remoteVersion", 13, newRV_inc((SV*)REMOTEVERSION), 0);
hv_store(USDEBUG, "isClone", 7, newSViv(isClone), 0);
hv_store(USDEBUG, "lastVoteTime", 12, newSViv(usdebug.lastVoteTime), 0);
hv_store(USDEBUG, "lastBeaconSent", 14, newSViv(usdebug.lastBeaconSent), 0);
hv_store(USDEBUG, "lastVote", 8, newSViv(usdebug.lastVote), 0);
hv_store(USDEBUG, "currentDB", 9, newSViv(usdebug.currentDB), 0);
hv_store(USDEBUG, "up", 2, newSViv(usdebug.up), 0);
hv_store(USDEBUG, "beaconSinceDown", 15, newSViv(usdebug.beaconSinceDown), 0);
( run in 0.536 second using v1.01-cache-2.11-cpan-39bf76dae61 )