Custom System Statistics Monitoring
As a systems administrator, knowing the status of the systems in your network is a must. This can be quite a challenge when you are dealing with tens, hundreds or thousands of different systems. A multitude of options are available for obtaining systems statistics, many of them freely available. For my purposes, I had a number of different requirements that most packages did not meet. In the end, I opted to build my own. This article explains the design of my solution, as well as its installation and configuration for use in your own environment.
One of my first requirements for systems statistics monitoring was any solution has to include a SQL backend. At the very least, it needs to have some way to export its data easily to allow it to be loaded into a SQL database. I wanted all data to be stored in a set of tables, but for simplicity and speed I decided to store only a single set of current data in the primary data table. Historical data then would be archived to an archive table, allowing reporting tools to use much simpler queries to obtain either current or historical data and to increase the speed and efficiency of queries against the current data table.
I debated whether to use a central data collection system or to allow each client to collect its own data. In the end, I decided to have each client collect the data and update the database. This made it much simpler to do asynchronous status updates without using a threaded server using a pull model. The agent needs to run on each host to collect the data, so why not have it make the database updates too?
The data gathering was a much more difficult problem to tackle due to portability issues. After spending some time implementing data-gathering functions, I came upon libstatgrab, a cross-platform systems statistics gathering library written in C. Many of the statistics I needed were handled by libstatgrab, so the first version uses libstatgrab exclusively to collect the data.
Figure 1 contains a simple graph showing the data flow from the OS level to ssclient via libstatgrab and then from ssclient to the database via libmysqlclient.
The ssclient client application uses the autoconf/automake/autoheader configuration method, so building and installing it should be a piece of cake for you. The current version is available here. Assuming the current version, download the tarball ssclient-0.2.2.tar.gz and run:
$ ./configure --prefix=/usr/local
The configure script attempts to locate your MySQL and libstatgrab installation locations and acts accordingly. If the configure script is unable to locate them, try listing their locations explicitly with:
$ ./configure --prefix=/usr/local \
--with-mysql-prefix=/path/to/mysql \
--with-statgrab-prefix=/path/to/statgrab
Once configured, you should be able to run make and, as root, make install. If you do not have the MySQL and libstatgrab shared libraries installed on each of your target systems, you may want to consider linking against their static libraries, (libmysqlclient.a and libstatgrab.a. This allows you to distribute only the ssclient package to each system on which it will run.
A sample spec file for building an RPM for Linux systems, as well as pkginfo and postinstall files for building a Solaris package, is located in the misc/packaging subdirectory, if you would like to build packages for those platforms.
Assuming you used our example prefix of /usr/local, once completed you have an ssclient binary in the /usr/local/bin directory. Make a copy of the sample configuration file from misc/ssclient.conf and install it in the /usr/local/etc directory. Next, we dive into the shallow pool of the configuration file.
The ssclient is pretty simple to configure, requiring only a few configuration options. A sample configuration is listed below:
debug 0 interval 300 db_host dbhost db_database ssdb db_user ssdbuser db_pass ssdbpwd logfile /var/log/ssclient.log syslog 1
The debug setting sets the debug level for ssclient. For a production setup, you should set this this to 0. The interval setting is the number of seconds to sleep between each update. The default interval setting is 300 seconds. This setting actually is 300 seconds plus a random number of seconds between 30 and -30. This is done to vary the time that updates are made to the database. The db_host, db_database, db_user and db_pass settings are used for connecting to the database into which you want the records inserted. The logfile setting is the path to your logfile if syslog logging is disabled. The syslog setting enables or disables logging with syslog by setting it to a 1 or a 0, respectively.
Trending Topics
| Make TV Awesome with Bluecop | May 16, 2012 |
| Hack and / - Password Cracking with GPUs, Part I: the Setup | May 15, 2012 |
| An Introduction to Application Development with Catalyst and Perl | May 14, 2012 |
| Cryptocurrency: Your Total Cost Is 01001010010 | May 09, 2012 |
| HTML5 for Audio Applications | May 07, 2012 |
| May 2012 Issue of Linux Journal: Programming | May 02, 2012 |
- Hack and / - Password Cracking with GPUs, Part I: the Setup
- How to Play DVD Digital Copy Movies on Kindle Fire?
- How to convert mxf file into Final Cut Pro for editing on Mac?
- Validate an E-Mail Address with PHP, the Right Way
- Readers' Choice Awards 2011
- An Introduction to Application Development with Catalyst and Perl
- Make TV Awesome with Bluecop
- Why Hulu Plus Sucks, and Why You Should Use It Anyway
- Why Python?
- Python for Android
- Awsome Post
1 hour 42 min ago - Awsome Post
1 hour 44 min ago - agreed
1 hour 46 min ago - agreed..
1 hour 55 min ago - missing ""
1 hour 58 min ago - lost me
2 hours 3 min ago - not really...
2 hours 6 min ago - x-forwarding over ssh to use libre office
2 hours 9 min ago - x11 & x11
2 hours 12 min ago - good example
2 hours 16 min ago






Comments
Re: Custom System Statistics Monitoring
I was unable to compile ssclient....keeps throwing error at stat.c:-
stats.c: In function `get_cpu_usage':
stats.c:28: error: `cpu_percent_t' undeclared (first use in this function)
stats.c:28: error: (Each undeclared identifier is reported only once
stats.c:28: error: for each function it appears in.)
stats.c:28: error: `cpu_percent' undeclared (first use in this function)
stats.c: In function `get_general_info':
stats.c:52: error: `general_stat_t' undeclared (first use in this function)
stats.c:52: error: `general_stats' undeclared (first use in this function)
stats.c: In function `get_load_average':
stats.c:103: error: `load_stat_t' undeclared (first use in this function)
stats.c:103: error: `load_stat' undeclared (first use in this function)
stats.c: In function `get_process_info':
stats.c:113: error: `process_stat_t' undeclared (first use in this function)
stats.c:113: error: `process_stat' undeclared (first use in this function)
stats.c: In function `get_memory_info':
stats.c:122: error: `mem_stat_t' undeclared (first use in this function)
stats.c:122: error: `mem_stats' undeclared (first use in this function)
stats.c:123: error: `swap_stat_t' undeclared (first use in this function)
stats.c:123: error: `swap_stats' undeclared (first use in this function)
stats.c: In function `get_user_info':
stats.c:137: error: `user_stat_t' undeclared (first use in this function)
stats.c:137: error: `users' undeclared (first use in this function)
make[2]: *** [stats.o] Error 1
make[2]: Leaving directory `/usr/local/src/ssclient-0.2.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/ssclient-0.2.3'
make: *** [all] Error 2
Re: Custom System Statistics Monitoring
Replace ` with '
Might help
Re: Custom System Statistics Monitoring
A new version of ssclient has been released on SourceForge.
Here are the URLs:
ssclient Project
ssclient Downloads
Re: Custom System Statistics Monitoring
What version of libstatgrab are you using? The API for
libstatgrab changed between 0.9 and 0.10, and a lot
of the types and other things changed.
In the short term, in includes.h before the #include for
statgrab.h, you can put this line:
It should look something like this:
I am going to be releasing a new version soon that
will detect which version of statgrab you're using,
if you're using 0.9 or older it will use the old API, if
you're using 0.10 it will use the new. Let me know
if this helps.
--Ryan
Re: Custom System Statistics Monitoring
This looks like it could be very sweet, but why not just keep a reference to the master (and maybe a few failover masters) on the client, and pull an appropriate client config. from the master machine ...
If you're maintaining more than a few machines, the ability to manage the client configs centrally could save you a lot of work ...
Re: Custom System Statistics Monitoring
My client configs are identical, I actually maintain from
a master system via rsync. I've tried to keep the configuration
to be as simple as possible. Another option if you wanted
some systems to use different intervals or different logging
methods would be to do something like this:
[main]
debug 0
db_host dbhost
db_database sysdb
db_user sysdb
db_pass sysdbpwd
[host1]
interval 300
[host2]
interval 250
[host3]
interval 600
A central configuration file could be used with
client-specific options being put in the host-specific
sections. I'll add it to my TODO. :-)
--Ryan