Server Solutions
Dedicated Server Rental Meet your physical server needs with dedicated server rental Explore Now
Virtual Servers Scalable, high-availability server rental services with our high-performance cloud server solutions. Explore Now
İlkbyte Cloud Fully developed by Netinternet, flexible and scalable cloud servers with cloud technology Explore Now
GPU-Based AI Infrastructure High-performance GPU solutions created on a project basis for your AI and machine learning projects Explore Now
Server & Hardware Procurement Server and hardware procurement services with equipment suitable for your projects Explore Now
Customized Infrastructure Solutions Custom-designed infrastructure solutions and technical consulting services for your unique needs Explore Now
Hosting Services
Cabinet Rental Dedicated 15U, 24U and 48U smart cabinet systems allocated for you Explore Now
Server Colocation Individual server hosting service in shared cabinet systems Explore Now
Premium Connectivity Fast and reliable internet access with multi-carrier, multi-IXP and high-capacity Anti-DDoS protection Explore Now
Telecom Data Center Circuit Low-cost and high-performance internet access through a dedicated data center tariff Explore Now
Cross-Connect Direct connection between network carriers with low latency and high performance Explore Now
IP Address Pricing IP address and ASN rental services with RIPE LIR management services Explore Now
Managed Services
Managed Server Installation, configuration, regular maintenance, updates and 24/7 monitoring of your server operating system Explore Now
Managed Infrastructure End-to-end management of your entire IT infrastructure including data center, storage, virtualization and backup Explore Now
Managed Network Professional management and monitoring of network devices (router, switch, firewall) configuration, optimization and performance Explore Now
Managed Cloud (Public / Private) Professional management of your public and private cloud infrastructures to meet your cloud needs Explore Now
Managed Security 24/7 monitoring, analysis and response services against cyber security threats Explore Now
Managed Backup & Disaster Recovery Backup and disaster recovery plans, implementation, operation to ensure your data security and business continuity Explore Now
License Rental
cPanel Licenses cPanel software license rental solutions Explore Now
Plesk Licenses Plesk software license rental solutions Explore Now
DirectAdmin Licenses DirectAdmin software license rental solutions Explore Now
LiteSpeed Licenses LiteSpeed software license rental solutions Explore Now
CloudLinux Licenses CloudLinux software license rental solutions Explore Now
Cyber Security
HEIMWALL Fully developed by Netinternet, protect against cyber attacks with our Web Application Firewall solution Explore Now →
AntiDDoS High-capacity volumetric Anti-DDoS protection provided free by default on all our services Explore Now →
VPN Solutions Secure, encrypted tunnel connections for your remote offices and employees with our managed VPN solutions Explore Now →
Layer4 Stateless Firewall Layer4 stateless firewall solution for filtering and directing incoming traffic Explore Now →
SSL Certificates Secure connection solutions with free and paid SSL/TLS certificate options Explore Now →
Penetration Tests Penetration tests performed by third parties in cooperation with TSE-approved testing firms Explore Now →
Corporate Email
Corporate Email Solutions Fully domestic, KVKK compliant, 100% compatible with Outlook and all mail programs, professional, uninterrupted email service Explore Now →
Bulk Email Sending Manageable bulk email sending services with high delivery rates for your marketing campaigns Explore Now →
Email Archiving Secure archiving of all your email traffic to protect corporate memory and comply with legal requirements Explore Now →
Free Email Migration Service Wherever your email service is, we migrate you to Netinternet corporate email solution for free! Explore Now →
Traditional Web Hosting
cPanel Web Hosting Fast and reliable hosting packages with easy setup and management using cPanel, the world's most popular hosting management panel. Explore Now →
cPanel Reseller Hosting Fully customizable cPanel-based reseller hosting solution for starting your own hosting business Explore Now →
DirectAdmin Reseller Hosting Scalable and cost-effective reseller hosting powered by lightweight DirectAdmin control panel Explore Now →
Free Hosting Migration Service Professional migration services to move your existing systems to Netinternet data center infrastructure Explore Now →
Domain Names
Domain Registration Services Domain registration and easy management at the most affordable prices in all popular extensions (.com, .net, .org, etc.) Explore Now →
Domain Transfer Services Transfer your domains to Netinternet for professional domain management services Explore Now →
Domain Reseller Flexible and reliable reseller program and integration services for offering domain registration to your customers Explore Now →
Free Hosting with Domain Free hosting service for domains registered or transferred to Netinternet Explore Now →
Hosting & Cloud Service Providers High-density infrastructures, multi-tenant architectures and SLA-focused sustainable data center solutions for hosting and cloud providers Explore Now →
E-Commerce Companies High-performance, secure and uninterrupted e-commerce infrastructures resilient to sudden traffic surges during campaign periods Explore Now →
Software Developers Developer-friendly infrastructure solutions with CI/CD compatible, API-supported, automation-ready flexible resource management Explore Now →
SaaS Providers Scalable, high-availability and continuity-focused cloud infrastructures suitable for SaaS architectures serving many users. Explore Now →
AI & R&D GPU-based high-performance and scalable infrastructures for big data processing, model training and high computation tasks Explore Now →
Agencies & Marketing Multi-client management compatible, quick setup, high-performance and flexible web hosting infrastructures Explore Now →
Media & Broadcasting High bandwidth and low latency infrastructure solutions for live streaming, video and heavy content traffic Explore Now →
Banks & Fintech Regulation-compliant, Tier-3/Tier-4 standard, highly secure financial infrastructures ensuring uninterrupted service Explore Now →
Government & Education Long-term, sustainable and secure infrastructure solutions compliant with regulations and data security requirements Explore Now →
Manufacturing / Industry Low-latency and high-availability infrastructure solutions compatible with Industry 4.0, IoT and production automation systems Explore Now →
Healthcare Organizations Highly secure and uninterrupted health informatics infrastructures prioritizing patient data privacy and continuity Explore Now →
HEIMWALL – Web Application Firewall Protect your web applications against advanced attacks with our 100% domestic WAF platform HEIMWALL Explore Now →
Ilkbyte - Cloud Server Service Scalable and high-performance cloud servers deployable in seconds with our domestically developed orchestration infrastructure Explore Now →
Netrafix - Bandwidth Monitoring Manage 5651 compliant logging and bandwidth billing (Burst, Traffic Quota, 95th Percentile) in one platform with sFlow, NetFlow and IPFIX supported Netrafix Explore Now →
Secure Internet - For ISPs Keep your DNS traffic in your own network with 100% domestic DNS software developed for authorized ISPs Explore Now →
DirectIP - IP Management System 100% domestic IP management platform developed by Netinternet for centralized IP address, subnet, VLAN and DHCP management Explore Now →
RuleDNS - Rule-Based DNS Management Dynamically manage DNS responses with rule-based RuleDNS, easily integrate CDN and services with API support Explore Now →
Documents / Whitepapers Developer-focused technical documentation covering all API endpoints, usage scenarios and automation examples Explore Now →
API Documentation Developer-focused technical documentation covering API endpoints, usage scenarios and automation examples for platform integration Explore Now →
Peering Policies Reference policies transparently explaining our network architecture, traffic exchange principles and peering criteria Explore Now →
Frequently Asked Technical Questions Clear and actionable answers to the most frequently asked technical questions about infrastructure, security and operations Explore Now →
System Status Status page transparently sharing real-time status, planned maintenance and past outages of all platforms and services Explore Now →
Our Physical Data Center
Our Physical Data Center Our corporate data center facility designed with high security standards and redundant power and cooling infrastructure Explore Now →
Power, Cooling, Security Facility architecture designed for critical infrastructures with redundant power lines, climate systems and multi-layered physical security Explore Now →
Internet Access Points Low-latency and high-availability backbone connections through multiple operators and internet exchange points Explore Now →
Network Infrastructure
Network Infrastructure Uninterrupted connectivity infrastructure with multi-carrier connections, redundant backbone and high-capacity network architecture Explore Now →
Network Policies Sustainable network operation policies with transparently defined rules for traffic management, peering, security and capacity usage Explore Now →
Planning and Processes Scalable and controlled network management approach with pre-designed network capacity planning, growth scenarios and operational processes Explore Now →
Certificates and Documents
Our Certifications We provide auditable and sustainable infrastructure standards with our certifications for information security and service continuity Explore Now →
Security Policy We ensure protection of infrastructure and data with our security policies covering information security, access control and risk management Explore Now →
KVKK Compliance Data processing and storage structure compliant with KVKK and related regulations with defined technical and administrative measures for personal data protection. Explore Now →
Quality Policy Our quality management policies within the scope of ISO 9001 for continuous improvement of service quality. Explore Now →
Service Management Policy Our policies and standards governing IT service management processes within the scope of ISO/IEC 20000-1. Explore Now →
Business Continuity Policy Our ISO 22301 compliant policies and procedures ensuring business continuity against possible outage scenarios. Explore Now →
Incident Management Policy Our incident management processes and action plans for the detection, response and resolution of security incidents. Explore Now →
Supplier Security Policy Our policy governing information security requirements and risk assessment processes in supplier relationships. Explore Now →
Disclosure Text Text prepared within the scope of our disclosure obligation regarding the processing of your personal data under KVKK. Explore Now →
Cookie Policy Our policy regarding cookies and data collection practices used on our website. Explore Now →
Hosting Provider and Legal Obligation Policy Legal obligations we fulfill as a hosting provider under Law No. 5651. Explore Now →
Blog Posts Technical analyses, sector evaluations and current content about data center, network, cyber security and cloud technologies Explore Now →
Case Studies Reference case studies describing needs encountered, solutions applied and outcomes achieved in real projects Explore Now →
Events and Announcements Events we attend and organize, technical meetings, launches and current announcements about Netinternet Explore Now →
Back to Blog

