# One-liners

====================================================================================

### Common Error/Limit identification 

\------------------------------------------------------------------------------------------------------------------------------------------------

#### Apache MaxRequestWorkers

```
grep -i 'MaxRequestWorkers' $(locate apache || locate httpd | grep -iE "error.log$")
```

<div _ngcontent-ng-c3315627782="" class="code-block ng-star-inserted" id="bkmrk-"><div _ngcontent-ng-c3315627782="" class="code-block-internal-container"></div></div>\------------------------------------------------------------------------------------------------------------------------------------------------

#### PHP Max\_Children

Check for all logged instances of max\_children limit being reached - prints each occurrence. Remember, max\_children being reached is usually the symptom of a larger issue - probably traffic.

```
grep -i max_children $(locate fpm | grep -iE "error.log$")  
```

Check for all instances of max\_children from today's date in the logs, and output as a count for each domains number of occurrences. (untested)

```
grep -i max_children $(locate fpm | grep -iE "error.log$") | grep -i "$(date +%d-%b)" | cut -d' ' -f5 | tr -d ']' | sort | uniq -c | sort -nr | awk 'BEGIN {print "Total PHP max_children errors on " strftime("%d-%b-%Y")}; {print $0}'
```

<div _ngcontent-ng-c1193751107="" class="code-block ng-star-inserted" id="bkmrk--1"><div _ngcontent-ng-c1193751107="" class="code-block-internal-container"></div></div>Check specific date's occurrences of PHP max\_children being reached (date needs updating to desired date.)

```
grep -i max_children $(locate fpm | grep -iE "error.log$") | grep -i '30-May' | cut -d' ' -f5 | tr -d ']' | sort | uniq -c | sort -nr | awk 'BEGIN {print "Total PHP max_children errors today"}; {print $0}' 
```

\------------------------------------------------------------------------------------------------------------------------------------------------

##### PHP Memory Limit

Search logs for instances of PHP memory\_limit being reached: (untested)

```
grep -i 'Fatal error: Allowed memory size of' $(find / -iname "*error.log")
```

or

```
grep -i  'Fatal error: Allowed memory size of' $(locate "*.ini")
```

Check domain PHP memory\_limit values:

```
grep -i 'memory_limit' $(find / -iname "*.ini")
```

or

```
grep -i 'memory_limit' $(locate "*.ini")
```

====================================================================================

#### Traffic Analysis

(File paths will need updating for these commands)

\------------------------------------------------------------------------------------------------------------------------------------------------

##### wp-login requests

```
grep -i 'wp-login' /path/to/access/log | cut -d ':' -f1 | sort | uniq -c
```

\------------------------------------------------------------------------------------------------------------------------------------------------

##### XML-RPC requests

```
grep -i 'xmlrpc' /path/to/access/log | cut -d ':' -f1 | sort | uniq -c
```

\------------------------------------------------------------------------------------------------------------------------------------------------

##### bot traffic user agents

```
 awk -F'"' '{print $6}' /var/www/vhosts/domain/logs/access_ssl_log | sort | uniq -c | sort -nr | head -20 | grep -iE 'bot|crawler'
```

====================================================================================

#### MySQL Tuner

```
wget -O mysqltuner.pl mysqltuner.pl && perl mysqltuner.pl
```

====================================================================================