Introduce own librenms user and remove rrds when removing a device

This commit is contained in:
f0o
2015-05-19 14:25:17 +00:00
parent 66297e1a19
commit 1f8db156eb
7 changed files with 53 additions and 8 deletions

View File

@@ -55,6 +55,11 @@ Adding the above line to `/etc/snmp/snmpd.conf` and running `service snmpd resta
In `/etc/php5/apache2/php.ini` and `/etc/php5/cli/php.ini`, ensure date.timezone is set to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid
examples are: "America/New York", "Australia/Brisbane", "Etc/UTC".
### Adding the librenms-user ###
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data
### Cloning ###
LibreNMS is installed using git. If you're not familiar with git, check out the [git book][2] or the tips at [git ready][3]. The initial install from github.com is called a `git clone`; subsequent updates are done through `git pull`.
@@ -81,9 +86,12 @@ To prepare the web interface (and adding devices shortly), you'll need to create
First, create and chown the `rrd` directory and create the `logs` directory:
mkdir rrd logs
chown www-data:www-data logs/ rrd/
chown www-data:www-data logs
chmod 775 rrd
chown librenms:librenms rrd
> NOTE: If you're not running Ubuntu or Debian, you will need to change `www-data` to the user and group which run the Apache web server.
> If you're planing on running rrdcached, make sure that the path is also chmod'ed to 775 and chown'ed to librenms:librenms.
Next, add the following to `/etc/apache2/sites-available/librenms.conf`:
@@ -168,7 +176,7 @@ LibreNMS uses Job Snijders' [poller-wrapper.py][1]. By default, the cron job ru
Create the cronjob
cp librenms.cron /etc/cron.d/librenms
cp librenms.nonroot.cron /etc/cron.d/librenms
### Daily Updates ###

View File

@@ -51,6 +51,11 @@ Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardle
pear install Net_IPv4-1.3.4
pear install Net_IPv6-1.2.2b2
### Adding the librenms-user ###
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data
### Using HTTPd (Apache2) ###
Set `httpd` to start on system boot.
@@ -167,9 +172,14 @@ First, create and chown the `rrd` directory and create the `logs` directory
mkdir rrd logs
# For HTTPd (Apache):
chown apache:apache rrd/
chown apache:apache logs
# For Nginx:
chown nginx:nginx rrd/
chown nginx:nginx logs
chmod 775 rrd
chown librenms:librenms rrd
> If you're planing on running rrdcached, make sure that the path is also chmod'ed to 775 and chown'ed to librenms:librenms.
Start the web-server:
@@ -202,7 +212,7 @@ If the thread count needs to be changed, you can do so by editing the cron file
Create the cronjob
cp librenms.cron /etc/cron.d/librenms
cp librenms.nonroot.cron /etc/cron.d/librenms
### Daily Updates ###

View File

@@ -39,6 +39,11 @@ Install necessary software. The packages listed below are an all-inclusive list
apt-get install lighttpd php5-cli php5-mysql php5-gd php5-snmp php5-cgi php-pear php5-curl snmp graphviz mysql-server mysql-client rrdtool sendmail fping imagemagick whois mtr-tiny nmap ipmitool php5-mcrypt php5-json python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git
### Adding the librenms-user ###
useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms www-data
### Cloning ###
You can clone the repository via HTTPS or SSH. In either case, you need to ensure the appropriate port (443 for HTTPS, 22 for SSH) is open in the outbound direction for your server.
@@ -81,7 +86,11 @@ To prepare the web interface (and adding devices shortly), you'll need to set up
First, create and chown the `rrd` directory and create the `logs` directory
mkdir rrd logs
chown www-data:www-data rrd/
chown www-data:www-data logs
chmod 775 rrd
chown librenms:librenms rrd
> NOTE: If you're planing on running rrdcached, make sure that the path is also chmod'ed to 775 and chown'ed to librenms:librenms.
Next, add the following to `/etc/lighttpd/librenms.conf`
@@ -145,7 +154,7 @@ If the thread count needs to be changed, you can do so by editing the cron file
Create the cronjob
cp librenms.cron /etc/cron.d/librenms
cp librenms.nonroot.cron /etc/cron.d/librenms
### Daily Updates ###

View File

@@ -6,6 +6,8 @@
# YES, THAT MEANS YOU #
/////////////////////////////////////////////////////////
umask(0002);
$config['os']['default']['over'][0]['graph'] = "device_processor";
$config['os']['default']['over'][0]['text'] = "Processor Usage";
$config['os']['default']['over'][1]['graph'] = "device_mempool";

View File

@@ -240,6 +240,9 @@ function delete_device($id)
$ret = '';
$host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
if( empty($host) ) {
return "No such host.";
}
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data)
{
@@ -260,7 +263,11 @@ function delete_device($id)
}
}
shell_exec("rm -rf ".trim($config['rrd_dir'])."/$host");
$ex = shell_exec("bash -c '( [ ! -d ".trim($config['rrd_dir'])."/".$host." ] || rm -vrf ".trim($config['rrd_dir'])."/".$host." 2>&1 ) && echo -n OK'");
$tmp = explode("\n",$ex);
if( $tmp[sizeof($tmp)-1] != "OK" ) {
$ret .= "Could not remove files:\n$ex\n";
}
$ret .= "Removed device $host\n";
return $ret;

View File

@@ -1,3 +1,5 @@
# It's recommended not to run this cron anymore - please see librenms.nonroot.cron
33 */6 * * * root /opt/librenms/discovery.php -h all >> /dev/null 2>&1
*/5 * * * * root /opt/librenms/discovery.php -h new >> /dev/null 2>&1
*/5 * * * * root /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1

7
librenms.nonroot.cron Normal file
View File

@@ -0,0 +1,7 @@
# Using this cron file requires an additional user on your system, please see install docs.
33 */6 * * * librenms /opt/librenms/discovery.php -h all >> /dev/null 2>&1
*/5 * * * * librenms /opt/librenms/discovery.php -h new >> /dev/null 2>&1
*/5 * * * * librenms /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1
15 0 * * * librenms sh /opt/librenms/daily.sh >> /dev/null 2>&1
* * * * * librenms /opt/librenms/alerts.php >> /dev/null 2>&1