# System Monitoring with Xymon/Other Docs/HOWTO
## How do I clone maintenance records from one xymon to the other one ?

The front-end web GUI is to collect information and in the end send out bb command with "disable" syntax.

### Found out the maintenance status of a host

* bb xymon-server-name "hobbitdboard color=blue fields=hostname,testname,disabletime,dismsg"

### Disable a host

* bb xymon-server-name "disable hostname.testname $timeframe $REASON"

### Enable a host

* bb xymon-server-name "enable hostname.testname"

### Enable All hosts with blue record that in maintenance mode

Why ?, Useful when you need to populate the records from hobbit server A to B.

### Replicate blue record from Xymon A to Xymon B
## How to have pca work with xymon ?

pca is a perl script that can report and install patch missing patches from Sun's patches databases for all versions of Solaris OS.
There are two ways to integrate pca with xymon monitoring tool.

### Server side patch analysis

Run "showrev -p" and "pkginfo -x" on xymon client and run pca.pl on xymon server to analyze missing patch for all the clients.

### Client side patch analysis

Run pca.pl on xymon client for missing patches analysis and send in lists of missed patch to xymon server.
* pca software and its dependent software need to be deployed as part of xymon client package.
* pca.pl need to be configure to query internal Solaris patch database reside on xymon server.
* Need to set up a local pca proxy server to store all the patch zip files and main solaris patch database.
* Use pca command to update missing patch after getting approvals to update the missing patches.

### Pros and Cons for Server and Client side methods

| Integration approach | Server side analysis | Client Side analysis |
| Client changes needed | Modify -sunos.sh to send in "showrev -p" and "pkginfo -x" output. | Run "pca -L" and more HTML code correction in wrapper script or run "pca -M" (with a patch change to pca.pl) on Xymon client as a client side ext module. |
| Server side change needed | Write a server side module to process the data of "showrev -p" sent from clients. | Xymon server will create a "pca" column with missed patch send from Xymon client. |
| Load on Xymon server | This will add the missing patch calculation time for all clients on the Xymon server. | Load to xymon server is minimum because the calculation task is done on Xymon clients. |
| pca script changes | No pca.pl script change is needed. We only update the new pca.pl one time on the Xymon server. | "pca -L" won't generate Xymon client compatible HTML code. We need to either correct this in the wrapper script or patch the pca perl code. |
| client to server traffic | The raw data output of "showrev -p" will be sent every 5 minutes! | The message size is only the missed patches list, not the whole output of "showrev -p" and every 5 minutes. |
| Administration Cost | TBD | TBD |

## Transparent Authentication against Active Directory 2003 with Apache and CentOS 5

Here, I (Stewart L) will explain the steps I went through to get a Linux server joined to our Active Directory 2003 infrastructure and to authenticate users against the domain without them being required to enter credentials.
This is against an AD 2003 structure. If you are operating in a 200 or NT domain, this might not work for you, but it should point you on your way.
I'll make a few assumptions at this point for the example.
* You are setting up a webserver to be named web1.example.com.
* Your domain is called EXAMPLE and your kerberos Realm is named EXAMPLE.COM
* You have a domain account named EXAMPLE\Bob that is authorized to add machines into the domain.
* Your Domain controller is dc1.example.com.

### Install Packages

You obviously need Apache installed. You will also need the mod_auth_kerb package to authenticate against the domain. It is also much easier if you use the system-config-authentication tool in the authconfig-gtk package.

### Join the Machine to the Domain

Before you can join a machine to a domain, you must have a few items taken care of...
* The hostname (excluding the domain) should be 15 characters or less.
* The system clocks should be synchronized. Use NTP for this.
* Your /etc/hosts file needs to be properly set up. You should have a localhost entry pointing to 127.0.0.1 and an entry that has your fully-qualified host name pointing to its assigned IP address.
With that out of the way, we can begin configuring authentication.
* Run system-config-authentication as root.
* On the Authentication tab, Enable Kerberos and Winbind
* Configure Kerberos.
** REALM = EXAMPLE.COM
** Check the boxes for using DNS to resolve hosts to realms and locate KDCs.
** KDC and Admin Sevrer can be left blank
** Click ok.
* Configure Winbind
** Domain = EXAMPLE
** Security Model = ads
** ADS Realm = EXAMPLE.COM
** Domain Controllers = dc1.example.com
** Click ok
* Edit your /etc/samba/smb.conf file and make sure that your netbios name is the same as your hostname. This should be the host part only, not the domain.

### Join the Domain

As the root user, run the following commands. You will have to enter a password for Bob after both commands.
This is the domain. By default you have to have a local account on the box to authenticate against AD, meaning if there is not a bob account on web1.example.com, bob cannot log in with his domain password.

