I’m using smokeping, i see a bunch of files that is no longer needed. To be safe, i want to rename find these files and rename them. I came with this solution find /var/lib/smokeping/rrd/ -name “*.rrd” -type f -mtime +30 -exec bash -c ‘mv $0 $(echo “$0” | sed -r “s|\.rrd|\.rrd\.old|g”)’ ‘{}’ \; The above command will find all files with ext .rrd and not modified in the last 30 days.Read More →

Add this line to your Dockerfile – in this example we change the timezone to America/New_York  RUN ln -snf /usr/share/zoneinfo/America/New_York /etc/localtime && echo “America/New_York” > /etc/timezoneRead More →

docker image ls docker run –d –name container_name image_name docker ps docker logs “container_id or container name” docker exec –it “container_id” /bin/bash docker top “container_id” docker logs –tail 50 –follow –timestamps containername docker run -it –entrypoint sh docker_image docker run -d \ –name graphite \ –restart=always \ -p 8080:80 \ -p 2003-2004:2003-2004 \ -p 2023-2024:2023-2024 \ -p 8125:8125/udp \ -p 8126:8126 \ -v /Data/graphite/conf:/opt/graphite/conf \ -v /Data/graphite/storage:/opt/graphite/storage \ -v /Data/statsd/config:/opt/statsd/config \ graphiteapp/graphite-statsdRead More →

Install Datadog agent DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=replace_with_your_key bash -c “$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)” Install PHP agent wget https://github.com/DataDog/dd-trace-php/releases/download/0.46.0/datadog-php-tracer_0.46.0_amd64.deb dpkg -i datadog-php-tracer_0.46.0_amd64.deb Optimize _generated.php in /opt/datadog-php/dd-trace-sources/bridge (see the other post) private static function initRootSpan(Tracer $tracer) { $options = array(‘start_time’ => Time::now()); if (‘cli’ === PHP_SAPI) { $operationName = isset($_SERVER[‘argv’][0]) ? basename($_SERVER[‘argv’][0]) : ‘cli.command’; $span = $tracer->startRootSpan($operationName, StartSpanOptions::create($options))->getSpan(); $span->setTag(Tag::SPAN_TYPE, Type::CLI); } else { $operationName = ‘web.request’; $span = $tracer->startRootSpan($operationName, StartSpanOptionsFactory::createForWebRequest($tracer, $options, Request::getHeaders()))->getSpan(); $span->setTag(Tag::SPAN_TYPE, Type::WEB_SERVLET); if (isset($_SERVER[‘REQUEST_METHOD’])) { $span->setTag(Tag::HTTP_METHOD, $_SERVER[‘REQUEST_METHOD’]); } if (isset($_SERVER[‘REQUEST_URI’])) { $span->setTag(Tag::HTTP_URL, $_SERVER[‘REQUEST_URI’]); } $span->setTag(Tag::HTTP_STATUS_CODE, 200); #================My Customize code if (isset($_SERVER[‘REMOTE_ADDR’])) { $span->setTag(“http.client_ip”, $_SERVER[‘REMOTE_ADDR’]); } if (isset($_SERVER[‘SCRIPT_NAME’])) { $span->setTag(“http.script_name”, $_SERVER[‘SCRIPT_NAME’]); } if (isset($_SERVER[‘HTTP_USER_AGENT’])) { $span->setTag(“http.user_agent”, $_SERVER[‘HTTP_USER_AGENT’]); } ifRead More →

Sometimes you are under a situation that you don’t know what’s going on with the server, it’s like a blackbox. How to get some lights in this? The answer is strace . strace is a utility that will help you see what your application is doing, what file it’s opening, what is it trying to do. How to start? the most common way to do is : you have a pid of your application , then just run this command: strace -p 100 How about other cases, like you have multiple process like web server, when a server start, it will start with at leastRead More →

As we all know, to monitor our PHP application performance with Datadog , we need to install 2 components – datadog-agent and its PHP package. The data-agent is a server listening on port 8126 to receive tracer/span from our application. The PHP package is used to inject some library to our run time PHP, it does some magic thing to collect our PHP application such as response time, database connection. Have you ever wondered what data that datadog tracing library send to its agent? Today we do a little trick , instead of using datadog-agent to receive data, we will use some tools to receiveRead More →

When i use Datadog to collect tracer/span in our PHP , i realize that Datadog library does not collect the client IP address. I don’t know what the reason behind this, but not having the client IP is very hard to troubleshoot the issue. After a while i figured out the way to hack the code. The hack is to modify this file /opt/datadog-php/dd-trace-sources/bridge/_generated.php This is my modification – check the line #================My Customize code private static function initRootSpan(Tracer $tracer) { $options = array(‘start_time’ => Time::now()); if (‘cli’ === PHP_SAPI) { $operationName = isset($_SERVER[‘argv’][0]) ? basename($_SERVER[‘argv’][0]) : ‘cli.command’; $span = $tracer->startRootSpan($operationName, StartSpanOptions::create($options))->getSpan(); $span->setTag(Tag::SPAN_TYPE, Type::CLI); }Read More →

My son was asking me to help him set up a server so that he can play with his friends – and i found this , easy to do. https://www.astralinternet.com/blog/en/build-minecraft-pocket-edition-server-ubuntu/ I turns out that this version does not work well with latest minecraft , i download the version from Minecraft official website, it works pretty well https://www.minecraft.net/en-us/download/server/bedrock/ After you download the server, just run this command: LD_LIBRARY_PATH=. ./bedrock_serverRead More →