logIt Log Around The Clock

application ARMv6 ARMv7 BeagleBoard certificate daemon device driver DNS embedded system emulator file system fuse GPIO image install-deinstall java java GUI job automation kernel local bin make-install managed node monitoring motif GUI OMAP3 OOP OSS OVCoreID php proxy python Raspberry Pi rootfs security shell script snmp socialmedia squid startup tagging template USB web-based wordpress Zabbix

Running Raddle in RHEL

Raddle is a great SNMP player written in Perl. I say player to this emulator application, meaning that I can append or dump snmpwalk output from a device and then replay that from Raddle. Installing it can be both simple and tedious tasks. I used Red Hat Enterprise Linux 5.2 inside a virtual machine (VirtualBox) to make it compact without interfering my own host snmpd setting.

net-SNMP packages are required for Raddle to work on top of primarily snmpd.

yum install net-snmp net-snmp-utils

Prior to installation some rpm packages must be downloaded separately as my local repo (created from original RHEL CD images) may not contain them. They are installed as follow:

rpm -i perl-Carp-Clan-6.00-1.el4.rf.noarch.rpm
rpm -i perl-Bit-Vector-6.4-2.el5.rf.i386.rpm
rpm -i perl-Crypt-DES-2.05-3.2.el5.rf.i386.rpm
rpm -i perl-Digest-SHA1-2.11-1.el5.rf.i386.rpm
rpm -i perl-Digest-HMAC-1.01-2.2.el5.rf.noarch.rpm
rpm -i perl-Socket6-0.20-1.el5.rf.i386.rpm
rpm -i perl-Net-SNMP-5.2.0-1.2.el5.rf.noarch.rpm
rpm -i perl-Date-Pcalc-1.2-1.2.el5.rf.noarch.rpm
rpm -i perl-Date-Calc-5.4-1.el5.rf.i386.rpm

continued by installing net-snmp-perl from original repo

yum install net-snmp-perl

Uncompressing Raddle and successful make test will mean installation is good and can be finished by make install

cd Net-Raddle-0.08
perl Makefile.PL
make test
make install

Replaying SNMP Packets

The idea is to run snmpd which replays a specific prepared-SNMP-packets instead of our own real time system SNMP data (in this case the condition of RHEL 5.2 host). There are three files to do that, let’s name them r1.*:

  1. r1.snmp
    A capture from i.e.
    snmpwalk -v 1 -c <community string> -OneU <device> > r1.snmp
  2. r1.conf
    snmpd will run this instead of the original OS default:
    snmpd -C -I vacm_vars -c /usr/local/etc/snmp-emulator/r1.conf
  3. r1.pl
    the perl script where the most basic is to just replay the above r1.snmp

An official documentation to replay SNMP can be found here. I got hold back when trying to listen from other host, it turns out that I must remove the localhost section in r1.conf which will make it to use standard port 161 as well

# Listen on port 9501
#agentaddress    udp:localhost:9501,tcp:localhost:9501

It is also wise to always cut the r1.snmp first to see if the perl works (test with perl -w /usr/local/etc/snmp-emulator/r1.pl) either with warning or clean, meaning no problem with just some of the OIDs found inside the file.

URL Shortener From Yourls (1)

We can self-hosted URL Shortener service. I tried open source php-based URLShort and Yourls. I later choose Yourls.

Both of course based on .htaccess manipulation (mod_rewrite of Apache must be enabled). I install Yourls in side http://my.web/somedir. To make my short URL to use something like http://my.web/xGf12 instead of http://my.web/somedir/xGf12, I run the regular install with that somedir as based URL, but then create .htaccess in http://my.web/.htaccess (instead of http://my.web/somedir/.htaccess) However, I intend to use prefix x for the shorten URL. Here is how the regular expression implemented:

# BEGIN YOURLS
 
RewriteEngine On
RewriteBase /somedir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(x[0-9A-Za-z]+)/?$ /somedir/yourls-go.php?id=$1 [L]
RewriteRule ^(x[0-9A-Za-z]+)\+/?$ /somedir/yourls-infos.php?id=$1 [L]
RewriteRule ^(x[0-9A-Za-z]+)\+all/?$ /somedir/yourls-infos.php?id=$1&amp;all=1 [L]
 