### Configure an AD User

This is where things become a little convoluted. We are going to create a user account in AD that the web server will use for authentication. There are a number of different versions and service packs out there for Windows Server 2000 and 2003. Check http://grolmsnet.de/kerbtut/ if you have problems with this part.
* Create a user in AD named http_web1.
* Set this account so that the password never expires.
* On the command line of the Domain Controller, run this line
    ktpass -princ HTTP/web1.example.com@EXAMPLE.COM -mapuser EXAMPLE\http_web1 -crypto DES-CBC-MD5 -ptype KRB5_NT_SRV_HST -pass * -out c:\temp\http_web1.heytab
* This will create a keytab file in C:\temp that you need to move to your webserver and place in /etc/http.

### Configure Apache

Your configuration should look something like this...
It is possible to change the Authname a new name. Check http://modauthkerb.sourceforge.net/ for more info on specific configurations.

### Configure Firefox (Optional)

* Type about:config in the URL bar
* Modify the following "Preference Name"
** network.negotiate-auth.delegation-uris - Example.com
** network.negotiate-auth.trusted-uris - Example.com
** network.automatic-ntlm-auth.trusted-uris - Example.com

## How do I prevent red/purple alert storm from Xymon server ?
### What

* red alert storm:
** caused by death of a few switches and bad bb-hosts configuration that missing router dependency directive.
** human error on configuring fping access control list.
* purple storm:
** caused by Xymon server went into very high CPU load itself that prevent itself from running the Xymon daemon themselves properly thus all machines went into purple due lack of message update within 30 minutes.

### How to fix

* Deploy mail filter to restrict the volume of alerts Xymon server can send out.

## How do I update xymon client's configuration file from xymon server ?
### Why ?

* To make global variable changes on all hobbit clients.
** Examples: To configure all your clients to send hobbit messages from one to two Xymon servers. This will need to modify hobbitclient.cfg on all clients. If you have small pool of clients, manually editing by login into each machines is ok. But for a pool of 3000 clients, this change is better done via clientudpate or cluster shell plus rsh approach.
** This wiki page is to verify if xymon's clientupdate really work for this need.

### What need to be done ?

* Update hobbit-client.cfg on hobbit clients with new hobbit-client.cfg locate in central hobbit server. The new hobbit-client.cfg contain new configuration to send hobbit messages to two hobbit server.
** diff of old and new hobbit-client.cfg file.
* Make sure/Modify all the scripts in ext directory send messages to BBDISPLAYS.
** temperature module.
*** original
*** changes for two hobbit servers.

### RTFM first

* http://www.hswn.dk/hobbit/help/manpages/man1/clientupdate.1.html
* Looks feasible from about manpage.

### Procedures

To manage updating clients without having to logon to each server, you can use the clientupdate utility. This is how you setup the release of a new client version.
* make sure the xymon client external scripts send message to "BBDISPLAYS", not just "BBDISP" variable.
** this require the review of external(home-grown) script got deployed to be modified to send messages to two xymon servers.
* Create the new client: Setup the new client $BBHOME directory, e.g. by copying an existing client installation to an empty directory and modifying it for your needs. It is a good idea to delete all files in the tmp/ and logs/ directories, since there is no need to copy these over to all of the clients. Pay attention to the etc./ files, and make sure that they are suitable for the systems where you want to deploy this new client. You can add files - e.g. extension scripts in the ext/ directory - but the clientupdate utility cannot delete or rename files.
* Package the client: When your new client software is ready, create a tar-file of the new client. All files in the tar archive must have filenames relative to the clients' $BBHOME (usually, ~hobbit/client/). Save the tarfile on the Hobbit server in ~hobbit/server/download/somefile.tar. Don't compress it. It is recommended that you use some sort of operating-system and version-numbering scheme for the filename, but you can choose whatever filename suits you - the only requirement is that it must end with ".tar". The part of the filename preceding ".tar" is what Hobbit will use as the "clientversion" ID.
* Configure which hosts receive the new client: In the client-local.cfg(5) file, you must now setup a clientversion:ID line where the ID matches the filename you used for the tar-file. So if you have packaged the new client into the file linux.v2.tar, then the corresponding entry in client-local.cfg would be clientversion:linux.v2.
* Wait for hobbitd to reload client-local.cfg: hobbitd will automatically reload the client-local.cfg file after at most 10 minutes. If you want to force an immediate reload, send a SIGHUP signal to the hobbitd process.
* Wait for the client to update: The next time the client contacts the Hobbit server to send the client data, it will notice the new clientversion setting in client-local.cfg, and will run clientupdate to install the new client software. So when the client runs the next time, it will use the new client software.

