Check These Out
Ever need to know why Apache is bogging down *right now*? Hate scanning Apache's Extended server-status for the longest running requests? Me, too. That's why I use this one liner to quickly find suspect web scripts that might need review.
Assuming the Extended server-status is reachable at the target URL desired, this one-liner parses the output through elinks (rendering the HTML) and shows a list of active requests sorted by longest running request at the bottom of the list. I include the following fields (as noted in the header line):
Seconds: How long the request is alive
PID: Process ID of the request handler
State: State of the request, limited to what I think are the relevant ones (GCRK_.)
IP: Remote Host IP making the request
Domain: Virtual Host target (HTTP/1.1 Host: header). Important for Virtual Hosting servers
TYPE: HTTP verb
URL: requested URL being served.
Putting this in a script that runs when triggered by high load average can be quite revealing. Can also capture "forgotten" scripts being exploited such as "formmail.pl", etc.
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
if you have problem threads problem in tomcat
This is useful if you have a program which doesn't work well with multicore CPUs. With taskset you can set its CPU affinity to run on only one core.
I have this on a daily cronjob to backup the commandlinefu.com database from NearlyFreeSpeech.net (awesome hosts by the way) to my local drive. Note that (on my Ubuntu system at least) you need to escape the % signs on the crontab.
This depends on 'stripansi' and 'urlencode' commands, which exist on my system as these aliases:
$ alias stripansi='perl -ple "s/\033\[(?:\d*(?:;\d+)*)*m//g;"'
$ alias urlencode='perl -MURI::Escape -ne "\$/=\"\"; print uri_escape \$_"'
The `open` command handles URLs on a Mac. Substitute the equivalent for your system (perhaps gnome-open).
I don't use system `mail`, so I have this aliased as `mail` and use it this way:
$ git show head | mail
Imagemagick library is used.
Using this command you can track a moment when usb device was attached.
Based on capsule8 agent examples, not rigorously tested