# Simple monitoring?



## Floren (Mar 21, 2021)

I would like to install Nginx and have the index.html file embed some sort of widget who can display say the uptime and current server load. Is there a FreeBSD package who will install an agent and allow me to display this information?

This is for an internal website running on Intranet, no need for fancy graphs, just some text displaying the information either automatically or on page refresh. The `top` information would be great. 

Thank you for your help.


----------



## Emrion (Mar 21, 2021)

You have the AJAX technology for such a thing. It uses html and java script.
Look here and there.


----------



## Floren (Mar 21, 2021)

Emrion to do that, you need an agent that readies the information, to be configured on server side using Nginx or with other similar approach. And I'm not looking to learn programming, but to find out if there is a solution which will allow me to display the uptime and server load on a web page, the same way I can display the Nginx `/status` for example.

I don't know if the Nginx Lua plugin is available in FreeBSD but I prefer to use an already existing FreeBSD pkg solution which allows me to insert a widget into a web page.


----------



## SirDice (Mar 23, 2021)

You can probably create a really small script, could probably do it in a couple of lines of shell script. Just read the status page, get the output in JSON, don't even need to parse it and write it to a place the webpage can read it. Let a cronjob read and write it every 5 minutes or so. Heck you can have a javascript on your webpage that directly reads and parses it, don't do this for internet facing servers though. There's nothing this "small" ready made, all agents you're going to find as a package are going to do much, much more than what you need for this.


----------



## im (Mar 25, 2021)

Floren said:


> I would like to ... have the index.html file embed some sort of widget who can display say the uptime and current server load.


Try to write a simple script which parse the output of monitoring tools like uptime, iostat, top and will create index.html
A lot of console tools here: https://forums.freebsd.org/threads/tools-to-monitoring-system.79424/

For long years ago I used mrtg for the same purposes.
net-mgmt/mrtg draws simple graphs from SNMP-data or custom shell scripts.
Mrtg graphs are generated as simple webpage, so your performance graphs may be accessible via web browser.
example of script for mrtg that collect cpu stat

```
#!/bin/sh
set `iostat -c 2 -t proc |tail +4`

us="$3"
sy="$5"
#if [ "x$ni" = "x0100" ]; then
#  ni=0
#fi

echo $us
echo $sy
echo 0
echo User processes
```

mrtg.cfg

```
....
### CPU Utilization

Target[localhost-cpu]: `/usr/local/etc/cpustat`
AbsMax[localhost-cpu]: 100
MaxBytes[localhost-cpu]: 100
Title[localhost-cpu]: CPU Utilization (average)
PageTop[localhost-cpu]: <h1>CPU Utilization</h1>
Options[localhost-cpu]: gauge,growright,nopercent
YLegend[localhost-cpu]: CPU Utilization
ShortLegend[localhost-cpu]: %
LegendI[localhost-cpu]:CPU-USER (percentage)
LegendO[localhost-cpu]:CPU-SYST (percentage)
```

Mrtg can to graph network interfaces statistic received via SNMP.
FreeBSD has builtin SNMP daemon bsnmpd().


----------



## diizzy (Mar 25, 2021)

..or just proxy netdata (it's in ports) however you'll need to parse it if you just want a few lines.


----------

