package init

This commit is contained in:
fun_yang 2020-02-14 14:15:52 +08:00
parent a177319cce
commit 9289a2d2d0
15 changed files with 313 additions and 75 deletions

View File

@ -1,36 +0,0 @@
# mrtg
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,39 +0,0 @@
# mrtg
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

4
filter-provides-mrtg.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
/usr/lib/rpm/find-provides "$@" | grep -v 'perl(\(SNMP_util\|SNMP_Session\|BER\|SNMPv1_Session\|SNMPv2c_Session\))'
exit 0

3
filter-requires-mrtg.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/lib/rpm/find-requires "$@" | grep -v 'perl(\(GD\|MRP::BaseClass\|Net::SNMP\))'

48
mrtg-2.15.0-lib64.patch Normal file
View File

@ -0,0 +1,48 @@
diff -up mrtg-2.17.7/bin/cfgmaker.orig mrtg-2.17.7/bin/cfgmaker
--- mrtg-2.17.7/bin/cfgmaker.orig 2018-07-13 08:09:56.000000000 +0200
+++ mrtg-2.17.7/bin/cfgmaker 2018-08-08 13:07:38.419241131 +0200
@@ -44,7 +44,7 @@ BEGIN {
use FindBin;
use lib "${FindBin::Bin}";
-use lib "${FindBin::Bin}${main::SL}..${main::SL}lib${main::SL}mrtg2";
+use lib "${FindBin::Bin}${main::SL}..${main::SL}@@lib@@${main::SL}mrtg2";
use MRTG_lib "2.100015";
use Getopt::Long;
diff -up mrtg-2.17.7/bin/indexmaker.orig mrtg-2.17.7/bin/indexmaker
--- mrtg-2.17.7/bin/indexmaker.orig 2018-07-13 08:09:56.000000000 +0200
+++ mrtg-2.17.7/bin/indexmaker 2018-08-08 13:08:41.187309764 +0200
@@ -48,7 +48,7 @@ BEGIN {
use FindBin;
use lib "${FindBin::Bin}";
-use lib "${FindBin::Bin}${main::SL}..${main::SL}lib${main::SL}mrtg2";
+use lib "${FindBin::Bin}${main::SL}..${main::SL}@@lib@@${main::SL}mrtg2";
use MRTG_lib "2.100016";
use Getopt::Long;
diff -up mrtg-2.17.7/bin/mrtg.orig mrtg-2.17.7/bin/mrtg
--- mrtg-2.17.7/bin/mrtg.orig 2018-07-13 08:09:56.000000000 +0200
+++ mrtg-2.17.7/bin/mrtg 2018-08-08 13:09:07.459338491 +0200
@@ -81,7 +81,7 @@ ERR
use FindBin;
use lib "${FindBin::Bin}";
-use lib "${FindBin::Bin}${main::SL}..${main::SL}lib${main::SL}mrtg2";
+use lib "${FindBin::Bin}${main::SL}..${main::SL}@@lib@@${main::SL}mrtg2";
use Getopt::Long;
use Math::BigFloat;
diff -up mrtg-2.17.7/bin/mrtg-traffic-sum.orig mrtg-2.17.7/bin/mrtg-traffic-sum
--- mrtg-2.17.7/bin/mrtg-traffic-sum.orig 2017-03-05 15:09:52.000000000 +0100
+++ mrtg-2.17.7/bin/mrtg-traffic-sum 2018-08-08 13:08:17.650284034 +0200
@@ -33,7 +33,7 @@ BEGIN {
use FindBin;
use lib "${FindBin::Bin}";
-use lib "${FindBin::Bin}${main::SL}..${main::SL}lib${main::SL}mrtg2";
+use lib "${FindBin::Bin}${main::SL}..${main::SL}@@lib@@${main::SL}mrtg2";
use MRTG_lib "2.090017";
use POSIX qw(mktime);

View File

@ -0,0 +1,33 @@
diff -up mrtg-2.17.7/bin/mrtg.orig mrtg-2.17.7/bin/mrtg
--- mrtg-2.17.7/bin/mrtg.orig 2018-08-08 13:09:59.682296406 +0200
+++ mrtg-2.17.7/bin/mrtg 2018-08-08 13:11:01.089173582 +0200
@@ -302,7 +302,7 @@ sub main {
if ($cfg{enableipv6} eq 'yes') {
if ( eval {local $SIG{__DIE__};require Socket; require Socket6; require IO::Socket::INET6;}) {
import Socket;
- import Socket6;
+ Socket6->import(qw(inet_pton getaddrinfo));
debug('base', "IPv6 libraries found, IPv6 enabled.");
} else {
warn "$NOW: WARNING: IPv6 libraries not found, IPv6 disabled.\n";
diff -up mrtg-2.17.7/lib/mrtg2/SNMP_Session.pm.orig mrtg-2.17.7/lib/mrtg2/SNMP_Session.pm
--- mrtg-2.17.7/lib/mrtg2/SNMP_Session.pm.orig 2018-07-13 08:09:56.000000000 +0200
+++ mrtg-2.17.7/lib/mrtg2/SNMP_Session.pm 2018-08-08 13:13:15.361988807 +0200
@@ -146,7 +146,7 @@ BEGIN {
if (eval {local $SIG{__DIE__};require Socket6;} &&
eval {local $SIG{__DIE__};require IO::Socket::INET6; IO::Socket::INET6->VERSION("1.26");}) {
- Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
+ Socket6->import(qw(inet_pton getaddrinfo inet_ntop));
$ipv6_addr_len = length(pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
$SNMP_Session::ipv6available = 1;
}
@@ -601,7 +601,7 @@ use Carp;
BEGIN {
if($SNMP_Session::ipv6available) {
import IO::Socket::INET6;
- Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
+ Socket6->import(qw(inet_pton getaddrinfo inet_ntop));
}
}

View File

@ -0,0 +1,12 @@
diff -up mrtg-2.17.7/bin/cfgmaker.orig mrtg-2.17.7/bin/cfgmaker
--- mrtg-2.17.7/bin/cfgmaker.orig 2018-08-08 13:14:19.609048676 +0200
+++ mrtg-2.17.7/bin/cfgmaker 2018-08-08 13:15:17.795102892 +0200
@@ -224,7 +224,7 @@ sub InterfaceInfo($$$$$) {
# maximum value (4,294,967,295) and ifHighSpeed must be used
# to report the interace's speed. For a sub-layer which has
# no concept of bandwidth, this object should be zero."
- if ( (not defined $value) || ($value == 2**32-1) ) {
+ if ( (not defined $value) || ($value == 2**32-1) || ($value == 2**32-2)) {
($if, $value) = split /:/, $ifHighSpeed[$i], 2;
$value = $value * 1000000; # highSpeed = contador * 10^6
debug('base',"Speed: $if - $value");

BIN
mrtg-2.17.7.tar.gz Normal file

Binary file not shown.

1
mrtg-2.17.7.tar.gz.md5 Normal file
View File

@ -0,0 +1 @@
eada3870c0419e425299401486600d95 mrtg-2.17.7.tar.gz

12
mrtg-httpd.conf Normal file
View File

@ -0,0 +1,12 @@
#
# This configuration file maps the mrtg output (generated daily)
# into the URL space. By default these results are only accessible
# from the local host.
#
Alias /mrtg /var/www/mrtg
<Location /mrtg>
Require local
# Require ip 10.1.2.3
# Require host example.org
</Location>

23
mrtg.cfg Normal file
View File

@ -0,0 +1,23 @@
######################################################################
# Multi Router Traffic Grapher -- Example Configuration File
######################################################################
# This file is for use with mrtg-2.0
#
# Note:
#
# * Keywords must start at the begin of a line.
#
# * Lines which follow a keyword line which do start
# with a blank are appended to the keyword line
#
# * Empty Lines are ignored
# * Lines starting with a # sign are comments.
# Where should the logfiles, and webpages be created?
# Minimal mrtg.cfg
#--------------------
HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg

29
mrtg.service Normal file
View File

@ -0,0 +1,29 @@
# To customize, copy this file to /etc/systemd/system and edit there
#
# This unit facilitates starting of MRTG. There are 2 options of
# how to run MRTG:
# - as a daemon (preferred); in this case please put
# RunAsDaemon: yes in mrtg.conf (or use --daemon switch)
# - periodically - please see and enable mrtg.timer
# Periodic settings need Type=oneshot set here
#
# Other recommended settings in mrtg.cfg for daemon mode:
# NoDetach: yes
# If you set this, change below Type=simple
#
# Please disable /etc/crond.d/mrtg job when using this unit!
#
# do not enable both mrtg-as-a-daemon and timer at the same time
[Unit]
Description=Multi-router Traffic Grapher
After=syslog.target
[Service]
Environment=LANG=C
ExecStart=/usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Type=simple
StandardOutput=syslog
[Install]
WantedBy=multi-user.target

126
mrtg.spec Normal file
View File

@ -0,0 +1,126 @@
%global _use_internal_dependency_generator 0
%global contentdir %{_localstatedir}/www/mrtg
%global libdir %{_localstatedir}/lib/mrtg
%global __find_requires %_sourcedir/filter-requires-mrtg.sh
%global __find_provides %_sourcedir/filter-provides-mrtg.sh
Name: mrtg
Version: 2.17.7
Release: 3
Summary: Multi Router Traffic Grapher
License: GPLv2+
URL: http://oss.oetiker.ch/mrtg/
Source0: http://oss.oetiker.ch/mrtg/pub/mrtg-%{version}.tar.gz
Source1: mrtg.cfg
Source2: filter-requires-mrtg.sh
Source3: mrtg-httpd.conf
Source4: filter-provides-mrtg.sh
Source5: mrtg.tmpfiles
Source6: mrtg.service
Source7: mrtg.timer
Patch0: mrtg-2.15.0-lib64.patch
Patch1: mrtg-2.17.2-socket6-fix.patch
Patch2: mrtg-2.17.4-cfgmaker-ifhighspeed.patch
BuildRequires: gd-devel libpng-devel perl-generators systemd-units gcc
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires: perl-Socket6 perl-IO-Socket-INET6 gd
%description
MRTG is a tool to monitor SNMP network devices and draw pretty pictures showing
how much traffic has passed through each interface.
%package_help
%prep
%autosetup -n %{name}-%{version} -p1
rm -rf contrib/nt-services
for i in doc/mrtg-forum.1 doc/mrtg-squid.1 CHANGES; do
iconv -f iso-8859-1 -t utf-8 < "$i" > "${i}_"
mv "${i}_" "$i"
done
%build
%configure
make LIBS='-lgd -lm'
pushd contrib
find . -type f -exec \
%{__perl} -e 's,^#!/\s*\S*perl\S*,#!%{__perl},gi' -p -i \{\} \;
find . -name "*.pl" -exec %{__perl} -e 's;\015;;gi' -p -i \{\} \;
find . -type f | xargs chmod a-x
popd
%install
chmod +x %_sourcedir/filter-*-mrtg.sh
%make_install
pushd %{buildroot}
mkdir -p .%{contentdir}
mkdir -p .%{_sysconfdir}/mrtg
mkdir -p .%{_sysconfdir}/httpd/conf.d
mkdir -p .%{_localstatedir}/lib/mrtg
mkdir -p .%{_localstatedir}/lock/mrtg
install -m 644 %_builddir/%{name}-%{version}/images/* .%{contentdir}/
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/mrtg/mrtg.cfg
install -m 644 %{SOURCE3} .%{_sysconfdir}/httpd/conf.d/mrtg.conf
mkdir -p ./%{_tmpfilesdir}
install -p -D -m 644 %{SOURCE5} ./%{_tmpfilesdir}/mrtg.conf
mkdir -p .%{_unitdir}
install -p -m 644 %{SOURCE6} .%{_unitdir}/mrtg.service
install -p -m 644 %{SOURCE7} .%{_unitdir}/mrtg.timer
for i in mrtg cfgmaker indexmaker mrtg-traffic-sum; do
sed -i 's;@@lib@@;%{_lib};g' .%{_bindir}/"$i"
done
sed -i 's;@@lib@@;%{_lib};g' .%{_mandir}/man1/*.1
popd
%post
install -d -m 0755 -o root -g root /var/lock/mrtg
restorecon /var/lock/mrtg
%systemd_post mrtg.service
%preun
if [ $1 -eq 0 ]; then
rm -rf /var/lock/mrtg
fi
%systemd_preun mrtg.service
%postun
%systemd_postun_with_restart mrtg.service
%files
%defattr(-,root,root)
%license COPYING COPYRIGHT
%ghost /var/lock/mrtg
%{_tmpfilesdir}/mrtg.conf
%dir %{_sysconfdir}/mrtg
%config(noreplace) %{_sysconfdir}/mrtg/mrtg.cfg
%config(noreplace) %{_sysconfdir}/httpd/conf.d/mrtg.conf
%{_bindir}/*
%{_libdir}/mrtg2
%dir %{_localstatedir}/lib/mrtg
%{_unitdir}/mrtg.timer
%{_unitdir}/mrtg.service
%{contentdir}
%exclude %{_datadir}/doc/mrtg2
%exclude %{_datadir}/mrtg2/icons
%exclude %{_libdir}/mrtg2/Pod
%files help
%defattr(-,root,root)
%doc contrib CHANGES README THANKS
%{_mandir}/*/*
%changelog
* Thu Nov 21 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.17.7-3
- Package init

20
mrtg.timer Normal file
View File

@ -0,0 +1,20 @@
# To customize, copy this file to /etc/systemd/system and edit there
#
# You can use this unit to periodically run mrtg.service.
# Only enable if you do not want to run mrtg as a daemon.
# Starting mrtg.timer while mrtg.service is running as a daemon has no point.
#
# Please disable /etc/crond.d/mrtg job when using this unit!
#
# Default is to run mrtg.service every 5 minutes, starting
# 1 minute after system boot.
[Unit]
Description=periodic invocation of MRTG
[Timer]
OnBootSec=2m
OnUnitActiveSec=6m
[Install]
WantedBy=multi-user.target

2
mrtg.tmpfiles Normal file
View File

@ -0,0 +1,2 @@
d /var/lock/mrtg 0755 root root -
d /var/lib/mrtg 0755 root root -