SNMP is a protocol to manage and monitor network devices. mrtg can capture the SNMP monitored data, analyze the data and generate the graphs. Previously, I used SNMP and mrtg to monitor my home server’s network traffic and CPU usage. However, mrtg is not quite powerful. RRDtool is a good substitution, but it’s very difficult to use. Therefore, I’m currently using cacti to help me to call RRDtool to generate the graphs. Cacti is actually a web based PHP software. So the installation path of cacti must be accessible by web server.

Environment: CentOS 5.3

Basic Setup:

Install some missing packages:
yum install intltool
yum install cairo-devel
yum install pango-devel
yum install net-snmp
yum install net-snmp-libs
yum install net-snmp-utils

Change some settings of snmpd:
vim /etc/snmp/snmpd.conf
Search:
com2sec notConfigUser default public
Replace:
com2sec notConfigUser 127.0.0.1 public

Give more permissions
Search:

view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1

Replace:
view systemview included .1.3.6.1.2.1
view systemview included .1.3.6.1.2.1.25.1.1

Search:
access notConfigGroup "" any noauth exact systemview none none
Replace:
access notConfigGroup "" any noauth exact all none none

Search:
#view all included .1 80
Replace (Remove comment):
view all included .1 80

Restart snmpd:
/etc/init.d/snmpd restart

turn on snmpd automatically when Linux starts:
ntsysv

Install RRDtool:
tar zxvf rrdtool-1.3.8.tar.gz
cd rrdtool-1.3.8
./configure --prefix=/usr/local/rrdtool
make
make install

Create cacti database:
mysql -u root -p
CREATE DATABASE cacti;
INSERT INTO mysql.user(Host,User,Password) VALUES ('localhost','cacti',password('cacti'));
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON cacti.* to cacti@localhost IDENTIFIED BY 'cacti';
\q

Install cacti:
tar zxvf cacti-0.8.7e.tar.gz
mv cacti-0.8.7e /home/admin/
/home/admin/cacti-0.8.7e /home/admin/cacti

Import cacti tables:
mysql -u cacti -pcacti cacti < /home/admin/cacti/cacti.sql

Edit cacti configurations:
vim /home/admin/cacti/include/config.php
Change to be like this:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";

Then, you can open your web browser to use cacti. Just simply follow the instruction to setup cacti. The following error may be shown as /usr/local/rrdtool/bin/rrdtool is not the default RRDTool installation path.

[NOT FOUND] RRDTool Binary Path: The path to the rrdtool binary.

Therefore, define the path of RRDTool installed previrously:
/usr/local/rrdtool/bin/rrdtool

The default username and password are admin

crontab configuration:
This step can update the cacti required information every five minutes.

Edit crontab file:
vim /etc/crontab
And add the following line at the end:
*/5 * * * * root /usr/local/php5/bin/php /home/admin/cacti/poller.php > /dev/null 2>&1
Where /usr/local/php5/bin/php is the binary execution of PHP.

More cacti configurations (monitoring network interface):
By default, cacti only shows the basic hardware configuration. But I also want it to display network interface information. Here is the configuration steps:

  1. Enable cacti SNMP v2 parsing:
    In my experience, it does not work when I choose default value "Not In use".
    Devices > [Description] > SNMP Version: Version 2
  2. Add Interface data source:
    Devices > [Description] > Data Source List (Top Right) > Add (Top Right)
    Choose:
    Selected Data Template: Interface - Traffic
    Host: [Description] 127.0.0.1
    click Create button.
  3. Select network interface:
    New Graphs > Select interface (e.g. eth0) > Create

Static graphs generation:
If you want to show this graphs to public without login. You can generation the static pages and graphs.

  1. Create a directory first (e.g. /home/admin/public)
  2. Login Cacti and goto Console. Click Settings under Configuration part.
  3. Click Graph Export
  4. Input an associated path (i.e. /home/admin/public) in Export Directory (both local and ftp) field
  5. The graphs will be generated every five minutes by default.

Integrated lm_sensors to show the graph of CPU temperature:
** Before doing this part, please ensure the sensors driver is installed and lm_sensors is properly configured.

