Category Archives: Linux

The Linux Category actually encompasses *BSD, RH, Fedora, Ubuntu, and the like.

Proxmox 1.9 Stopped Backing Up

Proxmox 1.9 – not fully updated (1.9 build 6542)
Had backups set to backup snapshots of machines every day starting at 2AM. They generally took about 3 hours and would finish by 5AM.

Little did I realize that I was no longer receiving the emails saying “backup successful”. Last one was 4 weeks ago. Whoops doesn’t even start to cover that.

Checking it out it looks like the backup stalled on one of the virtual machines.
ps auxww |grep vzdump
Then just kill any PID that looks like vzdump is running.

Re-run the command to backup either from the GUI or from the command line:
vzdump --quiet --snapshot --storage STORAGE --maxfiles 5 --mailto admin 101 102 103 etc

SNMP Daemon Ubuntu

Ubuntu 10.04.3 LTS x32 fully patched.

I needed to install SNMP so my cacti installation could work with graphing. And I thought I had already installed SNMP on the server I was testing against.

Testing from cacti:
snmpwalk -v 1 -c public IPOFSERVER

Timeout: No Response from IPOFSERVER

OK, so let me see if the process is running:
ps aux | grep snmp

root 439193 0.0 0.0 3884 616 pts/0 S+ 09:59 0:00 grep snmp

Well, looks like I need to install it:
apt-get install snmpd

The installation auto-starts the snmpd service with the default configuration file. I verified it was working with ps aux again, and the snmpd service is running under the snmp user.
On the local machine I could now run snmpwalk:
snmpwalk -v 1 -c public localhost
Which retrieved the information I wanted. Unfortunately I still could not run snmpwalk from the cacti server. Doh!

Edit the snmpd.conf file if you want a different community or RO/RW rights:
nano /etc/snmp/snmpd.conf

Otherwise, just edit the default snmpd configuration:
nano /etc/default/snmpd
Change the following line:

SNMPDOPTS=’-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1′

To:

SNMPDOPTS=’-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf’

Save and quit

Restart the snmpd service:
/etc/init.d/snmpd restart

Test again:
snmpwalk -v 1 -c public IPOFSERVER

Profit.

Sudoers Ubuntu Commands

I needed to find an easy, and fairly secure, way to allow a user to login on a website and display their current user’s disk usage. Generally I just navigate to the user’s home directory and run
du -hc
But in this case I needed it to work from the web.

By default, Ubuntu runs apache as www-data. Enter sudoers. My editor’s file is nano.
visudo
Add the following to the bottom of the file:
www-data ALL=NOPASSWD: /usr/bin/du, /usr/bin/ls, other/command
Save and quit

Now your www-data user can run those commands by running sudo command. And it will not allow the user to sudo any other commands.

My PHP page is as follows:
echo exec("sudo du -hc /mnt/ | grep " . $_SESSION["valid_user"] . "| awk '{print $1}'") . " Disk Space Used
";

Obviously the SESSION variable comes from a login page, but it’s a pretty good start for me.

NTP on RHEL

I know there is a GUI for RHEL, but I still prefer to do these things via a command line.

RHEL Setup NTPd

To simply set the time to the time server (correct time one-off), use the following command:
/usr/sbin/ntpdate IP_or_ADDR_of_NTP_Server

In my case it was this command and this result:

-bash-3.2# /usr/sbin/ntpdate 10.4.0.253
18 Jan 08:16:02 ntpdate[13347]: step time server 10.4.0.253 offset 756.199630 sec

As you can see, this server was off by over 12 minutes!

If you want to edit the NTP Servers List:
nano (or vi) /etc/ntpd.conf
Add the specific time server you require
/sbin/service ntpd restart

User Quota FreeNAS

I recently installed FreeNAS 8.x release and wanted to setup a per user quota. There is no way to set this up using the GUI front end – you can only setup a mount point quota at this time.

To setup a per user quota using the CLI, just login as root using your admin password, then issue the following commands:

zfs set userquota@USERNAME=10g SHARENAME
So in my case I had a /mnt/files filesystem, so I used:
zfs set userquota@thelibrarie=10g files

You can list the user quota
zfs list -o userquota@USERNAME SHARENAME

You can remove the user quota
zfs set userquota@USERNAME=none SHARENAME

View the current Input/Output statistics
zpool iostatzpool upgrade -v

View the current compression for all pools
zfs list -o compression

ESXi 4.1 Dell OpenManage

I had Nagios telling me there was a memory issue on the server, but not in which slot the bad ram was located. OM to the rescue?

Download oem-dell-openmanage-esxi_6.3.0-A00.zip (I’m running on a Dell PowerEdge 2850 Server)
Use the VMWare VSphere CLI to run the following:

vihostupdate.pl –server SERVERNAME_OR_IP -i -b “C:\oem-dell-openmanage-esxi_6.3.0-A00.zip”
Enter the username (root)
Enter the Password (password)

Then, using the Dell Web Server administrator (OM-SrvAdmin-Dell-Web-WIN-6.3.0-2075_A00.20.exe), connect to your virtual machine and IGNORE CERTIFICATE ERRORS!

ESXi Monitoring via Nagios

My current infrastructure budget does not allow for vSphere Server, ESXi 4.1 Enterprise, or OpsView Enterprise. They all have one thing in common: they’re more than $0. OK, I know OpsView comes in a community flavor, but still. ESXi hypervisor 4.1 is also free.

So originally I was going to just run SNMP monitoring through Nagios, but I found out that I needed to enable ESXi’s SNMP before I could attempt that. Long story short, ESXi’s SNMP is not worth monitoring. CIM, the supported protocol from VMWare, apparently is the route I needed to go.

So I found this site:
http://www.matthewjwhite.co.uk/blog/2010/02/09/monitoring-esxi-server-health-using-nagiosopsview/
Which gave me the direction I needed.

Log onto your Nagios Server:
apt-get install python-pywbem
cd /usr/local/nagios/libexec
wget http://communities.vmware.com/servlet/JiveServlet/downloadBody/7170-102-7-4233/check_esx_wbem.py
wget http://it.thelibrarie.com/utilities/check_esxi_hardware.py
chmod +x check_esxi_hardware.py

Check by running the following:
./check_esxi_hardware.py IPOFYOURESXISERVER root password VENDOR
You should receive a simple “OK” to verify everything is working

define command{
command_name check_esxi_hardware
command_line $USER1$/check_esxi_hardware.py -H $HOSTADDRESS -U $ARG1$ -P $ARG2$ -V $ARG3$
}

And the check as defined for one of my ESXi servers

define service{
use generic-service
host_name esx01
service_description ESXi Hardware Monitor
check_command check_esxi_hardware!readonlyuser!somepassword!dell
}

Verify it’s working after the check, you should have the green bar saying OK.

I had to edit a little bit as the previous script did not function through nagios although it did work via the command line. Nagios merely reported everything as OK even though I had errors reported on the CLI.