- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我改变了主意,并试图在 ubuntu 服务器上配置 munin 插件。我在终端中将 Perl 代码粘贴为 bash - 每行代码都作为命令运行。
perl 语法是否足够不同,不会对服务器造成任何损坏或意外更改?
这是代码(顺便说一句,它确实在我的主目录中创建了两个文件夹,这就是我担心的原因):
我想知道我是不是无意中弄乱了什么:S
#!/usr/bin/perl
#
# Plugin to monitor the number of accesses to Apache servers. It handles
# a list of ports passed in from a plugin configuration file.
#
# Requirements:
# - Needs access to http://localhost/server-status?auto (or modify the
# address for another host). See your apache documentation on how to
# set up this url in your httpd.conf. Apache needs ExtendedStatus
# enabled for this plugin to work
#
# Tip: To see if it's already set up correctly, just run this plugin
# with the parameter "autoconf". If you get a "yes", everything should
# work like a charm already.
#
# Parameters supported:
#
# config
# autoconf
#
# Configurable variables
#
# url - Override default status-url
# port - HTTP port numbers
#
# ssl - activate SSL (add env.ssl yes in munin plugin configuration)
# urls - Override default status-url (SSL)
# ports - HTTPS port numbers (SSL)
#
# $Log$
# Revision 1.13 2006/03/07 20:30:00 fra519
# adapt script for Apache-SSL Server.
#
# Revision 1.12 2004/12/10 18:51:43 jimmyo
# linux/apt* has been forced to LANG=C, to get predictable output.
#
# Revision 1.11 2004/12/10 10:47:47 jimmyo
# Change name from ${scale} to ${graph_period}, to be more consistent.
#
# Revision 1.10 2004/12/09 22:12:54 jimmyo
# Added "graph_period" option, to make "graph_sums" usable.
#
# Revision 1.9 2004/09/26 22:14:39 jimmyo
# Changd COUNTER -> DERIVE for some plugins. Set min/max values.
#
# Revision 1.8 2004/05/20 13:57:11 jimmyo
# Set categories to some of the plugins.
#
# Revision 1.7 2004/05/14 21:16:46 jimmyo
# "Upped" som plugins from contrib/manual to auto.
#
# Revision 1.6 2004/04/27 21:32:06 jimmyo
# Clarified the vlabels in the apache-plugins (Deb#238594).
#
# Revision 1.5 2004/04/27 08:46:57 jimmyo
# Fixed broken autoconf in apache-* plugins (Deb#236144).
#
# Revision 1.4 2004/02/18 15:47:35 jimmyo
# The generic/apache_* plugins now have defined max values.
#
# Revision 1.3 2004/02/03 17:17:25 jimmyo
# Generic/apache-plugins have been modified to properly to report the correct autoconf value. Also, bugfixes in _processes and _volume.
#
# Revision 1.2 2004/01/29 18:47:30 jimmyo
# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.4 2003/12/18 16:35:33 jimmyo
# fail more gracefully when using uninstalled perl modules.
#
# Revision 1.3 2003/11/07 17:43:16 jimmyo
# Cleanups and log entries
#
#
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
my $ret = undef;
my $ssl = undef;
if (! eval "require LWP::UserAgent;")
{
$ret = "LWP::UserAgent not found";
}
if (! eval "require Crypt::SSLeay;" and exists $ENV{'ssl'})
{
$ssl = "Crypt::SSLeay not found";
}
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
my @PORT = exists $ENV{'port'} ? split(' ', $ENV{'port'}) : (80);
my $URLS = exists $ENV{'urls'} ? $ENV{'urls'} : "https://127.0.0.1:%d/server-status?auto";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (443);
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret)
{
print "no ($ret)\n";
exit 1;
}
if ($ssl) {
print "no ($ssl)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
my @badports;
foreach my $port (@PORT) {
my $url = sprintf $URL, $port;
my $response = $ua->request(HTTP::Request->new('GET',$url));
push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
}
if (exists $ENV{'ssl'}) {
foreach my $port (@PORTS) {
my $url = sprintf $URLS, $port;
my $response = $ua->request(HTTP::Request->new('GET',$url));
push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
}
}
if (@badports) {
print "no (no apache server-status or ExtendedStatus missing on ports @badports)\n";
exit 1;
} else {
print "yes\n";
exit 0;
}
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title Apache accesses\n";
print "graph_args --base 1000\n";
print "graph_vlabel accesses / \${graph_period}\n";
print "graph_category apache\n";
foreach my $port (@PORT) {
print "accesses$port.label port $port\n";
print "accesses$port.type DERIVE\n";
print "accesses$port.max 1000000\n";
print "accesses$port.min 0\n";
}
if (exists $ENV{'ssl'}) {
foreach my $port (@PORTS) {
print "accesses$port.label port $port\n";
print "accesses$port.type DERIVE\n";
print "accesses$port.max 1000000\n";
print "accesses$port.min 0\n";
}
}
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
foreach my $port (@PORT) {
my $url = sprintf $URL, $port;
my $response = $ua->request(HTTP::Request->new('GET',$url));
if ($response->content =~ /^Total Accesses:\s+(.+)$/im) {
print "accesses$port.value $1\n";
} else {
print "accesses$port.value U\n";
}
}
if (exists $ENV{'ssl'}) {
foreach my $port (@PORTS) {
my $url = sprintf $URLS, $port;
my $response = $ua->request(HTTP::Request->new('GET',$url));
if ($response->content =~ /^Total Accesses:\s+(.+)$/im) {
print "accesses$port.value $1\n";
} else {
print "accesses$port.value U\n";
}
}
}
# vim:syntax=perl
最佳答案
评论将被忽略。我最初的意思是 Perl 注释。看起来我将不得不忽略反对票,因为我在这里帮助你 :)
我已将命令粘贴到 vanilla Ubuntu 桌面安装的 bash shell 中。出于各种原因,反对者会(并非不合理地)认为这是一个坏主意。
我的态度是,我有一个备用的 Ubuntu 虚拟机可以用来测试它,所以如果它出现任何问题,我很乐意销毁它。粗略地目视检查代码会发现以下内容。
你有命令 call my 吗?如果不是,则以下代码没有地雷。
my $ret = undef;
my $ssl = undef;
if (! eval "require LWP::UserAgent;")
if (! eval "require Crypt::SSLeay;" and exists $ENV{'ssl'})
{
$ssl = "Crypt::SSLeay not found";
}
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
my @PORT = exists $ENV{'port'} ? split(' ', $ENV{'port'}) : (80);
my $URLS = exists $ENV{'urls'} ? $ENV{'urls'} : "https://127.0.0.1:%d/server-status?auto";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (443);
接下来我们有
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret)
{
print "no ($ret)\n";
exit 1;
}
if ($ssl) {
print "no ($ssl)\n";
exit 1;
exit 1 会将您带出当前 shell。
假设您在子 shell 中进行更多分析...
这是有趣的代码。
rkielty@ubuntu:~$ foreach my $port (@PORT) {
bash: syntax error near unexpected token `('
清除地雷
rkielty@ubuntu:~$ push @badports, $port unless $response->is_success and $response->content =~ /^Total Accesses:/im;
The program 'push' is currently not installed. You can install it by typing:
sudo apt-get install heimdal-clients
现在您必须检查您是否有一个push
程序并查看它的作用。
运行 which push
然后 man 或 info push
rkielty@ubuntu:~$ print "no (no apache server-status or ExtendedStatus missing on ports @badports)\n";
Warning: unknown mime-type for "no (no apache server-status or ExtendedStatus missing on ports @badports)\n" -- using "application/octet-stream"
Error: no such file "no (no apache server-status or ExtendedStatus missing on ports @badports)\n"
所以这里我们受到了错误的保护。
从那里开始有两次 exit
调用。
看来你应该没问题。
注意事项是您需要确保系统上没有名为my
或push
的程序
我不确定目录是如何创建的,您可能应该进一步调查。请记住,它们可能不是由此引起的。
关于bash - 如果这些 Perl 命令在粘贴到 shell 中时被解释为 Bash 命令,是否有害?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10914814/
我有一个 if 语句,如下所示 if (not(fullpath.lower().endswith(".pdf")) or not (fullpath.lower().endswith(tup
然而,在 PHP 中,可以: only appears if $foo is true. only appears if $foo is false. 在 Javascript 中,能否在一个脚
XML有很多好处。它既是机器可读的,也是人类可读的,它具有标准化的格式,并且用途广泛。 它也有一些缺点。它是冗长的,不是传输大量数据的非常有效的方法。 XML最有用的方面之一是模式语言。使用模式,您可
由于长期使用 SQL2000,我并没有真正深入了解公用表表达式。 我给出的答案here (#4025380)和 here (#4018793)违背了潮流,因为他们没有使用 CTE。 我很欣赏它们对于递
我有一个应用程序: void deleteObj(id){ MyObj obj = getObjById(id); if (obj == null) { throw n
我的代码如下。可能我以类似的方式多次使用它,即简单地说,我正在以这种方式管理 session 和事务: List users= null; try{ sess
在开发J2EE Web应用程序时,我通常会按以下方式组织我的包结构 com.jameselsey.. 控制器-控制器/操作转到此处 服务-事务服务类,由控制器调用 域-应用程序使用的我的域类/对象 D
这更多是出于好奇而不是任何重要问题,但我只是想知道 memmove 中的以下片段文档: Copying takes place as if an intermediate buffer were us
路径压缩涉及将根指定为路径上每个节点的新父节点——这可能会降低根的等级,并可能降低路径上所有节点的等级。有办法解决这个问题吗?有必要处理这个吗?或者,也许可以将等级视为树高的上限而不是确切的高度? 谢
我有两个类,A 和 B。A 是 B 的父类,我有一个函数接收指向 A 类型类的指针,检查它是否也是 B 类型,如果是将调用另一个函数,该函数接受一个指向类型 B 的类的指针。当函数调用另一个函数时,我
有没有办法让 valgrind 使用多个处理器? 我正在使用 valgrind 的 callgrind 进行一些瓶颈分析,并注意到我的应用程序中的资源使用行为与在 valgrind/callgrind
假设我们要使用 ReaderT [(a,b)]超过 Maybe monad,然后我们想在列表中进行查找。 现在,一个简单且不常见的方法是: 第一种可能性 find a = ReaderT (looku
我的代码似乎有问题。我需要说的是: if ( $('html').attr('lang').val() == 'fr-FR' ) { // do this } else { // do
根据this文章(2018 年 4 月)AKS 在可用性集中运行时能够跨故障域智能放置 Pod,但尚不考虑更新域。很快就会使用更新域将 Pod 放入 AKS 中吗? 最佳答案 当您设置集群时,它已经自
course | section | type comart2 : bsit201 : lec comart2 :
我正在开发自己的 SDK,而这又依赖于某些第 3 方 SDK。例如 - OkHttp。 我应该将 OkHttp 添加到我的 build.gradle 中,还是让我的 SDK 用户包含它?在这种情况下,
随着 Rust 越来越充实,我对它的兴趣开始激起。我喜欢它支持代数数据类型,尤其是那些匹配的事实,但是对其他功能习语有什么想法吗? 例如标准库中是否有标准过滤器/映射/归约函数的集合,更重要的是,您能
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 9 年前。 Improve
我一直在研究 PHP 中的对象。我见过的所有示例甚至在它们自己的对象上都使用了对象构造函数。 PHP 会强制您这样做吗?如果是,为什么? 例如: firstname = $firstname;
...比关联数组? 关联数组会占用更多内存吗? $arr = array(1, 1, 1); $arr[10] = 1; $arr[] = 1; // <- index is 11; does the
我是一名优秀的程序员,十分优秀!