### Getting started with clientupdate

* find out the hobbiclient version, we are running 4.2.0 from output of "clientupdate --level"
** or cutout the version from clientversion.cfg.
* do the update but no new version on server side.

### Error messages from clientupdate

* core dump because we didn't run bbcmd first. clientupdate.c need to be updated to avoid the coredump.
* "--suid-setup failed: No such file or directory", no xymon server side configuration at all.

## How do I configure sudo to empower hobbit client to gain limited root privilege ?
### Add SUDO path to hobbit client main script

We need to modify hobbitclient.sh$.{OS} to use sudo without prompting password on root privileged access. Following is an patch for Linux client. you need to do similar patching for other OS types.

### configure your sudoer file

hobbits = hobbit server user account. hobbitc = hobbit client account.

## How can I create a hobbit client custom test script?

Anything that can be automated via a script or a custom program can be added into Hobbit. A lot of extension scripts are available for Big Brother at the www.deadcat.net archive, and these will typically work without modifications if you run them in Hobbit. Sometimes a few minor tweaks are needed - the Hobbit mailing list can help you if you don't know how to go about that.
But if you have something unique you need to test, writing an extension script is pretty simple. You need to figure out some things:
* What name will you use for the column?
* How will you test it?
* What criteria should decide if the test goes red, yellow or green?
* What extra data from the test will you include in the status message?
A simple client-side extension script looks like this:
You will notice that some environment variables are pre-defined: BB, BBDISP, MACHINE are all provided by Hobbit when you run your script via hobbitlaunch. Also note how the MSG variable is used to build the status message - it starts out with just the "Bad stuff status", then you add data to the message when we decided what the status is.
To run this, save your script in the ~hobbit/client/ext/ directory (i.e. in the ext/ directory off where you installed the Hobbit client), then add a new section to the ~hobbit/client/etc/clientlaunch.cfg (or ~hobbit/server/etc/hobbitlaunch.cfg on the server) file like this:
Optionally you may want to add a description for the new column your custom script creates. On the hobbit *server* edit the file $BBHOME/columndoc.csv adding a line like:

## How to write server side module ?

Server-side scripts look almost the same as client-side scripts, but they will typically use the bbhostgrep utility to pick out hosts in the bb-hosts file that have a special tag defined, and then send one status message for each of those hosts. Like this:
Note that for server side tests, you need to loop over the list of hosts found in the bb-hosts file, and send one status message for each host. Other than that, it is just like the client-side tests.
This script is saved in ~/hobbit/server/ext/my_script.sh, and you add its description in ~hobbit/server/etc/hobbitlaunch.cfg:
The service can now be added to the bb-hosts file:

### How can I test a custom script before adding it to the running agent ?

Before activating a new custom script it is useful to check its functionality and output on stdout.
To run a script on the command line, you have to load all the xymon environment and replace the $BB command by "echo".
You can easily do this on-the-fly by inserting this code snippet and then test your script by running it on the command line:
There is nothing you have to change in your script if you want to add it to your hobbitlaunch.cfg after testing.
This works for client-scripts as well as for server side scripts.
Of course you have to change the path settings to your environment.

## Hobbit Client and ZFS monitoring

* See the ZFS tutorial for a simple ZFS pool example.
* In this example, we have the 3rd and 4th disks available for zfs. 1st and 2nd are under SVM already.
* Mike Rowell <Mike.Rowell@Rightmove.co.uk> has the following ZFS hb external module.
* Testing on hobbit client.
* Check that the data arrives in Hobbit server.

## Use a Big Brother script without converting it to hobbit

Run the latest Big Brother client on your hobbit server. Execute the desired script from this client, it will report to hobbit. e.g. using the latest "bb-mrtg.pl" script to monitor your mrtg graphs

## Add Custom Graphs

Read the man page for hobbitd_rrd

## Add support for a database backend

I haven't done it, but it will be easy to implement. For reporting you just want to know what status changes have occurred, so you simply need to come up with a Hobbit "worker module" that receives messages from the Hobbit "stachg" channel, and stores them in your database.
Worker modules can be written in whatever language you fancy, although I'd advise against shell-scripts for performance reasons. Perl, Python, C, C++, Java ... pick your favourite programming tool.
All the module needs to do is read the messages off it's standard input filehandle, and store them in the database. Each message is formatted like this:
It is easy to pick out the first line and grab all of the needed information from that.
There's a sample module provided with the Hobbit sources, see the "hobbit-4.0-RC4/hobbitd/hobbitd_sample.c" file which illustrates how to build a worker module in C.

## Installing Hobbit as client with a BB server

