小编Fra*_*ubl的帖子

根据条件添加到 JSON ($payload={})

我将 JSON 提供给某个 webhook 以触发通知(M$ 团队)。这很好用。但是,我想扩展我的 Perl 脚本:我需要在特定条件下向我的“消息卡”构造添加一个新节点

例如我定义了这个:

my $payload={};
$payload = {
    '@type' => 'MessageCard',
    '@context' => 'http://schema.org/extensions',
    themeColor => $event{COLOR},
    text => $event{SERVICEOUTPUT},
    sections => [{
        facts => [{
            name => 'Type',
            value => "$event{NOTIFICATIONTYPE} $event{ADDITIONALINFO}"
        },
        ]
    }],
    potentialAction => [{
        '@type' => "OpenUri",
        name => "View Monitoring",
        targets => [{
            os => "default",
            uri => $naemon_url
        }]
    }]
};

$ua = LWP::UserAgent->new;
my $req = POST($opt_webhook
    , 'Content-Type' => 'application/json; charset=UTF-8'
    , 'Content' …
Run Code Online (Sandbox Code Playgroud)

perl json nagios

3
推荐指数
1
解决办法
48
查看次数

标签 统计

json ×1

nagios ×1

perl ×1