Log Archiving Compliant with Law No. 5651 on cPanel Servers

Abdullah
Abdullah Altunbaş
Author
15.04.2022
1877 views

With the new regulation, the obligation imposed on hosting providers under Law No. 5651 to store site access logs for at least six months is being extended to at least one year, with fines of up to 100,000 TL in case of non-compliance. Unfortunately, archiving access logs is a tedious and costly process. If we take commonly used control panels as an example, cPanel and all other hosting software process access records to generate a series of statistical data in the panel and then delete them to save space. The log archiving process must be done without disrupting control panel functions and without any gaps. In this article, we will share with you the cPanel access log archiving system produced by our R&D team.


One of the best methods for getting cPanel logs in a more organized and desired format is cPanel hooks. These hooks allow us to perform desired operations before, after, or during certain cPanel operations.


Functions related to cPanel logs are grouped under Stats Functions. These functions consist of 4 main functions: RunAll(pre/post) and RunUser(pre/post).


RunUser: The hook you define with RunUser will run for each user with user-level permissions. The hook specified with RunUser is called separately for each user. cPanel sends information about the current process in JSON format via stdin when calling the hook file.


RunAll: A hook can be defined to run after all user stats operations are completed with RunUser. cPanel does not send any data when calling this hook function.


Hooks can be written in many languages, but let’s create a backup hook in Perl based on the examples cPanel provides us.