There are a few gotchas if you want to use Hobbit as client with a BB server: the Hobbit client usually gets its configuration from the server, and the standard protocol is different. To make it backwards compatible requires a few workarounds on hobbit client side.
Example for Debian Unix OS, adjust as required otherwise.
Start as root
We are hobbit!
    Answer client
    Answer hobbit
    Answer /home/hobbit
    Answer 10.0.4.5 (replace with the IP address of your BB server)
    Add MACHINEDOTS="f.q.d.n", i.e. the client's fqdn
    Add --local on the line that starts hobbitlaunch
    Add BBMAXMSGSPERCOMBO=1
We are root again!
Create /etc/init.d/hobbit as:

## Monitor Hobbit clients in a DMZ using reverse SSH tunnels

Note: Other methods for doing this type of thing are documented on the System_Monitoring_with_Xymon/Administration_Guide page.
Operating system: Red Hat Enterprise Linux 5
Hobbit version: Hobbit 4.2.0
In some scenarios you may want to monitor Hobbit clients that are separated from the Hobbit server by a firewall (e.g. Hobbit clients located in a DMZ) and where you cannot open port 1984 inbound from the Hobbit clients to the Hobbit server. An alternative would be to use reverse SSH tunnels, using Padraig Lennon's ssh_tunnels.sh script.
Note that for the purpose of this document, the hobbit user's home directory is assumed to be /usr/lib/hobbit.

### Passwordless SSH Authentication

For the hobbit user, set up passwordless SSH authentication between the Hobbit server and the Hobbit clients.
On the Hobbit server, generate a private/public keypair with an empty password:
This should create the following files in the .ssh directory located in the hobbit user's home directory:
If for some reason the creation of the keypair fails, try manually creating the .ssh folder in the hobbit user's home directory before generating the keypair. Ensure that the folder is owned by the hobbit user and group, and that its permissions are correct:
Now you want to copy the generated public key (id_dsa.pub) to the Hobbit client. Ensure that the .ssh folder exists for the hobbit user on the Hobbit client with the same permissions as above, and then copy id_dsa.pub to the Hobbit client:
On the Hobbit client:
Rename the public key copied from the Hobbit server from "id_dsa.pub" to "authorized_keys":
Move the authorized_keys file to the hobbit user’s .ssh directory:
Check that the authorized_keys file has the correct permissions (chmod 644):
From the server, SSH to the client. You should add the client's host key to the server's known_hosts file when prompted, but should not be prompted for a password.

### Configure the Hobbit client

Add the following line to /usr/lib/hobbit/client/etc/hobbitclient.cfg on the Hobbit client:
Configure /etc/default/hobbit-client as follows:
Restart the hobbit-client service on the Hobbit client.

### Configure the Hobbit server

Copy the ssh-tunnels.sh script to the following location on the Hobbit server, and make sure that its permissions are correct (chmod 755):
Modify /etc/hobbit/hobbitlaunch.cfg:
Add entries for the Hobbit clients to the /etc/hobbit/bb-hosts file (use "noconn" if pings aren't allowed from server to client):
If the Hobbit clients' names cannot be resolved by the Hobbit server, add entries for those clients to the Hobbit server's /etc/hosts file:
As of ssh-tunnel.sh version 0.0.3 you can specify a non-standard ssh port to connect to. Example:
You could also create a DNS entry for the client, whichever is easier.
As the hobbit user, manually SSH to each Hobbit client at least once, and when prompted add the Hobbit client's host key to the Hobbit server's known_hosts file:
Restart the hobbit service on the Hobbit server:

### Confirm functional

Consult /var/log/hobbit/ssh-tunnels.log for any error messages, e.g.
Solution: Ensure that the Hobbit server can resolve the Hobbit client's name, e.g. add an entry for the Hobbit client to the Hobbit server's /etc/hosts file.
Solution: Manually SSH to the Hobbit client from the Hobbit server at least once and add the Hobbit client's host key to the Hobbit server's known_hosts file when prompted.
You can verify that the ssh tunnels have been successfully created:
You should also see a new column called "ssh-tunnel" generated in the Hobbit server's web interface.

## Mobile phone clients

If you want to check your hobbit / Xymon-Status from your mobile phone you can use the following apps:

### Android

XyMon by dot knowledge: http://www.dot-knowledge.de/Home/android/xymon-monitor (There you find a link to the Android market place)
Xydroid by Rune B. Broberg: http://mihtjel.dk/xydroid/ - a recent project of delivering Xymon statuses on Android phones.

## See also

* Clientupdate utility
* Custom Monitoring Scripts Howto
* Custom Server Scripts
* Devmon SNMP Howto