librenms-librenms/LibreNMS/Util/StringHelpers.php
Martijn Schmidt e0da083f5c New OS: Schleifenbauer, entity-physical improvements, various html page fixes (#9471)
* Fix some comment and documentation typos.

* Fix various entphysical page display issues.

- Resolve flickering during loading (missing liClosed for nested items).
- Clicking a sensor actually takes you to the matching graph now.

* Add a few nicecase() calls to clean up html page display.

* Create discover_entity_physical() function

- Add discover_entity_physical() function into includes/discovery/functions.inc.php
- This allows for an easy implementation of OS-specific entity-physical discovery.
- Update includes/discovery/entity-physical/entity-physical.inc.php to use the new function.

* Add power_consumed and power_factor sensors.

* Two new icons, make more entPhysical data visible.

* Pre-commit fix: blank line found at end of control structure.

* Add Schleifenbauer OS support.

* Now really fix the comment typo.

* Fix parsing mistakes.

* Add a generic count sensor.

* Make the Schleifenbauer discovery use count instead of state sensors.

* Don't place count sensor at the top, add sane limits for Schleifenbauer

* Finetuning the rrd_options, changing Schleifenbauer sensor names.

* Update schleifenbauer.svg

* optimize logo too

* add test data

* fix sensor value display (spaces break it)

* update entPhysicalIndex
2019-01-20 12:24:11 -06:00

82 lines
2.5 KiB
PHP

<?php
/**
* Text.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Util;
class StringHelpers
{
/**
* Shorten text over 50 chars, if shortened, add ellipsis
*
* @param $string
* @param int $max
* @return string
*/
public static function shortenText($string, $max = 30)
{
if (strlen($string) > 50) {
return substr($string, 0, $max) . "...";
}
return $string;
}
public static function niceCase($string)
{
$replacements = [
'dbm' => 'dBm',
'entropy' => 'Random entropy',
'mysql' => 'MySQL',
'powerdns' => 'PowerDNS',
'bind' => 'BIND',
'nfs-stats' => 'NFS Stats',
'nfs-v3-stats' => 'NFS v3 Stats',
'nfs-server' => 'NFS Server',
'ntp' => 'NTP',
'ntp-client' => 'NTP Client',
'ntp-server' => 'NTP Server',
'os-updates' => 'OS Updates',
'smart' => 'SMART',
'powerdns-recursor' => 'PowerDNS Recursor',
'powerdns-dnsdist' => 'PowerDNS dnsdist',
'dhcp-stats' => 'DHCP Stats',
'ups-nut' => 'UPS nut',
'ups-apcups' => 'UPS apcups',
'gpsd' => 'GPSD',
'exim-stats' => 'EXIM Stats',
'fbsd-nfs-client' => 'FreeBSD NFS Client',
'fbsd-nfs-server' => 'FreeBSD NFS Server',
'php-fpm' => 'PHP-FPM',
'opengridscheduler' => 'Open Grid Scheduler',
'sdfsinfo' => 'SDFS info',
'freeradius' => 'FreeRADIUS',
'pi-hole' => 'pi-hole',
'zfs' => 'ZFS',
];
return isset($replacements[$string]) ? $replacements[$string] : ucwords(str_replace(['_', '-'], ' ', $string));
}
}