Xymon Mailing List Archive search

NKedit and Instructions

5 messages in this thread

list Matthew Epp · Thu, 20 Jul 2006 19:09:26 -0400 ·
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)
list Allan Spencer · Fri, 21 Jul 2006 10:01:46 +1000 ·
quoted from Matthew Epp
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)

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
list Henrik Størner · Fri, 21 Jul 2006 11:24:27 +0200 ·
quoted from Allan Spencer
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&amp;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
list Henrik Størner · Fri, 21 Jul 2006 11:34:40 +0200 ·
quoted from Henrik Størner
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
list Matthew Epp · Wed, 26 Jul 2006 18:59:43 -0400 ·
quoted from Henrik Størner
-----Original Message-----
From: user-ce4a2c883f75@xymon.invalid [mailto:user-ce4a2c883f75@xymon.invalid]
Sent: Friday, July 21, 2006 5:24 AM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] NKedit and Instructions

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.
Just completed my modification to htmllog.c and the code is working
perfectly so far. I'm not a very skilled C coder though, so there may be
some potential bugs in the code. I can post the code if anyone wants to try
it out. It isn't a very drastic change to the file, just the function and an
additional #include.
quoted from Henrik Størner
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).
I tried that at first, and it sort of worked, however I noticed that only
Firefox even showed the object at all. Internet Explorer just acts as if the
<object> tag isn't even there. I didn't like how it was within a frame with
a scrollbar either, and wasn't sure if there was a way to easily change
that.
quoted from Henrik Størner
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.
I don't have a content management system yet, so I guess the next step is to
look at how you control the editing of the hobbit-nkview.cfg and emulate
that for my comments.conf and other content files.