# END YOURLS

Tagsistant On Production (2)

I’ve been waiting for someone to release a special-GUI-file manager to support Tagsistant. I decided not to wait and try out existing straightforward implementation (see previous post). I create a directory named tags inside my home and add an item on desktop session startup in System > Preferences > Startup Apllications containing this command

tagsistant -o allow_other -o umask=0022 -o uid=1000 --repository=~/.tagsistant ~/tags

Prior to that, I change owner  from root to me on

$ ls -l /etc/fuse.conf
 
-rw-r----- 1 arif arif 215 2010-02-09 11:20 /etc/fuse.conf

and uncomment the user_allow_other of that config.

Running Tagsistant will add this mount

$ mount
...
gvfs-fuse-daemon on /home/arif/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=arif)
tagsistant on /home/arif/tags type fuse (rw,nosuid,nodev,allow_other,user=arif)
 
$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on...
tagsistant           123593820  91720380  25595240  79% /home/arif/tags

Original file storage in this config is in ~/.tagsistant/archive/ and tagging structure in SQLite format is kept in ~/.tagsistant/tags.sql.

Serious Performance Drawback

I can use Nautilus or Krusader (basically any file browser) to access the tagged files but performance really drops when tags.sql reaches some 160MB. I don’t have time to look further and skip the chance to use it any longer in “production”.

Embed Tag Cloud (In Other Than Sidebar)

I try to embed WordPress tag cloud to the header part of the theme. Tag print is called from wp_tag_cloud('smallest=8&largest=16'). One example would be by inserting that function in this part of header.php of the corresponding theme:

1
2
3
4
5
6
7
8
9
10
	<div class="header">
        	< ?php if (is_home()) : ?>
        		<h1>< ?php bloginfo('name'); ?>
				<span>< ?php bloginfo('description'); ?></span></h1>
				< ?php wp_tag_cloud('smallest=8&largest=16'); ?>
        	< ?php else : ?>
		        <h1><a href="<?php echo get_settings('home'); ?>/">< ?php bloginfo('name'); ?></a>
				<span>< ?php bloginfo('description'); ?></span></h1>
	        < ?php endif; ?>
	</div>

Another embedding option is to use the famous wp-cumulus plugin.
Continue reading “Embed Tag Cloud (In Other Than Sidebar)” »

Template Dumping Scripts

To manage multiple templates in HP OMU, we need to dump them first. Dumping to file using opctempl will ease up the process of narrowing variation to gain uniformity. In the end converging to standard will help us tackle problems when faced with hundreds of templates being assigned to hundreds nodes.

I tried to make several scripts. Some were in conjunction used with another, some could be used individually. The problem is, they were made long ago without proper documentation, so I try to relate them first before building new ones to see if they’re still usable (at least in their conceptual work flow).

Get the Flash Player to see this player.

Continue reading “Template Dumping Scripts” »

Write WordPress Plugins to Play Freemind Mind-Map File

The first version main goal is to embed the *.mm file which is a Freemind file. I found similarity of embedding this kind of file in flash-video-player plugins (I used version 3.1.8). So, I tried to reverse engineer by mind-mapping how it works first and how to hook plugins to WordPress. Here is version 1.1 of the fremind-wp-browser. The final mind-map and plugin in-use in this post looks crowded, but you can find highlighted pointers below the mind-map.

Get the Flash Player to see this player.

Embedding with SWFObject

The *.mm file is projected over visorFreemind.swf player with the help of javascript.

Using javascript from SWFObject, the idea of flash embedding is to create an SWFObject and then write() that inside certain part of page body, i.e. div.

<script type="text/javascript"> 
   var s0 = new SWFObject("visorFreemind.swf","n0","800","400","7");
   s0.write("video0") ;
</script>

Parsing a Post

In general, the plugins will parse a post content to find [freemind file="path-to.mm" /] shortcode that will finally be replaced by the above javascript with respect to *.mm file that will be played over visorFreemind.swf.

Hooking the Plugins to WordPress

