-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
2,056 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "HostMonitorTimerEvent.h" | ||
|
||
#include "HostMonitorInputRunner.h" | ||
|
||
namespace logtail { | ||
|
||
bool HostMonitorTimerEvent::IsValid() const { | ||
return HostMonitorInputRunner::GetInstance()->IsCollectTaskValid(mConfigName, mCollectorName); | ||
} | ||
|
||
bool HostMonitorTimerEvent::Execute() { | ||
HostMonitorInputRunner::GetInstance()->ScheduleOnce(this); | ||
return true; | ||
} | ||
|
||
} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
#include "QueueKey.h" | ||
#include "timer/TimerEvent.h" | ||
|
||
namespace logtail { | ||
|
||
class HostMonitorTimerEvent : public TimerEvent { | ||
public: | ||
HostMonitorTimerEvent(std::chrono::steady_clock::time_point execTime, | ||
size_t interval, | ||
std::string configName, | ||
std::string collectorName, | ||
QueueKey processQueueKey) | ||
: TimerEvent(execTime), | ||
mConfigName(std::move(configName)), | ||
mCollectorName(collectorName), | ||
mProcessQueueKey(processQueueKey), | ||
mInputIdx(0) { | ||
mInterval = std::chrono::seconds(interval); | ||
} | ||
|
||
bool IsValid() const override; | ||
bool Execute() override; | ||
|
||
const std::string GetConfigName() const { return mConfigName; } | ||
const std::string GetCollectorName() const { return mCollectorName; } | ||
const QueueKey GetProcessQueueKey() const { return mProcessQueueKey; } | ||
int GetInputIndex() const { return mInputIdx; } | ||
const std::chrono::seconds GetInterval() const { return mInterval; } | ||
void ResetForNextExec() { SetExecTime(GetExecTime() + mInterval); } | ||
|
||
private: | ||
std::string mConfigName; | ||
std::string mCollectorName; | ||
QueueKey mProcessQueueKey; | ||
int mInputIdx; | ||
std::chrono::seconds mInterval; | ||
}; | ||
|
||
} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "EntityConstants.h" | ||
|
||
namespace logtail { | ||
|
||
const std::string DEFAULT_ENV_KEY_HOST_TYPE = "HOST_TYPE"; | ||
const std::string DEFAULT_ENV_VALUE_ECS = "ecs"; | ||
const std::string DEFAULT_ENV_VALUE_HOST = "host"; | ||
const std::string DEFAULT_CONTENT_KEY_ENTITY_TYPE = "__entity_type__"; | ||
const std::string DEFAULT_CONTENT_KEY_ENTITY_ID = "__entity_id__"; | ||
const std::string DEFAULT_CONTENT_KEY_DOMAIN = "__domain__"; | ||
const std::string DEFAULT_CONTENT_VALUE_DOMAIN_ACS = "acs"; | ||
const std::string DEFAULT_CONTENT_VALUE_DOMAIN_INFRA = "infra"; | ||
const std::string DEFAULT_CONTENT_KEY_FIRST_OBSERVED_TIME = "__first_observed_time__"; | ||
const std::string DEFAULT_CONTENT_KEY_LAST_OBSERVED_TIME = "__last_observed_time__"; | ||
const std::string DEFAULT_CONTENT_KEY_KEEP_ALIVE_SECONDS = "__keep_alive_seconds__"; | ||
const std::string DEFAULT_CONTENT_KEY_METHOD = "__method__"; | ||
const std::string DEFAULT_CONTENT_VALUE_METHOD_UPDATE = "update"; | ||
const std::string DEFAULT_CONTENT_VALUE_METHOD_EXPIRE = "expire"; | ||
|
||
// for process entity | ||
const std::string DEFAULT_CONTENT_VALUE_ENTITY_TYPE_PROCESS = "process"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_PID = "process_pid"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_PPID = "process_ppid"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_USER = "process_user"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_COMM = "process_comm"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_CREATE_TIME = "process_create_time"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_CWD = "process_cwd"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_BINARY = "process_binary"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_ARGUMENTS = "process_arguments"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_LANGUAGE = "process_language"; | ||
const std::string DEFAULT_CONTENT_KEY_PROCESS_CONTAINER_ID = "process_container_id"; | ||
} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <string> | ||
|
||
namespace logtail { | ||
|
||
extern const std::string DEFAULT_ENV_KEY_HOST_TYPE; | ||
extern const std::string DEFAULT_ENV_VALUE_ECS; | ||
extern const std::string DEFAULT_ENV_VALUE_HOST; | ||
extern const std::string DEFAULT_CONTENT_KEY_ENTITY_TYPE; | ||
extern const std::string DEFAULT_CONTENT_KEY_ENTITY_ID; | ||
extern const std::string DEFAULT_CONTENT_KEY_DOMAIN; | ||
extern const std::string DEFAULT_CONTENT_VALUE_DOMAIN_ACS; | ||
extern const std::string DEFAULT_CONTENT_VALUE_DOMAIN_INFRA; | ||
extern const std::string DEFAULT_CONTENT_KEY_FIRST_OBSERVED_TIME; | ||
extern const std::string DEFAULT_CONTENT_KEY_LAST_OBSERVED_TIME; | ||
extern const std::string DEFAULT_CONTENT_KEY_KEEP_ALIVE_SECONDS; | ||
extern const std::string DEFAULT_CONTENT_KEY_METHOD; | ||
extern const std::string DEFAULT_CONTENT_VALUE_METHOD_UPDATE; | ||
extern const std::string DEFAULT_CONTENT_VALUE_METHOD_EXPIRE; | ||
|
||
// for process entity | ||
extern const std::string DEFAULT_CONTENT_VALUE_ENTITY_TYPE_PROCESS; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_PID; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_PPID; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_USER; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_COMM; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_CREATE_TIME; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_CWD; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_BINARY; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_ARGUMENTS; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_LANGUAGE; | ||
extern const std::string DEFAULT_CONTENT_KEY_PROCESS_CONTAINER_ID; | ||
} // namespace logtail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 iLogtail Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "Constants.h" | ||
|
||
|
||
namespace logtail { | ||
|
||
#ifndef APSARA_UNIT_TEST_MAIN | ||
const bfs::path PROCESS_DIR = "/proc"; | ||
#else | ||
bfs::path PROCESS_DIR = "/proc"; | ||
#endif | ||
|
||
const bfs::path PROCESS_STAT = "stat"; | ||
|
||
} // namespace logtail |
Oops, something went wrong.