Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce own librenms user and remove rrds when removing a device #1071

Merged
merged 1 commit into from
May 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions doc/Installation/Installation-(Debian-Ubuntu).md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`:

Expand Down Expand Up @@ -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 ###

Expand Down
16 changes: 13 additions & 3 deletions doc/Installation/Installation-(RHEL-CentOS).md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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 ###

Expand Down
13 changes: 11 additions & 2 deletions doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`

Expand Down Expand Up @@ -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 ###

Expand Down
2 changes: 2 additions & 0 deletions includes/definitions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 8 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions librenms.cron
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions librenms.nonroot.cron
Original file line number Diff line number Diff line change
@@ -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