mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
ping_all
This commit is contained in:
parent
e5b511f2ae
commit
32a742f10d
1
.gitignore
vendored
1
.gitignore
vendored
@ -98,6 +98,7 @@ apps/dgiot_demo/
|
||||
apps/dgiot_jingmao/
|
||||
apps/dgiot_atom/
|
||||
apps/dgiot_12184/
|
||||
apps/dgiot_rtsp2ws/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
erlang_ls.config
|
||||
|
@ -997,15 +997,20 @@ get_port(Socket) ->
|
||||
%%[global, {capture, all_but_first, binary}])
|
||||
|
||||
ping_all() ->
|
||||
lists:map(fun({A, B, C, _D}) ->
|
||||
Cmd = "for /l %i in (1,1,255) do ping -n 1 -w 50 "
|
||||
++ to_list(A) ++ "."
|
||||
++ to_list(B) ++ "."
|
||||
++ to_list(C) ++ "."
|
||||
++ "%i",
|
||||
os:cmd(Cmd)
|
||||
end,
|
||||
get_ifaddrs()).
|
||||
lists:map(
|
||||
fun({A, B, C, _D}) ->
|
||||
lists:map(
|
||||
fun(N) ->
|
||||
Cmd =
|
||||
case os:type() of
|
||||
{unix, linux} ->
|
||||
"ping -c 1 -w 50 " ++ to_list(A) ++ "." ++ to_list(B) ++ "." ++ to_list(C) ++ "." ++ dgiot_utils:to_list(N);
|
||||
_ ->
|
||||
"ping -n 1 -w 50 " ++ to_list(A) ++ "." ++ to_list(B) ++ "." ++ to_list(C) ++ "." ++ dgiot_utils:to_list(N)
|
||||
end,
|
||||
os:cmd(Cmd)
|
||||
end, lists:seq(1, 255))
|
||||
end, get_ifaddrs()).
|
||||
|
||||
get_ifaddrs() ->
|
||||
case inet:getifaddrs() of
|
||||
|
@ -40,6 +40,7 @@
|
||||
triggeralarm/2,
|
||||
send_msg/1,
|
||||
sendSubscribe/1,
|
||||
send_dashboard/1,
|
||||
get_defultmessage/1,
|
||||
replace_miniparam/10
|
||||
]).
|
||||
@ -203,6 +204,7 @@ add_notification(<<"start_", Ruleid/binary>>, DeviceId, Payload) ->
|
||||
NotificationId = dgiot_parse_id:get_notificationid(Ruleid),
|
||||
dgiot_data:insert(?NOTIFICATION, {DeviceId, Ruleid}, {start, dgiot_datetime:now_secs(), NotificationId}),
|
||||
Content = save_notification(Ruleid, DeviceId, Payload, NotificationId),
|
||||
dgiot_umeng:send_dashboard(Content),
|
||||
dgiot_umeng:send_other(Content),
|
||||
dgiot_umeng:send_maintenance(Content#{<<"notificationid">> => NotificationId}),
|
||||
dgiot_umeng:send_msg(Content),
|
||||
@ -625,6 +627,41 @@ sendSubscribe(_O) ->
|
||||
%% io:format("~s ~p _O = ~p.~n", [?FILE, ?LINE, _O]),
|
||||
pass.
|
||||
|
||||
%% 推送前端弹框
|
||||
send_dashboard(#{<<"_deviceid">> := DeviceId, <<"dgiot_alarmvalue">> := Alarmvalue} = Args) ->
|
||||
case dgiot_parse:get_object(<<"Device">>, DeviceId) of
|
||||
{ok, #{<<"name">> := DeviceName, <<"product">> := #{<<"objectId">> := ProductId}}} ->
|
||||
ProductName =
|
||||
case dgiot_parse:get_object(<<"Product">>, ProductId) of
|
||||
{ok, #{<<"name">> := Name1}} ->
|
||||
Name1;
|
||||
_ ->
|
||||
<<>>
|
||||
end,
|
||||
<<Number:10/binary, _/binary>> = dgiot_utils:random(),
|
||||
Timestamp = dgiot_datetime:format(dgiot_datetime:to_localtime(dgiot_datetime:now_secs()), <<"YY-MM-DD HH:NN:SS">>),
|
||||
%% BinAlarmvalue = dgiot_utils:to_binary(Alarmvalue),
|
||||
Data = #{
|
||||
<<"id">> => Number,
|
||||
<<"deviceid">> => DeviceId,
|
||||
<<"devicename">> => DeviceName,
|
||||
<<"productid">> => ProductId,
|
||||
<<"productname">> => ProductName,
|
||||
<<"value">> => Alarmvalue,
|
||||
<<"time">> => Timestamp,
|
||||
<<"level">> => 1,
|
||||
<<"type">> => <<"warn">>,
|
||||
<<"description">> => maps:get(<<"description">>, Args, <<>>)
|
||||
},
|
||||
Pubtopic = <<"$dg/user/dashboard/notification/report">>,
|
||||
dgiot_mqtt:publish(DeviceId, Pubtopic, dgiot_json:encode(Data));
|
||||
_ ->
|
||||
pass
|
||||
end;
|
||||
|
||||
send_dashboard(_O) ->
|
||||
pass.
|
||||
|
||||
%% 推送第三方
|
||||
send_other(#{<<"send_alarm_status">> := <<"start">>, <<"_deviceid">> := DeviceId, <<"_viewid">> := ViewId, <<"dgiot_alarmvalue">> := Alarmvalue}) ->
|
||||
case dgiot_parse:get_object(<<"View">>, ViewId) of
|
||||
|
Loading…
Reference in New Issue
Block a user