1
0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-11-26 13:14:31 +01:00

Merge branch 'master' of github.com:pavel-odintsov/fastnetmon

This commit is contained in:
Pavel Odintsov 2024-10-13 01:06:11 +03:00
commit a427d8b6f0
7 changed files with 38 additions and 45 deletions

@ -115,16 +115,30 @@ jobs:
command: "sudo docker exec -it linux_priviledged_container pbuilder --create --basetgz /data/debian_base.tgz --distribution << parameters.debian_codename >>"
- run: ls -la /data
- run: sudo docker exec -it linux_priviledged_container pbuilder --build --basetgz /data/debian_base.tgz --debbuildopts "-sa" /fastnetmon_$(sudo docker exec -it linux_priviledged_container head -n 1 fastnetmon-debian-salsa/debian/changelog|awk '{print $2}'|sed 's/[()]//g').dsc
build_docker_x86_64:
build_docker:
machine:
image: ubuntu-2204:current
steps:
- checkout
- run: docker build -t ghcr.io/pavel-odintsov/fastnetmon-community:<< pipeline.parameters.fastnetmon_build_version >> -t ghcr.io/pavel-odintsov/fastnetmon-community:latest - < src/Dockerfile
- run: sudo docker images
- run: echo $CR_PAT | sudo docker login ghcr.io -u pavel-odintsov --password-stdin
- run: sudo docker push ghcr.io/pavel-odintsov/fastnetmon-community:<< pipeline.parameters.fastnetmon_build_version >>
- run: sudo docker push ghcr.io/pavel-odintsov/fastnetmon-community:latest
- run:
name: Extract GitHub Username
command: |
GH_USERNAME=$(echo "<< pipeline.project.git_url >>" | sed -n 's#.*/\([^/]*\)/.*#\1#p')
echo "GitHub username is $GH_USERNAME"
echo "export GH_USERNAME=$GH_USERNAME" >> $BASH_ENV
- run:
name: Build Docker images
command: |
echo $CR_PAT | docker login ghcr.io -u $GH_USERNAME --password-stdin
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use
docker buildx inspect --bootstrap
docker buildx build \
--file src/Dockerfile \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/$GH_USERNAME/fastnetmon-community:<< pipeline.parameters.fastnetmon_build_version >> \
--tag ghcr.io/$GH_USERNAME/fastnetmon-community:latest \
--push .
build_gce:
machine:
# We use this image because it uses GCE instead of AWS for testing
@ -134,14 +148,6 @@ jobs:
resource_class: large
steps:
- checkout
build_docker_arm64:
machine:
image: ubuntu-2204:current
resource_class: arm.large
steps:
- checkout
- run: docker build --build-arg installer_file_name=installer_arm64 -t ghcr.io/pavel-odintsov/fastnetmon-community:1.2.3 -t ghcr.io/pavel-odintsov/fastnetmon-community:latest - < src/Dockerfile
- run: sudo docker images
build_fedora_upstream:
parameters:
docker_image:
@ -436,10 +442,8 @@ workflows:
distro_name: "debian"
resource_class: "arm.large"
debian_package_architecture: "arm64"
- build_docker_x86_64:
name: "Build Docker image on x86_64 platform"
# - build_docker_arm64:
# name: "Build Docker image on ARM64 platform"
- build_docker:
name: "Build Docker images"
- build_debian_upstream_package:
name: "Debian Sid Upstream Build"
debian_codename: "sid"

@ -1,11 +1,18 @@
FROM ubuntu:22.04
ARG installer_file_name=installer
FROM ubuntu:24.04
ENV CI=true
ARG TARGETPLATFORM
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget && wget https://install.fastnetmon.com/$installer_file_name -Oinstaller && chmod +x installer && ./installer -install_community_edition
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget
LABEL org.opencontainers.image.source https://github.com/pavel-odintsov/fastnetmon
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
wget https://install.fastnetmon.com/installer -O installer; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
wget https://install.fastnetmon.com/installer_arm64 -O installer; \
fi && \
chmod +x installer && \
./installer -install_community_edition
CMD /opt/fastnetmon/fastnetmon
LABEL org.opencontainers.image.source=https://github.com/pavel-odintsov/fastnetmon
CMD ["/opt/fastnetmon-community/app/bin/fastnetmon"]

@ -146,7 +146,7 @@ std::string get_net_address_from_network_as_string(std::string network_cidr_form
split(subnet_as_string, network_cidr_format, boost::is_any_of("/"), boost::token_compress_on);
if (subnet_as_string.size() != 2) {
return 0;
return std::string();
}
return subnet_as_string[0];

@ -464,10 +464,6 @@ void free_up_all_resources();
void interruption_signal_handler(int signal_number);
#ifdef FASTNETMON_API
void silent_logging_function(gpr_log_func_args* args) {
// We do not want any logging here
}
// We could not define this variable in top of the file because we should define class before
FastnetmonApiServiceImpl api_service;
@ -1864,10 +1860,6 @@ int main(int argc, char** argv) {
std::filesystem::remove(fastnetmon_platform_configuration.backtrace_path);
}
#ifdef FASTNETMON_API
gpr_set_log_function(silent_logging_function);
#endif
// Set default ban configuration
init_global_ban_settings();

@ -90,10 +90,6 @@ class FastnetmonClient {
std::unique_ptr<Fastnetmon::Stub> stub_;
};
void silent_logging_function(gpr_log_func_args* args) {
// We do not want any logging here
}
int main(int argc, char** argv) {
std::string supported_commands_list = "ban, unban, get_banlist";
@ -102,8 +98,6 @@ int main(int argc, char** argv) {
return 1;
}
gpr_set_log_function(silent_logging_function);
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated

@ -213,8 +213,6 @@ void increment_clickhouse_per_protocol_counters(PerProtocolMetrics& metrics, con
// Populates Clickhouse host counters using speed_element
void increment_clickhouse_host_counters(ClickhouseHostMetrics& metrics, const subnet_counter_t& current_speed_element) {
std::vector<direction_t> processed_directions = { INCOMING, OUTGOING };
metrics.packets_incoming->Append(current_speed_element.total.in_packets);
metrics.bits_incoming->Append(current_speed_element.total.in_bytes * 8);
metrics.flows_incoming->Append(current_speed_element.in_flows);
@ -496,8 +494,6 @@ template <typename T, typename C>
(std::is_same_v<C, subnet_counter_t>)bool push_hosts_traffic_counters_to_clickhouse(clickhouse::Client* clickhouse_metrics_client,
abstract_subnet_counters_t<T, C>& host_counters,
const std::string& table_name) {
std::vector<direction_t> processed_directions = { INCOMING, OUTGOING };
clickhouse::Block block;
ClickhouseHostMetrics metrics;

@ -214,6 +214,6 @@ void graphite_push_thread() {
logger << log4cpp::Priority::DEBUG << "Graphite data pushed in: " << graphite_thread_execution_time.tv_sec
<< " sec " << graphite_thread_execution_time.tv_usec << " microseconds\n";
boost::this_thread::sleep(boost::posix_time::seconds(fastnetmon_global_configuration.clickhouse_metrics_push_period));
boost::this_thread::sleep(boost::posix_time::seconds(fastnetmon_global_configuration.graphite_push_period));
}
}