In this example, cacti is installed in /home/admin/cacti.

  1. Download cacti-netsnmp-lmsensors.0.8.tar.gz and extract it:
    tar zxvf cacti-netsnmp-lmsensors.0.8.tar.gz
  2. Copy scripts/ss_netsnmp_lmsensors.php to the /home/admin/cacti/scripts/ directory.
  3. Copy the XML files in resource/0.8.7/ to the /home/admin/cacti/resource/script_server/ directory
  4. Login to Cacti console and click Import Templates from the menu
  5. Upload the associated XML file (i.e. netsnmp_lmsensors_thermal_data_query_template.xml) from the templates folder that is extracted previously
  6. Devices > [Description]. In Associated Data Queries tab, add ucd/net - lmSensors - Thermal Sensors. You may click Verbose Query to check whether the temperature data can be obtained.
  7. Click New Graphs in the left menu. You can focus on Data Query [ucd/net - lmSensors - Thermal Sensors] to select the sensors that you want to monitor.

However, I found that different sensors device may use different object identifier (OID) to identify the CPU temperature. So you may need to modify the $oid_array (about line 313) of ss_netsnmp_lmsensors.php. In my f71882fg sensors, the OID is:
"sensorIndex" => ".1.3.6.1.4.1.2021.13.16.5.1.1"
"sensorName" => ".1.3.6.1.4.1.2021.13.16.5.1.2"
"sensorReading" => ".1.3.6.1.4.1.2021.13.16.5.1.3"

Integrated hddtemp to show the graph of Harddisk temperature:
** Please be also reminded that hddtemp must be installed and the hddtemp daemon must be started as well.

In my example, I have two hard disks, and my cacti is installed in /home/admin/cacti. Here is the command to start hddtemp daemon with two hard disks:
/usr/sbin/hddtemp -d /dev/sda /dev/sdb

I recommend to add above line to /etc/rc.local. The daemon will automatically start when the Linux starts.

  1. Download cacti-linux-hddtemp-1.0.tar.gz and extract it:
    tar zxvf cacti-linux-hddtemp-1.0.tar.gz
  2. Copy hddtemp.php to the /home/admin/cacti/scripts/ directory.
  3. Copy hddtemp.xml to the /home/admin/cacti/resource/script_queries/ directory
  4. Login to Cacti console and click Import Templates from the left menu
  5. Upload the basic template XML file (i.e. cacti_template_linux_hddtemp_disk_temperature.xml). If you want grouping graph (e.g. monitoring two hard disks in the same graph), please also upload an related graph template
    (e.g. cacti_graph_template_linux_hddtemp_disk_temperature_2x.xml for two hard disks)
  6. Devices > [Description]. In Associated Data Queries tab, add Linux - hddtemp - disk temperature. You may click Verbose Query to check whether the temperature data can be obtained.
  7. Click New Graphs in the left menu. In the Graph Templates part, Create field, select Linux - hddtemp - disk temperature. In the Data Query [Linux - hddtemp - disk temperature] part, tick the check boxes of /dev/sda and /dev/sdb. Then you can click the Create button. If you don't want to change the title, just can Create button again.
  8. Click Graph Management in the left menu. Click [Description] - Disks temperature hyperlink which the associated template name is Linux - hddtemp - Disk temperature 2x. Select below matching:
    Disk 1: [Description] - Disks temperature /dev/sda
    Disk 2: [Description] - Disks temperature /dev/sdb
  9. In Graph Management page, you may delete the single-disk graphs, but you must select Leave the data sources untouched.
  10. Actually the setup should be done. But my graph only shows the second line. Therefore, I click Graph Templates > Linux - hddtemp - Disk temperature 2x. Click Item # 1 and Item # 5.
    For Item # 1:
    Data Source: Linux - hddtemp - Disk temperature - (temperature)
    Graph Item Type: Area
    For Item # 5:
    Data Source: Linux - hddtemp - Disk temperature - (temperature)
    Graph Item Type: Line1

    Going back to previous page (Linux - hddtemp - Disk temperature 2x), in Graph Item Inputs part, delete unnecessary items except Disk1 and Disk2, and set it to Disk 1 maps to Item1-4 and Disk 2 maps to Item5-8.

    Click Graph Management in the left menu, click [Description] Disks temperature and choose again Disk 1 and Disk 2. That's all!

