每个人都需要帮助。 我现在使用telegraf作为我的InfluxDB数据库的日志馈送器,概念是我的telegraf将读取日志然后将结果发送到InfluxDB。
files = ["/here/is/the/directory/logname.log"]
当日志文件名为logname.log时,它按预期工作。但是,今天我需要将logname系统更改为logname.20170320.log,其中20170320是日志的日期。你介意,正确的配置如何:
files = ["/here/is/the/directory/logname.20170320.log"]
files = ["/here/is/the/directory/logname.20170321.log"]
因此它可以读取名称每天动态变化的日志,如:
#include <jni.h>
#include <math.h>
#include "WavFile.h"
JNIEXPORT jdoubleArray JNICALL
Java_com_manavdutta1_affdexdemo_VideoActivity_AnalyzFile(JNIEnv* env, jobject thiz, jstring file)
{
jdouble result[5];
memset(result, 0, 5);
const char *fileString = (*env)->GetStringUTFChars(env, file, 0);
VokaturiWavFile wavFile;
VokaturiWavFile_open (fileString, & wavFile);
if (! VokaturiWavFile_valid (& wavFile)) {
fprintf (stderr, "Error: WAV file not analyzed.\n");
}
else {
VokaturiVoice voice = VokaturiVoice_create (wavFile.samplingFrequency, wavFile.numberOfSamples);
VokaturiQuality quality;
VokaturiEmotionProbabilities emotionProbabilities;
VokaturiVoice_extract (voice, & quality, & emotionProbabilities);
if (quality.valid) {
result[0] = emotionProbabilities.neutrality;
result[1] = emotionProbabilities.happiness;
result[2] = emotionProbabilities.sadness;
result[3] = emotionProbabilities.anger;
result[4] = emotionProbabilities.fear;
}
VokaturiVoice_destroy (voice);
VokaturiWavFile_clear (& wavFile);
}
(*env)->ReleaseStringUTFChars(env, file, fileString);
jdoubleArray finalArray;
finalArray = (*env)->NewDoubleArray(env, 5);
(*env)->SetDoubleArrayRegion(env, finalArray, 0, 5, result);
return finalArray;
}
感谢您的帮助。
答案 0 :(得分:0)
基于@Luv33preet评论here,然后我创建一个脚本,每天使用sed更改配置,这里是代码:
/bin/sed -i "s/`date +'%Y%m%d' -d '1 day ago'`/`date +'%Y%m%d'`/" /etc/telegraf/conf.d/my-config.conf
更改电报配置。
答案 1 :(得分:-1)
为什么只为日志文件设置通配符?
[[inputs.logparser]]
/var/log/*/*.log -> find all .log files with a parent dir in /var/log
from_beginning = false