Added a -h option to sicslog querying
Fixed the mongodb path in sicslogmain to point to the production server
This commit is contained in:
@ -182,7 +182,11 @@ static int MongoQueryAction(SConnection * pCon, SicsInterp * pSics,
|
||||
status = sicslogQuery(argc,argv,QueryCallback,result);
|
||||
if(status != 0){
|
||||
error = sicslogGetError();
|
||||
SCPrintf(pCon,eError,"Error %s querying mongodb", error);
|
||||
if(strstr(error,"Options") != NULL){
|
||||
SCPrintf(pCon,eValue,"%s", error);
|
||||
} else {
|
||||
SCPrintf(pCon,eError,"Error %s querying mongodb", error);
|
||||
}
|
||||
} else {
|
||||
SCPureSockWrite(pCon,GetCharArray(result),eLog);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int sicslogQuery(int argc, char *argv[], ResultCallback_t func, void *userData)
|
||||
parse options
|
||||
*/
|
||||
optind = 1;
|
||||
while((c = getopt(argc,argv,"s:l:f:t:i:e:c:")) != -1) {
|
||||
while((c = getopt(argc,argv,"s:l:f:t:i:e:c:h")) != -1) {
|
||||
switch (c){
|
||||
case 's':
|
||||
sub = strdup(optarg);
|
||||
@ -129,6 +129,13 @@ int sicslogQuery(int argc, char *argv[], ResultCallback_t func, void *userData)
|
||||
case 'c':
|
||||
severity = sevFromText(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
snprintf(
|
||||
lastError,sizeof(lastError),
|
||||
"Options: -s subsystem\n-l last(h,d)\n-f fromtime\n-t totime\n-i instrument\n-c severity\n%s",
|
||||
"-e search-expression");
|
||||
return 1;
|
||||
break;
|
||||
case '?':
|
||||
if( optopt == 's' || optopt == 'l' || optopt == 'f' || optopt == 't'
|
||||
|| optopt == 'i' || optopt == 'e' || optopt == 'c') {
|
||||
|
@ -25,8 +25,8 @@ int sicslogSetup(char *url, char *inst);
|
||||
int sicslogQuery(int argc, char *argv[], ResultCallback_t func, void *userData);
|
||||
|
||||
/*
|
||||
If sicslogQuery returned or sicslogSetup returns an error, retrieve a description
|
||||
of it. Only valid right after the error inducing call.
|
||||
If sicslogQuery or sicslogSetup returns an error, retrieve a description
|
||||
of it. Only valid right after the error inducing call.
|
||||
*/
|
||||
char *sicslogGetError();
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <bson.h>
|
||||
#include <logv2.h>
|
||||
|
||||
static void formatSeverity(unsigned int severity, char *buffer, unsigned int bufferLength)
|
||||
void formatSeverity(unsigned int severity, char *buffer, unsigned int bufferLength)
|
||||
{
|
||||
static const char *severityText[] = {"FATAL",
|
||||
"ERROR",
|
||||
@ -25,6 +25,7 @@ static void formatSeverity(unsigned int severity, char *buffer, unsigned int buf
|
||||
}
|
||||
strncpy(buffer,severityText[severity-1],bufferLength);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------*/
|
||||
static void ResultPrint(const bson_t *doc, void *userData)
|
||||
{
|
||||
@ -55,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
int status;
|
||||
char *error;
|
||||
|
||||
sicslogSetup("mongodb://logwriter:sinqsics@localhost:27017/?authSource=admin",NULL);
|
||||
sicslogSetup("mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin",NULL);
|
||||
status = sicslogQuery(argc,argv,ResultPrint,NULL);
|
||||
if(status != 0){
|
||||
error = sicslogGetError();
|
||||
|
Reference in New Issue
Block a user