mkdir /usr/local/cpanel/Netinternet
touch /usr/local/cpanel/Netinternet/NetinternetBackup.pm

Create a simple Perl module with the describe method required by cPanel hooks:


package Netinternet::NetinternetBackup;
use strict;
use warnings;

sub describe {
my $hooks = [
{
‘namespace’ => ‘Stats’,
‘function’ => ‘RunUser’,
‘hook’ => ‘Netinternet::NetinternetBackup::copy_logfiles’,
‘stage’ => ‘pre’,
},
];
return $hooks;
}

sub copy_logfiles {
return 1;
}

1;


The final version of our script:


package Netinternet::NetinternetBackup;
use File::Copy;
use File::Path;
use strict;
use warnings;
use POSIX;
sub describe {
my $hooks = [
{
‘namespace’ => ‘Stats’,
‘function’ => ‘RunUser’,
‘hook’ => ‘Netinternet::NetinternetBackup::copy_logfiles’,
‘stage’ => ‘pre’,
},
];
return $hooks;
}

sub copylogfiles {
my $year = POSIX::strftime(‘%Y’, localtime());
my $mon = POSIX::strftime(‘%m’, localtime());
my $mday = POSIX::strftime(‘%d’, localtime());
my ( $context, $args ) = @
;
my $user = $args->{‘user’};
foreach my $log_ref ( @{ $args->{‘logfiledesc’} } ) {
my $access_log = $log_ref->{‘logfile’};
my $backup_location = “/backup/$user/$year/$mon/$mday/” . $log_ref->{‘domain’} . ‘.’ . time();
if ( !-e “/backup/$user/$year/$mon/$mday” ) {
mkpath(“/backup/$user/$year/$mon/$mday/”);
}
print “Backing up ” . $log_ref->{‘domain’} . “ domain to: $backup_location
”;
File::Copy::copy( $access_log, $backup_location ) || print STDERR $! . “
”;
}
return 1;
}

1;