The above javascript needs to be loaded in every head part of each WordPress page, this action will call a function that will insert that script

163
add_action('wp_head', 'FreemindMap_head');

Hence, we get

<script type="text/javascript" src="http://lakm.us/logit/wp-content/plugins/freemind-wp-browser/swfobject.js"></script>

on the header source of every page.

To deal with content parsing looking for the shortcode, add the following filter

166
add_filter('the_content', 'FreemindMap_Parse');

Activation/deactivation of the plugin is via the hook registration where it also create an option panel when activated by adding

99
add_options_page('Freemind Options', 'Freemind', '8', 'freemind-wp-browser.php', 'FreemindOptions');

This initial version has limited options though; enough to set the width and height of the mind-map projection.

Install Nagios 3 and Plugins

Quickstart

I decided to install in RedHat 5.2. Maybe it is easier in Ubuntu (Nagios 3 already listed in the repository, but I haven’t tried it). As pointed out by the quickstart (it is meant for Fedora by the way), requirements are:

  1. php, httpd
  2. gcc, glibc, glibc-common
  3. gd, gd-devel

After getting those, the configure-make-install procedure runs well, except that I don’t check the warnings. It turns out that only some of Nagios core components are installed. It can be seen from the content of /usr/local/nagios/libexec directory. There is no check_snmp etc. Error also appears in statusmap page of Nagios.

Compile More Nagios Core Components

I run through ./configure once more, check out all warnings, and begin to evaluate requirements (found this text inside nagios-plugins-1.4.14 tarball)

MySQL

For check_mysql functionality, mysql (MySQL client for linux) must be installed. ./configure also test this client, by default config, to the local MySQL socket, hence mysql-server must also exist.

Radius Client

Client from freeradius package doesn’t meet Nagios requirements. It must be the ones from original radiusclient, I found RPMs for radiusclient-0.3.2-0.2.el5.rf.i386.rpm and radiusclient-devel-0.3.2-0.2.el5.rf.i386.rpm.

GD

It is quite tricky to get statusmap.c to be compiled for the .cgi of Nagios status map. Compilation needs gd library from http://www.libgd.org/gd requires zlib, libjpeg, and libpng. On first attempt, I installed from RPMs. This appeared to be not working as I could still see warnings about gd2 during ./configure.

So, I choose to compile from the source gd-2.0.33.tar.bz2. This tarball was found in the older section of current gd2 web. I chose this version because the RPM used was gd-2.0.33-9.4.el5_1.1.rpm. I removed this RPM first which made me to remove also libmwf and ImageMagick.

After straightforward  configure-make-install the library will be installed under /usr/local/lib i.e libgd.so.2.0.0. Header files will also be available in /usr/local/include i.e gd.h. These are different from the situation when I installed from RPM where libgd.so.2.0.0 is under /usr/lib/ and no gd.h found under /usr/include.

So, I make devclean and rerun

./configure --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/include --with-command-group=nagcmd

I configure the /usr/local/nagios/etc/cgi.conf but status map page is still empty. Next workaround is to install back  gd-2.0.33-9.4.el5_1.1.rpm. (which also bring back libmwf and ImageMagick) and point the gd library to the ones created from RPM. I make devclean and rerun:

./configure --with-gd-lib=/usr/lib --with-gd-inc=/usr/local/include --with-command-group=nagcmd

At this point I regret not to have Ubuntu implementation in the first place. Just a small regret.

Other library needed for check_smtp, check_http, etc. don’t seem to trouble me much, I need openssl, openldap, etc. and simply get them from RPMs.

MicroBlogger Add Search Feature (1)

This is mainly about view of custom search page (not about searching itself).

Adding “Search” To Main Link Tabs

Changes to file under

/app/omb/plugins/
  1. wp.php
  2. security.php

In wp.php:

Adding

$links['Search'] = $request->url_for('search');

between ‘Personal’ and ‘Profile’ would bring out the ‘Search’ tab in main link-tabs.

In security.php

Adding

