How to analyze Apache access.log with AWStats?

When i use VirtualSever in WanWang.com which provide the awstats report for administrator to help analyze the webserver`s visit status.In my case , I want a single static html file , easily to share 🙂

First of all .you must change you awstats.model.conf correctly!

In my case , i change this.

LogFormat=1
# i change to 4 default is 1

LogFile="/var/log/httpd/mylog.log"
# change the path to you access.log file full path!

Then you can run the command below to generate the html report file!

$ cd awstats-7.7\wwwroot\cgi-bin
$ perl awstats.pl -config=model -output -staticlink >> youserver.html

When you access.log file include long duration of year.you can use sed command to extract the line you want to analyze!

$ sed -n '[start line number],[end line number]p' access.log >> access_sed.log

Conclusion:

Some images in the static html can`t show , so i will figure it out later.

for more detail pls visit

https://www.awstats.org/

How to limit cpu usage with Nodejs?

I want to introduce the node-cpulimit in this post.When i use puppeteer ,some page cost a long time in page loading. At the same time , the cpu limit will increase instantly.So i want to find some tools to help limit the cpu usage.

A very simple example to use cpulimit and childprocess

const limiter = require('cpulimit');


// Run command
const { spawn } = require('child_process');
const node = spawn('node', ['/root/puppeteer.js']);



// Run cpulimit
const options = {
  limit: 50, // or any other value
  includeChildren: true,
  pid: node.pid
};

limiter.createProcessFamily(options, (err, processFamily) => {
  if (err) {
    console.error('Error:', err.message);
    return;
  }

  limiter.limit(processFamily, options, (err) => {
    if (err) {
      console.error('Error:', err.message);
    } else {
      console.log('Done.');
    }
  });
});

for more detail pls visit

https://github.com/vangelov/node-cpulimit