To register the module with cPanel:


/usr/local/cpanel/bin/manage_hooks add module Netinternet::NetinternetBackup

As a result of these operations, while statistical data is being generated for each cPanel user, a copy of the logs will be copied to the specified directory. You can also add a compression function while copying logs, but keep in mind that this may extend the processing time. At Netinternet, we perform compression operations after obtaining the logs in raw form. Since access files are text files, tools like gunzip can compress them by up to 90%.

Abdullah

Abdullah Altunbaş

Content Writer

Netinternet Bilişim Teknolojileri A.Ş.'de teknik konularda liderlik yapıyorum. 15 yıldır bu alanda çalışıyorum ve özellikle sistem yönetimi, ağ teknolojileri ve yazılım geliştirme konularına odaklanıyorum.

Comments

4
66
Barış
19.02.2014, 12:02

<p>Haftalardır bomboş klasör hook olarak eklendi sorun ne olabilir?</p>

84
Timur
19.02.2014, 12:02

<p>çok teşekkürler,</p><p> my $backup_location = "/usr/local/cpanel/netinternet/yedek/$user/$year/$mon/$mday/" . $log_ref-&gt;{'domain'} . '.' . time();</p><p> if ( !-e "/yedek/$user/$year/$mon/$mday" ) {</p><p> mkpath("/usr/local/cpanel/netinternet/yedek/$user/$year/$mon/$mday/", 0777);</p><p>netinternet klasörüne ve yedek klasörüne 0777 yazma izni vererek düzelttim.</p><p>Bu mevzudaki (5651) düşüncem ise:<br>Anladığım kadarıyla Linux sunuculardaki loglama sistemi için tib bir format düşünmemiş. Mevcut log sistemini windows sunuculardaki şekliyle yapmak istesek manuel bir yapı ile düzenleme yapmak gerekiyor. Yanlış anlamadıysam TİB, kullanıcının ip adresini, server'a girdiği çıktığı zamanı ve MAC adresininin loglamasını istiyor. Bunun bu şekilde olması CPanel kullanıcıları için şu an için zor gibi gözüküyor. Birde biz bu logları arzu edilen formata çevirsek bile güvenirliğinin elle değiştirilebilinir olduğu gerçeği unutulmuş gibi:). sonuç olarak bu logların tutulmasına eyvallah ama sistemin bacaklarının linux'u unutması bir format belirlenmemesi ilginç. Logların imzalanması güzel fikir fakat Loglar'ın makine ile eş zamanlı olmadan imzalanması gibi bir durum sözkonusu gliba bu ilginç bir çıkmaz. Allah kolaylık versin :) ilginize teşekkür ederim.</p>

72
Hakan ERSU
19.02.2014, 12:02

<p>Dediğiniz gibi belirli bir format istenmemiş ki açıkcası belirli bir format istenmesi durumunda ortaya tahmin edilemez birçok problem çıkacaktır.Sonuç olarak herkes apache veya nginx tabanlı bir sistem kullanmamakta.Durum başlı başına sıkıntılı bir süreç ve bu yasa için pek de üzerinde oturulup düşünüldüğünü sanmıyorum.</p><p>Bu konularda söyleycek çok sözüm olsada maalesef burada paylaşmam mümkün değil :)</p><p>Bu arada logların yollarını değiştirin.<br>if ile kontrol edilen ve içerisinde oluşturulan dizinin aynı dizin olmasına dikkat edin.Ben bu örnekte /yedek yani ana dizin içerisindeki yedek klasörünü kullandım ama siz /usr/local/cpanel/ dizini içerisinde klasörleri oluşturmaktasınız.Cpanel dosyaları içerisinde yedekleri tutmayın ve tahmin edilemez yollar kullanmayı deneyin.Örnek olarak bir yapılandırma daha ekliyorum ;</p><p>my $backup_location = "/var/log/yedek/$user/$year/$mon/$mday/" . $log_ref-&gt;{'domain'} . '.' . time();</p><p>if ( !-e "/var/log/yedek/$user/$year/$mon/$mday" ) {</p><p> mkpath("/var/log/yedek/$user/$year/$mon/$mday/");</p><p>}</p>

195
Çağrı
19.02.2014, 12:02

<p>Teşekkürler çok faydalı bir makale olmuş. Logları sıkıştırma işlemini nasıl yaptığınızıda açıklayabilir misiniz ?</p>

Leave a Comment

* Your comment will be published after approval.