function security_init() {
...
$request->connect( 'search' );
...

would give the URI link if tab is clicked or hovered, that is: http://base_url/?search.

Adding the search function would make the URI seek for the correlated viewing page

1
2
3
4
function search( $vars ) {
extract( $vars );
$_SESSION['requested_url'] = $request->base;
}

I create a viewing page then, under /app/omb/view/ by the name _search.html.

However, the main theme won’t appear correctly. So, what I do is: add a controller in /app/omb/controller/ with the name search_posts.php (an empty one for a start) and its view with the name _search_posts.html (inside /app/omb/view/). And then, add rendering to our previous search-function as in

1
2
3
4
5
function search( $vars ) {
extract( $vars );
$_SESSION['requested_url'] = $request->base;
render( 'action', '<strong>search_posts</strong>' );
}

As I’ll be incorporating databases issue later. The following search is adequate to show relevant results, plain with no links etc. It is the content of the current _search_posts.html.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php if (environment('authentication') == 'password') : ?>
 
<table cellpadding="0" cellspacing="0" border="0" width="770" align="center" style="margin-top: 30px;">
<tr>
  <td class="content">
<!-  <form name="search" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  <form name="search" action="<?php url_for('search_posts'); ?>" method="post">
 
    <table cellpadding="5" cellspacing="0" border="0" align="center" width="500">
    <tr>
      <td height="40" align="center" colspan="2">Please enter search</td>
    </tr>
    <tr>
      <td height="10" colspan="2"></td>
    </tr>
    <tr>
      <td width="170" height="30" align="right">Search:</td>
      <td><input type="text" maxlength="30" name="search_" value="" style="width: 180px;" /></td>
    </tr>
    <tr height="30">
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" value="Submit" style="width: 180px; font-size: 10px; text-transform: uppercase; color: #003366; border: 1px solid #336699; background-color: #DDDDDD; padding: 3px;" /></td>
    </tr>
    <tr>
      <td height="10" colspan="2"></td>
    </tr>
    </table>
  </form>
  </td>
</tr>
</table>
 
 
 
 
<?php endif; ?>
 
<?php if (isset($_POST['submit'])) : ?>
 
 
<?php
   $link1 = @mysql_connect("localhost","db_name","db_password")
                 or die("Could not connect to MySQL Server!");
 
   @mysql_select_db("omb_db")
                 or die("Could not select database!");
 
	$search_ = $_POST['search_'];
	$query = "SELECT `title` , `id` FROM `posts` WHERE `title` LIKE '%$search_%'";
	$result = mysql_query($query);
?>
 
  <?php while (list($title, $id_) = mysql_fetch_row($result)	) : ?>
	<br />
	<br />
	<br />
	<a href="<?php url_for(array('resource'=>'posts', 'id'=>$id_)); ?>"><?php print $title ?></a>;
	<br />
	<br />
	<br />
  <?php endwhile; ?>
<?php  mysql_close(); ?>
 
 
<?php endif; ?>

Hijri Calendar

Not succeding to find Hijri Calendar in Synaptic, I go for http://www.ojuba.org/wiki/hijra/. First, let Google translate does the job. Secondly, install this python applet.

Inside hijra-0.1.18 run $ sudo python setup.py install

It’d fail as it couldn’t find HijriApplet. Rename HijriApplet.py to HijriApplet to make it work. Now, it is in path (/usr/bin/) and can be called by HijriApplet command. We can copy hijra-autostart.desktop description to i.e. ~/.gnome2/panel2.d/default/launchers for shortcut launcher.

python-gnome2-extras must be installed or else it’d fail to launch saying can’t find egg.trayicon

Tagsistant (1)

Installation of tagsistant requires SQLite and FUSE, in Ubuntu they are satisfied as libsqlite3-dev and libfuse-dev (which will also requires libselinux1-dev and libsepol1-dev). A series of configure, make, and make-install will fail during the make-install. /usr/local/share/pixmaps must be created first before running

$ sudo make install

After that I test tagsistant to organize /data/tags/

$ tagsistant /data/tags

The tagging works as expected but not too handy since no browser GUI is embedded. It is just like browsing through multiple OR and AND folders.

The installation process will also install tagman (a tag manager GUI) if libgtk2.0-dev and libglib2.0-dev are installed.

← Before After →