This page includes an update to the socket_count.cm macro that first appeared in the December 2006 Stratus eCustomer Newsletter. I refer you to that document for an explaination of all the macro's output.
The change was required because it was determining the number of tc_entries and lines generated by netstat by doing a display_file_status on the respective output files and then extracting the record count from the 23rd line. This worked fine until I ran into a site that linked the process_dir_dir to a non-standard location. The result was that display_file_status added an extra line indicating the real location. This moved the record count to the 24th line and the macro reported incorrect results.
The new mechanism creates a relative file and then copies the sequential file with the data to be counted into the relative file. I can then use the "last_record" key with the file_info command function. For example:
&if (exists (process_dir)>tc_entries2) &then delete_file (process_dir)>tc_entries2 -no_ask create_file (process_dir)>tc_entries2 -organization relative -record_size 256 copy_file (process_dir)>tc_entries (process_dir)>tc_entries2 -truncate &set records (file_info (process_dir)>tc_entries2 last_record) |
& socket_count begins here & & socket_count.cm & version 2.0 06-11-01 & 2.1 08-02-07 changed the way tc_entries and netstat lines are & counted to fix a problem caused when the process & directory is a link & Noah Davids Stratus CAC noah.davids@stratus.com & &attach_input &set START (calc (length (system_name)) + 3) &set_string STCP_DEVICE stcp.(substr (current_module) &START&) & analyze_system ..attach_default_output (process_dir)>tc_entries match tcb; dump_tcentry ..detach_default_output ..attach_default_output (process_dir)>ntcpcon d ntcpcon ..detach_default_output ..attach_default_output (process_dir)>clones match clone_count; dump_dvt -name &STCP_DEVICE& match clone_limit; dump_dvt -name &STCP_DEVICE& ..detach_default_output ..attach_default_output (process_dir)>devices d configured_local_devices$ d max_local_devices$ ..detach_default_output ..attach_default_output (process_dir)>pmm match 'pmm_limit' ; dump_stream -stm_msg match 'hq_pool[0]->pmm_total_size' ; dump_stream -stm_msg match 'hq_pool[0]->pmm_allocated_size' ; dump_stream -stm_msg ..detach_default_output quit attach_default_output (process_dir)>netstat >system>stcp>command_library>netstat -numeric -all_sockets -protocol tcp detach_default_output & &if (exists (process_dir)>tc_entries2) &then delete_file (process_dir)>tc_entries2 -no_ask create_file (process_dir)>tc_entries2 -organization relative -record_size 256 copy_file (process_dir)>tc_entries (process_dir)>tc_entries2 -truncate &set records (file_info (process_dir)>tc_entries2 last_record) & display_line display_line &set NTCPCON (calc (substr (contents (process_dir)>ntcpcon 1) 19 8)x) display_line The number of tc_entries at &+ (file_info (process_dir)>tc_entries date_used) is (calc &records& - 2) &+ out of &NTCPCON& & &set CLONE_COUNT (substr (contents (process_dir)>clones 1) 25) &set CLONE_LIMIT (substr (contents (process_dir)>clones 2) 25) display_line The &STCP_DEVICE& clone count at &+ (file_info (process_dir)>clones date_used) is &CLONE_COUNT& &+ out of &CLONE_LIMIT& & &if (exists (process_dir)>netstat2) &then delete_file (process_dir)>netstat2 -no_ask create_file (process_dir)>netstat2 -organization relative -record_size 256 copy_file (process_dir)>netstat (process_dir)>netstat2 -truncate &set records (file_info (process_dir)>netstat2 last_record) &if &records& = 0 &then display_line No info from netstat, probably no sockets available &else display_line TCP sockets from netstat at &+ (file_info (process_dir)>netstat date_used) is (calc &records& - 2) & &set CONFIG_DEVICES (calc (substr (contents (process_dir)>devices 1) 19 4)x) &set MAX_DEVICES (calc (substr (contents (process_dir)>devices 2) 19 4)x) display_line The number of devices at ' ' &+ (file_info (process_dir)>devices date_used) is &CONFIG_DEVICES& &+ out of &MAX_DEVICES& & &set ALLOC_MEM (substr (contents (process_dir)>pmm 6) 46) &set TOTAL_MEM (substr (contents (process_dir)>pmm 5) 46) &set LO_MEM (substr (contents (process_dir)>pmm 2) 41) &set MED_MEM (substr (contents (process_dir)>pmm 3) 41) &set HI_MEM (substr (contents (process_dir)>pmm 4) 41) &set LO_PER (substr (calc &ALLOC_MEM& / &LO_MEM& * 100) 1 5) &set MED_PER (substr (calc &ALLOC_MEM& / &MED_MEM& * 100) 1 5) &set HI_PER (substr (calc &ALLOC_MEM& / &HI_MEM& * 100) 1 5) display_line &LO_PER&% of LO Streams memory &+ threshold in use as of (file_info (process_dir)>pmm date_used) display_line &MED_PER&% of MED Streams memory &+ threshold in use as of (file_info (process_dir)>pmm date_used) display_line &HI_PER&% of HI Streams memory &+ threshold in use as of (file_info (process_dir)>pmm date_used) & & socket_count ends here |