NKedit and Instructions
Greetings! We've been using Big Brother in our datacenter here for over 5 years now, and I've been testing out Hobbit for a few weeks now, planning to eventually migrate to it. One of the things I'm trying to accomplish before moving fully to Hobbit is to integrate some of the customizations I've made to BB.
The one feature I'm focusing on right now is similar to the "Instructions" section handled by NKedit. In my custom BB, I edited a section of dohostsvc.c to read in files containing plain text or html. This content gets placed at the bottom of any page generated from bb-dohostsvc.sh.
Basically, a file called comments.conf resides in $BBHOME/www/comments/ and looks like this:
----[cut]----
This is the configuration file for the Special Instructions section on
all Big Brother alert pages. To create a new alert message, put whatever
text you want into a new file, call it anything you like, but try to
stick to the convention of group.service. Wildcards also work, but place
them at the bottom of the file, so that absolute matches can override
the wildcard entries.
NOTE: Make sure there are no trailing spaces at the end of the line.
I'll be adding in error checking code for that asap.
Portal Application Servers rules group
hostname*.int.*.us.army.mil.disk appservers.disk Army_Home_Page.http Army_Home_Page.http mail*.http mail_servers
Place all wildcard matches below here
*.cpu ALL.cpu *.disk ALL.disk *.msgs ALL.msgs *.procs ALL.procs *.http ALL.http *.conn ALL.conn ----[cut]----
Then, in the same directory, you just create the files like appservers.disk, or mail_servers, whatever you've called them, and the content loads whenever anyone goes to a bb-dohostsvc.sh page that matches. It works really well, and the only downside is having to ssh in and manually edit the conf file and content files. But you can use any html code you want, and don't have to worry about extra spaces, line feeds/carriage returns, etc.
What I need to do now is decide how best to proceed with setting this up in Hobbit. I'd like to be able to edit the content from the web interface somehow. The "Instruction" field in the existing nkedit is good for short comments, but we've been using long descriptive html output with web links and such. With some experimentation, I found that you can do the same thing in nkedit, but you have to remove any special tags like nbsp; and all newline characters or it makes the hobbit-nkview.cfg file unreadable.
I'm going to start looking at the source for bb-hostsvc.sh tomorrow to see where I'd need to make changes, but I wanted to throw this out there to see if anyone had any thoughts. If anyone else would also like my existing code for BB, I can post that. :)
Matthew Epp Sr Unix Engineer Army Knowledge Online (PEO/EIS) / CherryRoad Technologies Sitesupport Engineering (SEO)
Epp, Matthew Contractor PEO EIS AKO wrote:
Greetings! We've been using Big Brother in our datacenter here for over 5 years now, and I've been testing out Hobbit for a few weeks now, planning to eventually migrate to it. One of the things I'm trying to accomplish before moving fully to Hobbit is to integrate some of the customizations I've made to BB.
The one feature I'm focusing on right now is similar to the "Instructions" section handled by NKedit. In my custom BB, I edited a section of dohostsvc.c to read in files containing plain text or html. This content gets placed at the bottom of any page generated from bb-dohostsvc.sh.
Basically, a file called comments.conf resides in $BBHOME/www/comments/ and looks like this:
----[cut]----
This is the configuration file for the Special Instructions section on
all Big Brother alert pages. To create a new alert message, put whatever
text you want into a new file, call it anything you like, but try to
stick to the convention of group.service. Wildcards also work, but place
them at the bottom of the file, so that absolute matches can override
the wildcard entries.
NOTE: Make sure there are no trailing spaces at the end of the line.
I'll be adding in error checking code for that asap.
Portal Application Servers rules group
hostname*.int.*.us.army.mil.disk appservers.disk Army_Home_Page.http Army_Home_Page.http mail*.http mail_servers
Place all wildcard matches below here
*.cpu ALL.cpu *.disk ALL.disk *.msgs ALL.msgs *.procs ALL.procs *.http ALL.http *.conn ALL.conn ----[cut]----
Then, in the same directory, you just create the files like appservers.disk, or mail_servers, whatever you've called them, and the content loads whenever anyone goes to a bb-dohostsvc.sh page that matches. It works really well, and the only downside is having to ssh in and manually edit the conf file and content files. But you can use any html code you want, and don't have to worry about extra spaces, line feeds/carriage returns, etc.
What I need to do now is decide how best to proceed with setting this up in Hobbit. I'd like to be able to edit the content from the web interface somehow. The "Instruction" field in the existing nkedit is good for short comments, but we've been using long descriptive html output with web links and such. With some experimentation, I found that you can do the same thing in nkedit, but you have to remove any special tags like nbsp; and all newline characters or it makes the hobbit-nkview.cfg file unreadable.
I'm going to start looking at the source for bb-hostsvc.sh tomorrow to see where I'd need to make changes, but I wanted to throw this out there to see if anyone had any thoughts. If anyone else would also like my existing code for BB, I can post that. :)
Matthew Epp Sr Unix Engineer Army Knowledge Online (PEO/EIS) / CherryRoad Technologies Sitesupport Engineering (SEO)
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
Completely off topic but it amazes me how far hobbit reaches and what organisations it appeals to. Its so cool to know that someone like the US army/military (or some division there of) are actually using it
Allan
On Thu, Jul 20, 2006 at 07:09:26PM -0400, Epp, Matthew Contractor PEO EIS AKO wrote:
The one feature I'm focusing on right now is similar to the "Instructions" section handled by NKedit. In my custom BB, I edited a section of dohostsvc.c to read in files containing plain text or html. This content gets placed at the bottom of any page generated from bb-dohostsvc.sh. [snip] What I need to do now is decide how best to proceed with setting this up in Hobbit. I'd like to be able to edit the content from the web interface somehow. The "Instruction" field in the existing nkedit is good for short comments, but we've been using long descriptive html output with web links and such. With some experimentation, I found that you can do the same thing in nkedit, but you have to remove any special tags like nbsp; and all newline characters or it makes the hobbit-nkview.cfg file unreadable.
I'm going to start looking at the source for bb-hostsvc.sh tomorrow to see where I'd need to make changes, but I wanted to throw this out there to see if anyone had any thoughts. If anyone else would also like my existing code for BB, I can post that. :)
You're welcome to look at the source code, but this particular bit of Hobbit is not one of the prettier in terms of how it's implemented :-) Eventually you will end up in lib/htmllog.c and try to tweak that.
However, I think you could do this without changing a single line of code in Hobbit. The ~hobbit/server/web/hostsvc_footer is already inserted at the bottom of all the status pages (in the default setup, it's just a link to bb_footer, but copy that and make your own file).
You can implement your custom instructions by adding an HTML "object" to that file; you can get the hostname and columnname of the host being viewed by using &BBHOST and &BBSVC placeholders. So you can use this as parameters to a CGI script that delivers your instructions for this specific host+test combination, and by embedding it in an <object> section, it will automatically be shown as part of the status page.
E.g. in the hostsvc_footer you add
<center>
<object
data="&CGIBINURL/instructions.sh?HOST=&BBHOST&SVC=&BBSVC"
type="text/html" width="60%">
No instructions
</object>
</center>
near the top of the hostsvc_footer filer.
Your "instructions.sh" script would need to grab the QUERY_STRING environment variable which holds the HOST and SVC parameters, match those against your configuration file, and output an HTML document with the instructions. A simple shell script would be something like (note that writing GCI shell scripts are a bad idea, security-wise):
#!/bin/sh
set echo "$QUERY_STRING" | sed -e 's!&! !g'
while test "$1" != ""; do
case "$1" in
HOST=*)
HOSTNAME=echo $1 | cut -d= -f2
;;
SVC=*)
SERVICE=echo $1 | cut -d= -f2
;;
esac
shift
done
echo "Content-type: text/html" echo "" echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" echo "<html><head><title>Instructions</title></head>" echo "<body bgcolor=\"#ffffff\">" echo "These are the instructions for host $HOSTNAME / service $SERVICE" echo "</body></html>" echo ""
exit 0
Similar things can be written in Perl, Python, C or whatever your preferred language may be. Note that setting a <font> or BGCOLOR is necessary; my first tests of this ended up with black-on-black which is not easy to read :-)
One nice aspect of this is that you have completely de-coupled the maintenance of the instructions from Hobbit. If you have a content management system for uploading the instructions, you can use that to maintain the data. Or any other tool which is appropriate.
Regards, Henrik
On Fri, Jul 21, 2006 at 11:24:27AM +0200, Henrik Stoerner wrote:
One nice aspect of this is that you have completely de-coupled the maintenance of the instructions from Hobbit. If you have a content management system for uploading the instructions, you can use that to maintain the data. Or any other tool which is appropriate.
Just one thing I'd like to point out; it may be obvious, but still:
Since the <object> data is an independent web page (just embedded into another page), you can use all of the HTML features in it. So if you want to let users edit the instructions directly off the status view page, you can place your instructions in a text edit field of a form, and have the form submission update the instructions textfile.
Regards, Henrik
participants (3)
-
allan@zandahar.net
-
henrik@hswn.dk
-
matthew.epp@us.army.mil