Getting your wordpress self hosted stats on your console with bash script update regularly.

Getting your wordpress self hosted stats on your console with bash script.

Some time back I wrote a blog on how to get your site stats using curl in bash shell. Today we will use the same script to get the stats every few seconds on the terminal on the same line, similar to progress meter.

Here is the script and the description:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash -
#===============================================================================
#
#          FILE:  update_stats.sh
#
#         USAGE:  ./update_stats.sh
#
#   DESCRIPTION:  Update the stats inline in shell every $1 seconds.
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:  <a class="zem_slink" title="Amit Agarwal" rel="homepage" href="http://amit-agarwal.co.in">Amit Agarwal</a> (AKA), amit.agarwal@amit-agarwal.co.in
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  06/21/2010 11:27:16 PM IST
#      REVISION:  ---
#===============================================================================

sleep_time=30 #the time to wait between stats collection
run_stats=get_stats  # the script to run to get the stats
filename=/tmp/statpress.html # the filename where the script is storing the html file of your statpress page.
eval $run_stats 2><a class="zem_slink freebase/en/dev_null" title="/dev/null" rel="wikipedia" href="http://en.wikipedia.org/wiki//dev/null">/dev/null</a>
while (true)
do
<!--loginview start-->values=$(cat $filename | w3m -dump -T <a class="zem_slink freebase/en/html" title="HTML" rel="wikipedia" href="http://en.wikipedia.org/wiki/HTML">text/html</a> |<a class="zem_slink freebase/en/grep" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep</a> "^Visitor\\|^Pageviews"|<a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk</a> \'{print $10}\'|tr  "\\n" " ")
time=$(date)
printf "$time --> $values \\r"<!--loginview end-->
sleep $sleep_time
done
\"Enhanced

Minimize the download size for updates.

Fedora has rolled out presto repositories. What this means to the users is that the download size for the updates would be greatly reduced. To use the feature, first install the yum plugin:

sudo yum install yum-presto.noarch

Presto uses delta rpms. These delta rpms are quite small in size (eg few kbs instead of 15 MB for firefox 3.5). These delta rpms are used to re-create the original rpm and this is completely transparent to the end user. So, next time when you update with the plugin installed you will see the difference in the download size.

Database of vulnurability at milw0rm.com – udpate and makeindex with cron.

I am quite regular visitor of milw0rm and generally try to keep up with the vul\’s. For doing this I wrote a small scripts rather set of scripts to keep myself update.  Here\’s what we are going to do:

1. Get the latest tar from the site.

2. Extract it.

3. Make the index

4. Have a shortcut to search the index.

Download the attached files for the first 2 points. makeindex-milw0rm and udpate-milw0rm

Now open the update-milw0rm file with the directory paths, that is located in the starting of the file.

Once that is done, do the following on the terminal,

crontab -e

Add a entry like this:

@daily /home/amit/update-milw0rm.sh

So you are all set to automatically download and update the data everyday. Lets now create a alias to search the exploitlist from the terminal.

Put the following in your profile :

alias search_sploit=\”cat $(cat ~/bin/update-milw0rm.sh|grep dir=|awk -F\’=\’ \'{print $2}\’|awk -F\’\”\’ \'{print $2}\’)/milw0rm/sploitlist.txt|grep -i\”

Now, when you want to search the database for the exploit you can simply type:

search_sploit <search term>