References:
Linux Pilot 2009年7月號(Vol. 81)
Eric A. Hall - - Software Projects - - Cacti lmSensors/Net-SNMP Sensor Readings
hddtemp template for cacti

I previously introduced the way of blocking the ad pop up of Avira AntiVir Personal 8.0. However, this method can’t block the ad of version 9.0. Here is the solution:

I use Windows Vista Business to perform the following steps.

  1. Click Windows Icon (or Start) > Control Panel >Administrative Tools >Local Security Policy.
  2. After Local Security Policy MMC has opened, you can click Additional Rules under Software Restriction Policies.
  3. If you cannot find Additional Rules, you can right click Software Restriction Policies and click New Software Restriction Policies.
  4. Then, right click Additional Rules, and select New Path Rule. Then, you will see a new dialog box. Then, click Browse… to select C:\Program Files\Avira\AntiVir Desktop\avnotify.exe.
  5. Make sure the security level is set to Disallowed. Finally, you can click OK button.

I hope this screenshot would be helpful.

antivir

Yesterday, I wrote three very simple programs in different programming languages including C++, C# and Java. These programs will use trial division method to find 200000 prime numbers that is starting from 2 orderly. Then, the found prime numbers will store in an array. I found that C++ has the best performance, and the next are Java and C#. However, you don’t need to take the test seriously. I know this test can’t represent the whole performance of C++, C# and Java. And it ’s just for fun.

Compilers:

C++
MS 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80×86 and
MS Incremental Linker Version 9.00.30729.01
compilation command: cl /EHsc /Ox primeN.cpp

C#
MS Visual C# 2008 Compiler version 3.5.30729.1 (.NET Framework 3.5)
compilation command: csc primeN.cs

Java
Java SE Development Kit 6 Update 11
compilation command: javac primeN.java

Environments:

OS: Windows Vista Business SP1 (32bit)
CPU: AMD Athlon 64 x2 5400+
RAM: 4GB

Result:

cpp_cs_java

Download the source codes

WordPress 2.7 build-in revision feature to save all backup articles (or you may call posts). However, the backup articles almost will not be used and a lot of database storage is wasted. Therefore, I disabled revision feature in my blog. Here is the solution to turn this feature off.

  1. Edit wp-config.php that is saved in WordPress root directory.
  2. Add the following red statement at wp-config.php. It’s suggested to add the red statement at the last 2 line (before ?>).
    ...........
    require_once(ABSPATH . 'wp-settings.php');
    define('WP_POST_REVISIONS', false);
    ?>

If you have wrote many articles previously, I believe your database has already stored many unnecessary articles. To release the storage, it is suggested to remove the existing revision articles.

  1. Go to phpMyAdmin
  2. Click SQL button:
    phpmyadmin_sql
  3. Enter and submit the following SQL statements:
    DELETE FROM wp_posts WHERE post_type = "revision";
  4. Finally, phpMyAdmin will show you how many revision articles have been deleted:
    deleted
  5. If error occurs, you should substitute wp_ to the table prefix of your WordPress

Komodo Edit is a free and open source text editor. I like using Komodo Edit to develop my PHP programs, XHTML and JavaScript. If you hate remember functions name, variables name and functions parameter and so on, Komodo Edit is a good choice because it offers autocomplete feature. If you like Visual Studio, I believe you will enjoy Komodo Edit as well.

By the way, NetBeans also provides this feature. If you want to try alternative PHP Editor, NetBeans seems also a good choice.

Autocomplete:
komodoedit1

Call Tips:
komodoedit2

Links:
Komodo Edit homepage

Free online virus scan

February 14th, 2009

Virustotal
This website builds-in 39 anti-virus scanners to scan your uploaded file. A lot of popular anti-virus software is included in this online scanner such as Kaspersky, Symantec, McAfee.

Jotti’s malware scan
This website is good as well. 20 anti-virus scanners are included.

virus1