<?php
ini_set('memory_limit', '1024M'); // Use 1G
// /usr/bin/php /opt/lampp/htdocs/CAP_1000/get_request_multi.php
date_default_timezone_set('America/Denver');
include "conn.php";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$current_time=time();
$time_less_day=time() - 24*60*60;
$date = date("D M d g:i:s T o");
$result = pg_query($con2,"SELECT * FROM eb_devices WHERE device_modelid = '9'");
while ($row = pg_fetch_array($result)){
$cap_ip = trim($row[3]);
// $cap_ip = '172.30.209.74';
echo "Trying " . $cap_ip . "\n";
$check_for_ip_result=pg_query($con2, "SELECT * FROM lb_cap_status WHERE cap_ip = '$cap_ip'");
$check_for_ip_row = pg_fetch_array($check_for_ip_result);
if($check_for_ip_row == ''){
$insert_offline=pg_query($con2, "INSERT INTO lb_cap_status (cap_ip, online, mode, cpr_state)
VALUES ('$cap_ip', '0', '0', '0')");
}
//make the connection with curl
$cl = curl_init($cap_ip);
curl_setopt($cl,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($cl,CURLOPT_HEADER,true);
curl_setopt($cl,CURLOPT_NOBODY,true);
curl_setopt($cl,CURLOPT_RETURNTRANSFER,true);
//get response
$response = curl_exec($cl);
curl_close($cl);
if (!$response) {
// echo $cap_ip . " is offline.\n";
// echo "----------\n";
$update_offline=pg_query($con2, "UPDATE lb_cap_status SET cap_ip='$cap_ip', online='0', active_cap_ip='0' WHERE cap_ip = '$cap_ip'");
}else{
/////////Test login attempt////////
$login_xml_data ='<?xml version="1.0" encoding="UTF-8"?>
<request id="G1000" origin="gui" destination="device" command="add" category="login" time="'.$date.'" protocol-version="4.0" platform-name="CAP-1000" type="push">
<user name="APIUser" password="APIP@$$w0rd" authentication="embedded" />
</request>';
$URL = "http://".$cap_ip.":80/xmlrq";
$headers = array();
array_push($headers, "Content-Type: text/xml");
array_push($headers, "Accept: text/xml");
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login_output = curl_exec($ch);
curl_close($ch);
$login_xml = simplexml_load_string($login_output);
if(strpos($login_xml->reason, 'XML messaging protocol mismatch.') === false){
$proto = '4.0';
}else{
$proto = '3.0';
}
// echo $cap_ip . "|";
// echo $proto . "<br>";
/////////Test login attempt////////
/////////Login with correct protocol////////
$login_xml_data ='<?xml version="1.0" encoding="UTF-8"?>
<request id="G1000" origin="gui" destination="device" command="add" category="login" time="'.$date.'" protocol-version="'.$proto.'" platform-name="CAP-1000" type="push">
<user name="APIUser" password="APIP@$$w0rd" authentication="embedded" />
</request>';
$URL = "http://".$cap_ip.":80/xmlrq";
$headers = array();
array_push($headers, "Content-Type: text/xml");
array_push($headers, "Accept: text/xml");
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login_output = curl_exec($ch);
curl_close($ch);
$login_xml2 = simplexml_load_string($login_output);
$session_id = $login_xml2->session['sid'];
$xml_sid = $login_xml2->session['sid'];
$manager_id=$login_xml2->session['manager-id'];
//echo "<hr>";
//print_r($login_xml2);
//echo "<hr>";
// echo $manager_id . "\n";
// echo "----------\n";
//////////////////////////////////*End of login*//////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
$update_xml_config_data =
'<?xml version="1.0" encoding="UTF-8"?>
<request id="G1020" origin="gui" destination="device" command="get"
category="users" time="'.$date.'" protocol-version="'.$proto.'"
platform-name="CAP-1000" sid="'.$xml_sid.'">
<path>
<manager id="'.$manager_id.'" />
<farmer id="'.$manager_id.'" />
</path>
<users />
</request> ';
$headers = array();
array_push($headers, "Content-Type: text/xml");
array_push($headers, "Accept: text/xml");
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $update_xml_config_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$config_output = curl_exec($ch);
curl_close($ch);
$get_xml_config = simplexml_load_string($config_output);
if ($get_xml_config->reason != ''){
echo "<b>" . $cap_ip . " Failed " . $date . "\n";
$insert_offline=pg_query($con2, "INSERT INTO lb_failed_login (cap_ip, proto, account, checked)
VALUES ('$cap_ip', '$proto', 'radius', '0')");
mail('lane.brunson@charter.com', 'CAP Admin account failed', "\n\r" . $cap_ip . "\nRadius login failed. Proto = " .$proto , null,
'-fadmin@lanebrunson.com');
}else{
echo $cap_ip . " Passed " . $date . "\n";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////*Beginning of logout*///////////////////////////
$logout_xml_data ='<?xml version="1.0" encoding="UTF-8"?>
<request id="G1057" origin="gui" destination="device" command="remove"
category="login" protocol-version="'.$proto.'"
platform-name="CAP-1000" sid="'.$login_xml->session['sid'].'" />
';
// print $logout_xml_data;
$URL = "http://".$cap_ip.":80/xmlrq";
$headers = array();
array_push($headers, "Content-Type: text/xml");
array_push($headers, "Accept: text/xml");
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $logout_xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$logout_output = curl_exec($ch);
curl_close($ch);
/*End of logout*/
}
}
?>
分享到:
相关推荐
PhoneX_NO_CHECK_v2.2.7_release_2020-10-12_227_jiagu_sign.apk.1.apk
网盘文件永久链接 Check_Point_R75.40.Splat.zip
为了更有效地进行日志检查,我们可以选择使用ConSol Labs开发的check_logfiles插件,它提供了更多的高级特性,如处理截断日志、支持宏定义和正则表达式等,极大地增强了监控的灵活性。 **1. 安装check_logfiles** ...
升级win11跳过TPM检测
v_check_dark_x24.xml
build_file_checksums.ser
check_all_input_v1.1 微信小程序input选中内容组件代码check_all_input,实现input自由选中内容的功能效果!欢迎大家使用。 相关文章 https://blog.csdn.net/java558/article/details/100133614
亲测有效 通过此版本可以把oracle时区版本调整到为最新版本,一般配合时区补丁使用 可以参考...脚本里有说明 先运行upg_tzv_check.sql再运行upg_tzv_apply.sql
解决myeclipse10.6不能正常导出ear或war包问题,导出时出现security alert:integrity check error 内附解决方法和jar包com.genuitec.eclipse.export.wizard_9.0.0.me201203160414.jar 关掉myeclipse10.6,替换文件,...
nagios软件包集合: Class-Accessor-0.31.tar.gz Config-Tiny-2.12.tar.gz libart_lgpl-2.3.17.tar.gz Math-Calc-Units-1.07.tar.gz nagios-3.5.1.tar.gz Nagios-Plugin-0.34.tar.gz ...check_mysql
《深入理解Nginx Upstream Check Module:2019年版》 Nginx作为一款高性能的HTTP和反向代理服务器,广泛应用于各种互联网服务中。为了提高系统的可用性和可靠性,Nginx提供了丰富的模块扩展,其中Nginx Upstream ...
docker容器中编译安装第三方后端检查模块nginx_upstream_check_module 使用方法见:https://blog.csdn.net/pcn01/article/details/105182600
check_snmp_storage 存储检查(磁盘、交换、内存等) check_snmp_int 接口状态、主机、交换机、路由器等的使用情况。 check_snmp_process 正在运行的进程、它们的数量、使用的 CPU 和内存。 check_snmp_load 负载/...
该压缩包文件名"check_default_route"暗示其内部可能包含一个名为"check_default_route"的脚本文件,可能是用bash或其他shell脚本语言编写的。这个脚本可能用于自动检测和验证系统是否正确设置了默认路由,确保所有...
Linux下的perl脚本文件check_linux_stats.pl,可用于nagios中进程的监控,具体安装方法在我博客中有介绍。
《惠普服务器管理工具check_hpasm详解》 在IT运维领域,有效监控服务器硬件状态是保障业务稳定运行的关键。惠普公司为此提供了check_hpasm工具,这是一个专门用于监控HP(Hewlett-Packard)服务器硬件状态的开源...
《PyPI官网下载 | checkio_client-0.2.10.tar.gz——探索Python库的分布式应用》 PyPI(Python Package Index)是Python开发者的重要资源库,它提供了丰富的Python库,供全球开发者下载和使用。在PyPI官网上,我们...
《PyPI官网下载:check_systemd-2.0.6.tar.gz详解》 在Python的世界里,PyPI(Python Package Index)是最重要的软件仓库,它为开发者提供了分享和下载Python库的平台。本文将深入探讨从PyPI官网下载的资源——`...
本话题主要围绕"check_snmp_cisco.zip"这一压缩包,它是Nagios监控Cisco交换机CPU和内存利用率的一种实现方式,通过SNMP(简单网络管理协议)进行数据采集。 首先,让我们了解一下SNMP。SNMP是Internet上的标准管理...
PHP的文档的扩展必备神器,主要用于在php环境里调用windows api以及处理word文档,先在php.ini文件中开启配置(即设置com.allow_dcom = true),然后下载php_com_dotnet.dll到php的ext扩展目录下,重启Apache后即可...